Explorar o código

Build Core As Lib

sebastien %!s(int64=6) %!d(string=hai) anos
pai
achega
b7986e6af5

+ 31 - 0
Tools/Gulp/config.json

@@ -1495,6 +1495,7 @@
         }
     ],
     "modules": [
+        "core",
         "materialsLibrary",
         "postProcessesLibrary",
         "proceduralTexturesLibrary",
@@ -1507,6 +1508,36 @@
         "viewer",
         "viewer-assets"
     ],
+    "core": {
+        "libraries": [
+            {
+                "output": "babylon.js",
+                "maxOutput": "babylon.max.js",
+                "entry": "../src/Legacy/legacy.ts"
+            }
+        ],
+        "build": {
+            "webpack": "../../src/webpack.config.js",
+            "srcDirectory": "../../src/",
+            "distOutputDirectory": "/",
+            "dtsBundle": {
+                "name": "babylonjs",
+                "main": "../../dist/preview release/build/src/index.d.ts",
+                "out": "../babylon.module.d.ts",
+                "baseDir": "../../dist/preview release/build/",
+                "headerText": "BabylonJS"
+            },
+            "processDeclaration": {
+                "filename": "babylon.module.d.ts",
+                "packageName": "babylonjs",
+                "moduleName": "BABYLON",
+                "importsToRemove": [],
+                "classMap": {
+                    "babylonjs": "BABYLON"
+                }
+            }
+        }
+    },
     "materialsLibrary": {
         "libraries": [
             {

+ 1 - 39
Tools/Gulp/gulpfile.js

@@ -38,7 +38,6 @@ var config = require("./config.json");
 
 var includeShadersStream;
 var shadersStream;
-var workersStream;
 
 var extendsSearchRegex = /var\s__extends[\s\S]+?\}\)\(\);/g;
 var decorateSearchRegex = /var\s__decorate[\s\S]+?\};/g;
@@ -161,43 +160,6 @@ gulp.task("shaders", gulp.series("includeShaders", function(cb) {
     cb();
 }));
 
-gulp.task("workers", function(cb) {
-    workersStream = config.workers.map(function(workerDef) {
-        return gulp.src(workerDef.files).
-            pipe(expect.real({ errorOnFailure: true }, workerDef.files)).
-            pipe(uglify()).
-            pipe(srcToVariable({
-                variableName: workerDef.variable
-            }));
-    });
-    cb();
-});
-
-/**
- * Build tasks to concat minify uflify optimise the BJS js in different flavor (workers...).
- */
-gulp.task("buildWorker", gulp.series(gulp.parallel("workers", "shaders"), function() {
-    var filesToProcess = determineFilesToProcess("files");
-    return merge2(
-        gulp.src(filesToProcess).
-            pipe(expect.real({ errorOnFailure: true }, filesToProcess)),
-        shadersStream,
-        includeShadersStream,
-        workersStream
-    )
-        .pipe(concat(config.build.minWorkerFilename))
-        .pipe(cleants())
-        .pipe(replace(extendsSearchRegex, ""))
-        .pipe(replace(decorateSearchRegex, ""))
-        .pipe(addDecorateAndExtends())
-        .pipe(addModuleExports("BABYLON", {
-            dependencies: config.build.dependencies
-        }))
-        .pipe(uglify())
-        .pipe(optimisejs())
-        .pipe(gulp.dest(config.build.outputDirectory));
-}));
-
 gulp.task("build", gulp.series("shaders", function build() {
     var filesToProcess = determineFilesToProcess("files");
     var directFilesToProcess = determineFilesToProcess("directFiles");
@@ -275,7 +237,7 @@ gulp.task("typescript-compile", function() {
 /**
  * Build the releasable files.
  */
-gulp.task("typescript", gulp.series("typescript-compile", "buildWorker", "build"));
+gulp.task("typescript", gulp.series("typescript-compile", "build"));
 
 /**
  * Build all libs.

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

@@ -45,7 +45,8 @@ var buildExternalLibrary = function(library, settings, cb) {
 
     // Generate unminified file.
     wpConfig.mode = "development";
-    wpConfig.output.filename = wpConfig.output.filename.replace(".min", "");
+    // Allow babylon.max.js and babylon.js
+    wpConfig.output.filename = library.maxOutput || wpConfig.output.filename.replace(".min", "");
     let wpBuildMax = webpackStream(wpConfig, webpack);
     let buildEventMax = wpBuildMax.pipe(gulp.dest(outputDirectory));
     sequence.push(buildEventMax);

+ 14 - 0
src/Legacy/legacy.ts

@@ -0,0 +1,14 @@
+import * as BABYLON from "../index";
+
+/**
+ * Legacy support, defining window.BABYLON (global variable).
+ *
+ * This is the entry point for the UMD module.
+ * The entry point for a future ESM package should be index.ts
+ */
+var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
+if (typeof globalObject !== "undefined") {
+    (<any>globalObject).BABYLON = BABYLON;
+}
+
+export * from "../index";

+ 24 - 20
src/tsconfig.json

@@ -1,24 +1,28 @@
 {
-  "compileOnSave": true,
   "compilerOptions": {
-    "noResolve": true,
-    "target": "es5",
-    "declaration": true,
-    "experimentalDecorators": true,
-    "isolatedModules": false,
-    "sourceMap": true,
-    "types": [],
-    "noImplicitAny": true,
-    "noImplicitReturns": true,
-    "noImplicitThis": true,
-    "noUnusedLocals": true,
-    "strictNullChecks": true,
-    "strictFunctionTypes": true,
-    "skipLibCheck": true,
-    "lib": [
-        "dom",
-        "es2015.promise",
-        "es5"
-    ]
+      "experimentalDecorators": true,
+      "module": "commonjs",
+      "target": "es5",
+      "moduleResolution": "node",
+      "noImplicitAny": true,
+      "noImplicitReturns": true,
+      "noImplicitThis": true,
+      "noUnusedLocals": true,
+      "strictNullChecks": true,
+      "strictFunctionTypes": true,
+      "declaration": true,
+      "sourceMap": true,
+      "lib": [
+          "es5",
+          "dom",
+          "es2015.promise",
+          "es2015.collection",
+          "es2015.iterable"
+      ],
+      "skipDefaultLibCheck": true,
+      "skipLibCheck": true,
+      "baseUrl": "./",
+      "rootDir": "./",
+      "outDir": "./build"
   }
 }