Procházet zdrojové kódy

Update to typescript 3.2.2 + fix UMD module typings

sebavan před 6 roky
rodič
revize
231dc1074f

+ 4 - 1
Tools/Config/config.js

@@ -21,6 +21,8 @@ const tempTypingsFileName = tempTypingsAMDFileName.replace(".js", ".d.ts");
 const tempTypingsAMDFilePath = path.join(tempFolder, tempTypingsAMDFileName);
 const tempTypingsFilePath = path.join(tempFolder, tempTypingsFileName);
 
+const tscPath = path.resolve(rootFolder, "node_modules/typescript/bin/tsc");
+
 config.computed = {
     rootFolder,
     tempFolder,
@@ -36,7 +38,8 @@ config.computed = {
     tempTypingsAMDFileName,
     tempTypingsFileName,
     tempTypingsAMDFilePath,
-    tempTypingsFilePath
+    tempTypingsFilePath,
+    tscPath
 }
 
 config.additionalNpmPackages.forEach(package => {

+ 3 - 5
Tools/Config/config.json

@@ -102,19 +102,17 @@
                             "path": "babylonjs/Debug/skeletonViewer",
                             "namespace": "BABYLON.Debug"
                         }
-                    ],
-                    "doNotAppendNamespace": true,
-                    "prependToNamespaceText": "declare module 'babylonjs' { export = BABYLON; }"
+                    ]
                 },
                 "packagesFiles": [
-                    "babylon.d.ts",
+                    "babylon.module.d.ts",
                     "babylon.js",
                     "babylon.max.js",
                     "babylon.max.js.map",
                     "Oimo.js",
                     "readme.md"
                 ],
-                "typings": "babylon.d.ts",
+                "typings": "babylon.module.d.ts",
                 "index": "babylon.js",
                 "dependencies": [],
                 "devDependencies": []

+ 3 - 2
Tools/Gulp/tasks/gulpTasks-libraries.js

@@ -17,7 +17,8 @@ var del = require("del");
 // Parse Command Line.
 var commandLineOptions = minimist(process.argv.slice(2), {
     boolean: ["noNamespace"],
-    string: ["moduleName"]
+    string: ["moduleName"],
+    string: ["tscPath"]
 });
 
 // Import Build Config
