Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

blueslip: Untangle from page_params.

Anders Kaseorg0b3cf7833352
diff --git a/.eslintrc.js b/.eslintrc.js
index f82ef410fb6..1ceca87ce2f 100644
--- a/.eslintrc.js
+++ b/.eslintrc.js
@@ -247,6 +247,7 @@ module.exports = {
node: false,
},
globals: {
+ DEVELOPMENT: false,
ZULIP_VERSION: false,
},
rules: {
diff --git a/web/src/blueslip.ts b/web/src/blueslip.ts
index b965ce74d5c..7e407cfb837 100644
--- a/web/src/blueslip.ts
+++ b/web/src/blueslip.ts
@@ -9,7 +9,6 @@
import * as Sentry from "@sentry/browser";
import $ from "jquery";
-import {page_params} from "./base_page_params";
import {BlueslipError, display_stacktrace} from "./blueslip_stacktrace";
if (Error.stackTraceLimit !== undefined) {
@@ -81,7 +80,7 @@ export function info(msg: string, more_info?: unknown): void {
export function warn(msg: string, more_info?: unknown): void {
const args = build_arg_list(msg, more_info);
logger.warn(...args);
- if (page_params.development_environment) {
+ if (DEVELOPMENT) {
console.trace();
}
}
@@ -100,7 +99,7 @@ export function error(msg: string, more_info?: object | undefined, original_erro
logger.error(...args);
// Throw an error in development; this will show a dialog (see below).
- if (page_params.development_environment) {
+ if (DEVELOPMENT) {
throw new BlueslipError(msg, more_info, original_error);
}
// This function returns to its caller in production! To raise a
@@ -109,7 +108,7 @@ export function error(msg: string, more_info?: object | undefined, original_erro
// Install a window-wide onerror handler in development to display the stacktraces, to make them
// hard to miss
-if (page_params.development_environment) {
+if (DEVELOPMENT) {
$(window).on("error", (event: JQuery.TriggeredEvent) => {
const {originalEvent} = event;
if (originalEvent instanceof ErrorEvent && originalEvent.error instanceof Error) {
diff --git a/web/src/global.ts b/web/src/global.ts
index 796d4bf5f17..879df997c93 100644
--- a/web/src/global.ts
+++ b/web/src/global.ts
@@ -51,5 +51,6 @@ declare global {
};
}
+ const DEVELOPMENT: boolean;
const ZULIP_VERSION: string;
}
diff --git a/web/webpack.config.ts b/web/webpack.config.ts
index aa4a58f899c..b72012c822b 100644
--- a/web/webpack.config.ts
+++ b/web/webpack.config.ts
@@ -199,6 +199,7 @@ const config = (
},
plugins: [
new DefinePlugin({
+ DEVELOPMENT: JSON.stringify(!production),
ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"),
}),
new DebugRequirePlugin(),