From 9973a067c90d461460761c8f7c72c582752f4223 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Wed, 10 Apr 2019 15:38:06 -0700
Subject: [PATCH] debug mode tweaks

---
 README.md                 | 14 ++------------
 src/mol-plugin/context.ts |  3 +++
 src/mol-util/debug.ts     |  4 ++--
 webpack.config.js         |  2 ++
 4 files changed, 9 insertions(+), 14 deletions(-)

diff --git a/README.md b/README.md
index a03c9462e..839436bb0 100644
--- a/README.md
+++ b/README.md
@@ -55,19 +55,9 @@ This project builds on experience from previous solutions:
 
 ### Build automatically on file save:
     npm run watch
-    npm run watch-extra
 
-### Build/watch mol-viewer
-**Build**
-
-    npm run build
-    npm run build-viewer
-
-**Watch**
-
-    npm run watch
-    npm run watch-extra
-    npm run watch-viewer
+### With debug mode enabled:
+    DEBUG=molstar npm run watch
 
 **Run**
 
diff --git a/src/mol-plugin/context.ts b/src/mol-plugin/context.ts
index 8826344ea..245dcaad2 100644
--- a/src/mol-plugin/context.ts
+++ b/src/mol-plugin/context.ts
@@ -34,6 +34,7 @@ import { StructureElementSelectionManager } from './util/structure-element-selec
 import { SubstructureParentHelper } from './util/substructure-parent-helper';
 import { Representation } from 'mol-repr/representation';
 import { ModifiersKeys } from 'mol-util/input/input-observer';
+import { isProductionMode, isDebugMode } from 'mol-util/debug';
 
 export class PluginContext {
     private disposed = false;
@@ -225,5 +226,7 @@ export class PluginContext {
         this.lociLabels = new LociLabelManager(this);
 
         this.log.message(`Mol* Plugin ${PLUGIN_VERSION} [${PLUGIN_VERSION_DATE.toLocaleString()}]`);
+        if (!isProductionMode) this.log.message(`Development mode enabled`);
+        if (isDebugMode) this.log.message(`Debug mode enabled`);
     }
 }
\ No newline at end of file
diff --git a/src/mol-util/debug.ts b/src/mol-util/debug.ts
index 3f9334cd8..5dc93664a 100644
--- a/src/mol-util/debug.ts
+++ b/src/mol-util/debug.ts
@@ -12,8 +12,8 @@ const isProductionMode = process.env.NODE_ENV === 'production'
 
 /**
  * set to true to enable more comprehensive checks and assertions,
- * moslty used in `mol-gl`
+ * mostly used in `mol-gl`
  */
-const isDebugMode = false
+const isDebugMode = process.env.DEBUG === '*' || process.env.DEBUG === 'molstar'
 
 export { isProductionMode, isDebugMode }
\ No newline at end of file
diff --git a/webpack.config.js b/webpack.config.js
index f3cf06a29..90c91d820 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -49,6 +49,8 @@ const sharedConfig = {
         }),
         new webpack.DefinePlugin({
             __PLUGIN_VERSION_TIMESTAMP__: webpack.DefinePlugin.runtimeValue(() => `${new Date().valueOf()}`, true),
+            'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
+            'process.env.DEBUG': JSON.stringify(process.env.DEBUG)
         }),
         new MiniCssExtractPlugin({ filename: 'app.css' })
     ],
-- 
GitLab