Ver código fonte

Decouple preview bundle (#1013)

* Decouple preview bundle

* per Fred
Dinh Long Nguyen 1 ano atrás
pai
commit
dd19116388

+ 6 - 0
frontend/taipy-gui/base/src/index-preview.ts

@@ -0,0 +1,6 @@
+import { TaipyApp, createApp, OnChangeHandler, OnInitHandler } from "./app";
+import { ModuleData } from "./dataManager";
+
+export default TaipyApp;
+export { TaipyApp, createApp };
+export type { OnChangeHandler, OnInitHandler, ModuleData };

+ 16 - 7
frontend/taipy-gui/base/webpack.config.js

@@ -8,9 +8,18 @@ const webAppPath = resolveApp(basePath);
 
 
 module.exports = {
 module.exports = {
     target: "web",
     target: "web",
-    entry: "./base/src/index.ts",
+    entry: {
+        "default": "./base/src/index.ts",
+        "preview": "./base/src/index-preview.ts",
+    },
     output: {
     output: {
-        filename: "taipy-gui-base.js",
+        filename: (arg) => {
+            if (arg.chunk.name === "default") {
+                return "taipy-gui-base.js";
+            }
+            return "[name].taipy-gui-base.js";
+        },
+        chunkFilename: "[name].taipy-gui-base.js",
         path: webAppPath,
         path: webAppPath,
         globalObject: "this",
         globalObject: "this",
         library: {
         library: {
@@ -18,11 +27,11 @@ module.exports = {
             type: "umd",
             type: "umd",
         },
         },
     },
     },
-    plugins: [
-        new webpack.optimize.LimitChunkCountPlugin({
-            maxChunks: 1,
-        }),
-    ],
+    optimization: {
+        splitChunks: {
+            chunks: 'all',
+        },
+    },
     module: {
     module: {
         rules: [
         rules: [
             {
             {

+ 17 - 7
frontend/taipy-gui/webpack.config.js

@@ -171,9 +171,19 @@ module.exports = (env, options) => {
     },
     },
     {
     {
         mode: options.mode,
         mode: options.mode,
-        entry: ["./base/src/index.ts"],
+        target: "web",
+        entry: {
+            "default": "./base/src/index.ts",
+            "preview": "./base/src/index-preview.ts",
+        },
         output: {
         output: {
-            filename: "taipy-gui-base.js",
+            filename: (arg) => {
+                if (arg.chunk.name === "default") {
+                    return "taipy-gui-base.js";
+                }
+                return "[name].taipy-gui-base.js";
+            },
+            chunkFilename: "[name].taipy-gui-base.js",
             path: webAppPath,
             path: webAppPath,
             globalObject: "this",
             globalObject: "this",
             library: {
             library: {
@@ -181,11 +191,11 @@ module.exports = (env, options) => {
                 type: "umd",
                 type: "umd",
             },
             },
         },
         },
-        plugins: [
-            new webpack.optimize.LimitChunkCountPlugin({
-                maxChunks: 1,
-            }),
-        ],
+        optimization: {
+            splitChunks: {
+                chunks: 'all',
+            },
+        },
         module: {
         module: {
             rules: [
             rules: [
                 {
                 {