Sfoglia il codice sorgente

fix: optimize chunk splitting

* group Vue and all UI stuff in one chunk
* don't load it in background script
* remove polyfills for unused NodeJS features
tophf 4 anni fa
parent
commit
42d123debc
2 ha cambiato i file con 16 aggiunte e 2 eliminazioni
  1. 12 2
      scripts/plaid.conf.js
  2. 4 0
      scripts/webpack.conf.js

+ 12 - 2
scripts/plaid.conf.js

@@ -36,7 +36,7 @@ const minimizerOptions = {
 
 const splitVendor = prefix => ({
   [prefix]: {
-    test: new RegExp(`node_modules[/\\\\]${prefix}.*?\\.js`),
+    test: new RegExp(`node_modules[/\\\\]${prefix}`),
     name: `public/lib/${prefix}`,
     chunks: 'all',
     priority: 100,
@@ -49,6 +49,17 @@ exports.optimization = {
   runtimeChunk: false,
   splitChunks: {
     cacheGroups: {
+      'common-ui': {
+        name: 'common-ui',
+        test: new RegExp([
+          /\bsvg/,
+          /src\/common\/(ui|keyboard|load-script-icon)/,
+          'node_modules/@violentmonkey/shortcut',
+          'node_modules/vue',
+        ].map(re => re.source || re).join('|')),
+        chunks: 'all',
+        minChunks: 2,
+      },
       common: {
         name: 'common',
         minChunks: 2,
@@ -57,7 +68,6 @@ exports.optimization = {
       },
       ...splitVendor('codemirror'),
       ...splitVendor('tldjs'),
-      ...splitVendor('vue'),
     },
   },
   minimizer: isProd && [

+ 4 - 0
scripts/webpack.conf.js

@@ -34,6 +34,10 @@ const definitions = new webpack.DefinePlugin({
 
 const modify = (page, entry, init) => modifyWebpackConfig(
   (config) => {
+    config.node = {
+      process: false,
+      setImmediate: false,
+    };
     config.plugins.push(definitions);
     if (!entry) init = page;
     if (init) init(config);