Browse Source

Fix Debug presence in Bundle

sebavan 6 years ago
parent
commit
abb9cac062

+ 2 - 1
Tools/Config/config.json

@@ -105,7 +105,8 @@
                             "path": "babylonjs/Debug/skeletonViewer",
                             "namespace": "BABYLON.Debug"
                         }
-                    ]
+                    ],
+                    "hiddenConsts": ["Debug"]
                 },
                 "requiredFiles": [
                     "readme.md"

+ 17 - 0
Tools/Gulp/helpers/gulp-processAmdDeclarationToModule.js

@@ -119,6 +119,23 @@ var processData = function(data, options) {
         str = str.replace(/^\s*$/gm, "");
     }
 
+    // Hide Exported Consts if necessary
+    if (options.hiddenConsts) {
+        for (let toHide of options.hiddenConsts) {
+            var constStart = str.indexOf(`export const ${toHide}`);
+            if (constStart > -1) {
+                for (let i = constStart; i < str.length; i++) {
+                    if (str[i] === "}") {
+                        // +1 to enroll the last }
+                        // +2 to enroll the trailing ;
+                        str = str.substr(0, constStart) + str.substr(i + 2);
+                        break;
+                    }
+                }
+            }
+        }
+    }
+
     // Add Entry point.
     str += `
 declare module "${moduleName}" {

+ 1 - 0
Tools/Gulp/tasks/gulpTasks-libraries.js

@@ -134,6 +134,7 @@ var processDTSFiles = function(libraries, settings, cb) {
             moduleName: commandLineOptions.moduleName || settings.build.umd.packageName,
             entryPoint: library.entry,
             externals: settings.build.umd.processDeclaration.classMap,
+            hiddenConsts: settings.build.umd.processDeclaration.hiddenConsts
         });
 
         // Convert Module to Namespace for globals

+ 10 - 9
src/Legacy/legacy.ts

@@ -1,5 +1,5 @@
 import * as Babylon from "../index";
-import * as Debug from "../Debug/index";
+import * as DebugImort from "../Debug/index";
 
 declare var global: any;
 
@@ -17,18 +17,19 @@ if (typeof globalObject !== "undefined") {
     BABYLON.Debug = BABYLON.Debug || {};
 
     const keys = [];
-    for (var key in Debug) {
-        BABYLON.Debug[key] = (<any>Debug)[key];
+    for (var key in DebugImort) {
+        BABYLON.Debug[key] = (<any>DebugImort)[key];
         keys.push(key);
     }
     for (var key in Babylon) {
-        // Prevent Reassignment.
-        // if (keys.indexOf(key) > -1) {
-        // continue;
-        // }
-
         BABYLON[key] = (<any>Babylon)[key];
     }
 }
 
-export * from "../index";
+export * from "../index";
+export const Debug = {
+    AxesViewer: DebugImort.AxesViewer,
+    BoneAxesViewer: DebugImort.BoneAxesViewer,
+    PhysicsViewer: DebugImort.PhysicsViewer,
+    SkeletonViewer: DebugImort.SkeletonViewer,
+};