Browse Source

Merge branch 'master' of https://github.com/BabylonJS/Babylon.js

David Catuhe 7 years ago
parent
commit
a5e8fac548

+ 1 - 1
Tools/Gulp/config.json

@@ -1646,7 +1646,7 @@
                 "output": "babylon.inspector.js",
                 "webpack": "../../inspector/webpack.config.js",
                 "bundle": "true",
-                "moduleDeclaration": "GUI"
+                "moduleDeclaration": "INSPECTOR"
             }
         ],
         "build": {

+ 6 - 5
Tools/Gulp/gulp-addModuleExports.js

@@ -5,7 +5,7 @@ var through = require('through2');
  * The parameters for this function has grown during development.
  * Eventually, this function will need to be reorganized. 
  */
-module.exports = function (varName, subModule, extendsRoot, requireOnly) {
+module.exports = function (varName, subModule, extendsRoot, externalUsingBabylon) {
     return through.obj(function (file, enc, cb) {
 
         var optionalRequire = `var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : this);
@@ -24,15 +24,15 @@ globalObject["${base}"] = f;` : '';
             }*/
 
             return `\n\n(function universalModuleDefinition(root, factory) {
+                var f = factory();
                 if (root && root["${base}"]) {
                     return;
                 }
-                var f = factory();
                 ${sadGlobalPolution}
     if(typeof exports === 'object' && typeof module === 'object')
         module.exports = f;
     else if(typeof define === 'function' && define.amd)
-        define([], factory);
+        define(["${varName}"], factory);
     else if(typeof exports === 'object')
         exports["${varName}"] = f;
     else {
@@ -76,8 +76,9 @@ globalObject["${base}"] = f;` : '';
         }
 
         try {
-            if (requireOnly) {
-                file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
+            if (externalUsingBabylon) {
+                //file.contents = new Buffer(optionalRequire.concat(String(file.contents)));
+                file.contents = new Buffer(optionalRequire.concat(new Buffer(String(file.contents).concat(moduleExportAddition(varName)))));
             } else {
                 let pretext = subModule ? optionalRequire : '';
                 file.contents = new Buffer(pretext.concat(decorateAddition).concat(new Buffer(extendsAddition.concat(String(file.contents)).concat(moduleExportAddition(varName)))));

+ 1 - 1
inspector/webpack.config.js

@@ -4,7 +4,7 @@ module.exports = {
         "../../dist/preview release/inspector/babylon.inspector.min.js"
     ],
     output: {
-        libraryTarget: "umd",
+        libraryTarget: "var",
         library: "INSPECTOR",
         umdNamedDefine: true
     },

+ 4 - 0
src/Debug/babylon.debugLayer.ts

@@ -1,7 +1,9 @@
 module BABYLON {
 
     // declare INSPECTOR namespace for compilation issue
+    declare var require: any;
     declare var INSPECTOR: any;
+    // load the inspector using require, if not present in the global namespace.
 
     export class DebugLayer {
         private _scene: Scene;
@@ -11,6 +13,8 @@ module BABYLON {
 
         constructor(scene: Scene) {
             this._scene = scene;
+            // load inspector using require, if it doesn't exist on the global namespace.
+            INSPECTOR = typeof INSPECTOR !== 'undefined' ? INSPECTOR : (typeof require !== 'undefined' ? require('INSPECTOR') : undefined);
         }
 
         /** Creates the inspector window. */