From 767ad1d90ec1d371742db75b4e23d4bcc528c2b9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Tue, 28 Jul 2020 19:46:33 -0700 Subject: [PATCH] debug: Remove debug from globals. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is used rarely enough that it’s easier to document how to use it as a non-global than to document the horrifying things that might go wrong as a global. Signed-off-by: Anders Kaseorg --- static/js/debug.js | 13 +++---------- tools/webpack.config.ts | 3 +-- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/static/js/debug.js b/static/js/debug.js index 6b9a75c198..086a94af9a 100644 --- a/static/js/debug.js +++ b/static/js/debug.js @@ -1,15 +1,8 @@ /* eslint-disable no-console */ -/* WARNING: - - This file is only included when Django's DEBUG = True and your - host is in INTERNAL_IPS. - - Do not commit any code elsewhere which uses these functions. - They are for debugging use only. - - The file may still be accessible under other circumstances, so do - not put sensitive information here. */ +// This module is included from webpack in development mode. To access it from +// the browser console, run: +// var debug = require("./static/js/debug"); /* debug.print_elapsed_time("foo", foo) diff --git a/tools/webpack.config.ts b/tools/webpack.config.ts index 58bde4f359..abd1e5ac60 100644 --- a/tools/webpack.config.ts +++ b/tools/webpack.config.ts @@ -244,7 +244,6 @@ export default (env?: string): webpack.Configuration[] => { // Good error messages show up in production and development in the source maps const exposeOptions = [ {path: "./debug-require.js", name: "require"}, - {path: "../static/js/debug.js"}, {path: "jquery/dist/jquery.js", name: ["$", "jQuery"]}, ]; config.module!.rules.unshift(...getExposeLoaders(exposeOptions)); @@ -252,7 +251,7 @@ export default (env?: string): webpack.Configuration[] => { if (!production) { // Out JS debugging tools for (const paths of Object.values(assets)) { - paths.push("./static/js/debug.js"); + paths.push("./static/js/debug"); } config.devServer = { clientLogLevel: "error",