Browse Source

correctly handling export=

Raanan Weber 8 years ago
parent
commit
9d7890a4cf
2 changed files with 8 additions and 3 deletions
  1. 7 2
      Tools/Gulp/gulp-addDtsExport.js
  2. 1 1
      Tools/Gulp/gulpfile.js

+ 7 - 2
Tools/Gulp/gulp-addDtsExport.js

@@ -1,14 +1,19 @@
 var gutil = require('gulp-util');
 var through = require('through2');
 
-module.exports = function (varName, moduleName, subModule) {
+module.exports = function (varName, moduleName, subModule, extendsRoot) {
     return through.obj(function (file, enc, cb) {
 
+        let exportText = "BABYLON";
+        if (subModule && !extendsRoot) {
+            exportText += '.' + varName;
+        }
+
         var moduleExportsAddition =
             `/// <reference types="babylonjs"/>
 
 declare module '${moduleName}' { 
-    export = ${(subModule ? 'BABYLON.' : '')}${varName}; 
+    export = ${exportText}; 
 }
 `;
 

+ 1 - 1
Tools/Gulp/gulpfile.js

@@ -336,7 +336,7 @@ var buildExternalLibrary = function (library, settings, watch) {
         if (library.buildAsModule) {
             var dts2 = tsProcess.dts
                 .pipe(concat(library.output))
-                .pipe(addDtsExport(library.moduleDeclaration, library.moduleName, true))
+                .pipe(addDtsExport(library.moduleDeclaration, library.moduleName, true, library.extendsRoot))
                 .pipe(rename({ extname: ".module.d.ts" }))
                 .pipe(gulp.dest(outputDirectory));
             waitAll = merge2([dev, code, css, dts, dts2]);