@@ -95,7 +96,7 @@ var buildAMDDTSFiles = function(libraries, settings, cb) {
     let library = libraries[0];
     if (!library.preventLoadLibrary) {
         // Generate DTS the old way...
-        cp.execSync(`tsc --module amd --outFile "${config.computed.tempTypingsAMDFilePath}" --emitDeclarationOnly true`, {
+        cp.execSync(`node "${commandLineOptions.tscPath || config.computed.tscPath}" --module amd --outFile "${config.computed.tempTypingsAMDFilePath}" --emitDeclarationOnly true`, {
             cwd: settings.computed.srcDirectory
         });
     }

+ 3 - 2
Tools/Gulp/tasks/gulpTasks-librariesES6.js

@@ -187,7 +187,7 @@ var build = function(settings, cb) {
         verbose: true
     };
 
-    let command = `tsc --inlineSources --sourceMap true -t es5 -m esNext --outDir "${settings.computed.distES6Directory}"`;
+    let command = `node "${config.computed.tscPath}" --skipLibCheck false --inlineSources --sourceMap true -t es5 -m esNext --outDir "${settings.computed.distES6Directory}"`;
     shelljs.exec(command, options, function(code, stdout, stderr) {
         if (stderr) {
             console.log(stderr);
@@ -216,7 +216,8 @@ var buildWebpack = function(settings, module, cb) {
         verbose: true
     };
 
-    let command = `gulp ${module} --noNamespace --moduleName ${settings.build.es6.packageName}`;
+    let command = `gulp ${module} --noNamespace --moduleName ${settings.build.es6.packageName} --tscPath "${config.computed.tscPath}"`;
+    console.log(command)
     shelljs.exec(command, options, function(code, stdout, stderr) {
         if (stderr) {
             console.log(stderr);

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-viewerLibraries.js

@@ -68,7 +68,7 @@ var buildViewerLibrary = function(library, settings) {
             if (dest.addBabylonDeclaration) {
                 // include the babylon declaration
                 if (dest.addBabylonDeclaration === true) {
-                    dest.addBabylonDeclaration = ["babylon.d.ts"];
+                    dest.addBabylonDeclaration = ["babylon.module.d.ts"];
                 }
                 var decsToAdd = dest.addBabylonDeclaration.map(function(dec) {
                     return config.build.outputDirectory + '/' + dec;

+ 1 - 1
Tools/Gulp/tasks/gulpTasks-watchCore.js

@@ -54,7 +54,7 @@ gulp.task("watchCore", gulp.series("watchCore-buildShaders", function watch() {
         async: true,
         verbose: true
     };
-    shelljs.exec(`tsc --importHelpers false --isolatedModules true --declaration false --target es5 --module es2015 --outDir "${outputDirectory}" -w`, options, function(code, stdout, stderr) {
+    shelljs.exec(`node "${config.computed.tscPath}" --importHelpers false --isolatedModules true --declaration false --target es5 --module es2015 --outDir "${outputDirectory}" -w`, options, function(code, stdout, stderr) {
         if (stderr) {
             console.log(stderr);
         }

+ 1 - 1
Viewer/tests/unit/tsconfig.json

@@ -23,7 +23,7 @@
         "rootDir": "../../",
         "paths": {
             "babylonjs": [
-                "../../../../dist/preview release/babylon.d.ts"
+                "../../../../dist/preview release/babylon.module.d.ts"
             ],
             "babylonjs-loaders": [
                 "../../../../dist/preview release/loaders/babylonjs.loaders.module.d.ts"

+ 2 - 2
dist/preview release/package.json

@@ -16,14 +16,14 @@
     },
     "main": "babylon.js",
     "files": [
-        "babylon.d.ts",
+        "babylon.module.d.ts",
         "babylon.js",
         "babylon.max.js",
         "babylon.max.js.map",
         "Oimo.js",
         "readme.md"
     ],
-    "typings": "babylon.d.ts",
+    "typings": "babylon.module.d.ts",
     "keywords": [
         "3D",
         "javascript",

+ 2 - 2
package.json

@@ -99,10 +99,10 @@
         "tslib": "^1.9.3",
         "tslint": "^5.11.0",
         "typedoc": "^0.12.0",
-        "typescript": "~3.0.1",
+        "typescript": "^3.2.2",
         "webpack": "^4.25.1",
         "webpack-cli": "^3.1.2",
         "webpack-dev-server": "^3.1.14",
         "webpack-stream": "5.0.0"
     }
-}
+}

+ 1 - 1
tests/modules/typescript-vanilla/src/tests-loader.ts

@@ -1,4 +1,4 @@
-/// <reference path="../../../../dist/preview release/babylon.d.ts"/>
+/// <reference path="../../../../dist/preview release/babylon.module.d.ts"/>
 /// <reference path="../../../../dist/preview release/gui/babylon.gui.d.ts"/>
 /// <reference path="../../../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"/>
 /// <reference path="../../../../dist/preview release/loaders/babylonjs.loaders.d.ts"/>

+ 1 - 1
tests/modules/typescript-webpack/tsconfig.json

@@ -19,7 +19,7 @@
         "baseUrl": "./",
         "paths": {
             "babylonjs": [
-                "../../../dist/preview release/babylon.d.ts"
+                "../../../dist/preview release/babylon.module.d.ts"
             ],
             "babylonjs-gui": [
                 "../../../dist/preview release/gui/babylon.gui.module.d.ts"

+ 1 - 1
tests/unit/babylon/babylonReference.ts

@@ -1,4 +1,4 @@
-/// <reference path="../../../dist/preview release/babylon.d.ts" />
+/// <reference path="../../../dist/preview release/babylon.module.d.ts" />
 /// <reference path="../../../dist/preview release/loaders/babylonjs.loaders.d.ts" />
 /// <reference path="../../../dist/preview release/glTF2Interface/babylon.glTF2Interface.d.ts"/>
 /// <reference path="../../../dist/preview release/serializers/babylonjs.serializers.d.ts" />