]> git.ipfire.org Git - thirdparty/vuejs/router.git/commitdiff
build: add size check
authorEduardo San Martin Morote <posva13@gmail.com>
Sun, 24 Aug 2025 15:41:13 +0000 (17:41 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Sun, 24 Aug 2025 15:41:13 +0000 (17:41 +0200)
packages/router/size-checks/rollup.config.mjs
packages/router/size-checks/webRouter_experimental.js [new file with mode: 0644]
scripts/check-size.mjs

index e0ec8a14f0572e827f8ff8e8669b9aebe7e51c50..98cc8411a247b705840be2a494ecd807cd84d033 100644 (file)
@@ -9,59 +9,61 @@ import { defineConfig } from 'rollup'
 
 const __dirname = path.dirname(fileURLToPath(import.meta.url))
 
-const config = defineConfig({
-  external: ['vue'],
-  output: {
-    file: path.resolve(__dirname, './dist/webRouter.js'),
-    format: 'es',
-  },
-  input: path.resolve(__dirname, './webRouter.js'),
-  plugins: [
-    replace({
-      preventAssignment: true,
-      values: {
-        __DEV__: 'false',
-        // this is only used during tests
-        __TEST__: 'false',
-        // If the build is expected to run directly in the browser (global / esm builds)
-        __BROWSER__: 'true',
-        // is targeting bundlers?
-        __BUNDLER__: 'false',
-        __GLOBAL__: 'false',
-        // is targeting Node (SSR)?
-        __NODE_JS__: 'false',
-        __VUE_PROD_DEVTOOLS__: 'false',
-        'process.env.NODE_ENV': JSON.stringify('production'),
-      },
-    }),
-    ts({
-      check: false,
-      tsconfig: path.resolve(__dirname, '../tsconfig.json'),
-      cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
-      tsconfigOverride: {
-        compilerOptions: {
-          sourceMap: false,
-          declaration: false,
-          declarationMap: false,
+const configs = ['webRouter', 'webRouter_experimental'].map(file => {
+  return defineConfig({
+    external: ['vue'],
+    output: {
+      file: path.resolve(__dirname, `./dist/${file}.js`),
+      format: 'es',
+    },
+    input: path.resolve(__dirname, `./${file}.js`),
+    plugins: [
+      replace({
+        preventAssignment: true,
+        values: {
+          __DEV__: 'false',
+          // this is only used during tests
+          __TEST__: 'false',
+          // If the build is expected to run directly in the browser (global / esm builds)
+          __BROWSER__: 'true',
+          // is targeting bundlers?
+          __BUNDLER__: 'false',
+          __GLOBAL__: 'false',
+          // is targeting Node (SSR)?
+          __NODE_JS__: 'false',
+          __VUE_PROD_DEVTOOLS__: 'false',
+          'process.env.NODE_ENV': JSON.stringify('production'),
         },
-        exclude: ['__tests__', 'test-dts'],
-      },
-    }),
-    resolve(),
-    commonjs(),
-    terser({
-      // uncomment to debug output size changes
-      // mangle: false,
-      format: {
-        comments: false,
-      },
-      module: true,
-      compress: {
-        ecma: 2015,
-        pure_getters: true,
-      },
-    }),
-  ],
+      }),
+      ts({
+        check: false,
+        tsconfig: path.resolve(__dirname, '../tsconfig.json'),
+        cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
+        tsconfigOverride: {
+          compilerOptions: {
+            sourceMap: false,
+            declaration: false,
+            declarationMap: false,
+          },
+          exclude: ['__tests__', 'test-dts'],
+        },
+      }),
+      resolve(),
+      commonjs(),
+      terser({
+        // uncomment to debug output size changes
+        // mangle: false,
+        format: {
+          comments: false,
+        },
+        module: true,
+        compress: {
+          ecma: 2015,
+          pure_getters: true,
+        },
+      }),
+    ],
+  })
 })
 
-export default config
+export default configs
diff --git a/packages/router/size-checks/webRouter_experimental.js b/packages/router/size-checks/webRouter_experimental.js
new file mode 100644 (file)
index 0000000..97fbf59
--- /dev/null
@@ -0,0 +1,7 @@
+export { createWebHistory } from '../dist/vue-router.mjs'
+export {
+  createFixedResolver,
+  experimental_createRouter,
+  normalizeRouteRecord,
+  MatcherPatternPathStatic,
+} from '../dist/experimental/index.mjs'
index e681b5558f2ab114c4d86e5a7b280cb2e3d272b1..6f6ed7bd12e508e4456ccbfab7c058cd92347fff 100644 (file)
@@ -40,6 +40,10 @@ async function checkFileSize(filePath) {
         __dirname,
         '../packages/router/dist/vue-router.global.prod.js'
       ),
+      path.resolve(
+        __dirname,
+        '../packages/router/size-checks/dist/webRouter_experimental.js'
+      ),
     ].map(checkFileSize)
   )
 })()