Skip to content

Commit a3ce3ed

Browse files
committed
build: add size check
1 parent 4a3fde4 commit a3ce3ed

File tree

3 files changed

+66
-53
lines changed

3 files changed

+66
-53
lines changed

packages/router/size-checks/rollup.config.mjs

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -9,59 +9,61 @@ import { defineConfig } from 'rollup'
99

1010
const __dirname = path.dirname(fileURLToPath(import.meta.url))
1111

12-
const config = defineConfig({
13-
external: ['vue'],
14-
output: {
15-
file: path.resolve(__dirname, './dist/webRouter.js'),
16-
format: 'es',
17-
},
18-
input: path.resolve(__dirname, './webRouter.js'),
19-
plugins: [
20-
replace({
21-
preventAssignment: true,
22-
values: {
23-
__DEV__: 'false',
24-
// this is only used during tests
25-
__TEST__: 'false',
26-
// If the build is expected to run directly in the browser (global / esm builds)
27-
__BROWSER__: 'true',
28-
// is targeting bundlers?
29-
__BUNDLER__: 'false',
30-
__GLOBAL__: 'false',
31-
// is targeting Node (SSR)?
32-
__NODE_JS__: 'false',
33-
__VUE_PROD_DEVTOOLS__: 'false',
34-
'process.env.NODE_ENV': JSON.stringify('production'),
35-
},
36-
}),
37-
ts({
38-
check: false,
39-
tsconfig: path.resolve(__dirname, '../tsconfig.json'),
40-
cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
41-
tsconfigOverride: {
42-
compilerOptions: {
43-
sourceMap: false,
44-
declaration: false,
45-
declarationMap: false,
12+
const configs = ['webRouter', 'webRouter_experimental'].map(file => {
13+
return defineConfig({
14+
external: ['vue'],
15+
output: {
16+
file: path.resolve(__dirname, `./dist/${file}.js`),
17+
format: 'es',
18+
},
19+
input: path.resolve(__dirname, `./${file}.js`),
20+
plugins: [
21+
replace({
22+
preventAssignment: true,
23+
values: {
24+
__DEV__: 'false',
25+
// this is only used during tests
26+
__TEST__: 'false',
27+
// If the build is expected to run directly in the browser (global / esm builds)
28+
__BROWSER__: 'true',
29+
// is targeting bundlers?
30+
__BUNDLER__: 'false',
31+
__GLOBAL__: 'false',
32+
// is targeting Node (SSR)?
33+
__NODE_JS__: 'false',
34+
__VUE_PROD_DEVTOOLS__: 'false',
35+
'process.env.NODE_ENV': JSON.stringify('production'),
4636
},
47-
exclude: ['__tests__', 'test-dts'],
48-
},
49-
}),
50-
resolve(),
51-
commonjs(),
52-
terser({
53-
// uncomment to debug output size changes
54-
// mangle: false,
55-
format: {
56-
comments: false,
57-
},
58-
module: true,
59-
compress: {
60-
ecma: 2015,
61-
pure_getters: true,
62-
},
63-
}),
64-
],
37+
}),
38+
ts({
39+
check: false,
40+
tsconfig: path.resolve(__dirname, '../tsconfig.json'),
41+
cacheRoot: path.resolve(__dirname, '../node_modules/.rts2_cache'),
42+
tsconfigOverride: {
43+
compilerOptions: {
44+
sourceMap: false,
45+
declaration: false,
46+
declarationMap: false,
47+
},
48+
exclude: ['__tests__', 'test-dts'],
49+
},
50+
}),
51+
resolve(),
52+
commonjs(),
53+
terser({
54+
// uncomment to debug output size changes
55+
// mangle: false,
56+
format: {
57+
comments: false,
58+
},
59+
module: true,
60+
compress: {
61+
ecma: 2015,
62+
pure_getters: true,
63+
},
64+
}),
65+
],
66+
})
6567
})
6668

67-
export default config
69+
export default configs
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export { createWebHistory } from '../dist/vue-router.mjs'
2+
export {
3+
createFixedResolver,
4+
experimental_createRouter,
5+
normalizeRouteRecord,
6+
MatcherPatternPathStatic,
7+
} from '../dist/experimental/index.mjs'

scripts/check-size.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ async function checkFileSize(filePath) {
4040
__dirname,
4141
'../packages/router/dist/vue-router.global.prod.js'
4242
),
43+
path.resolve(
44+
__dirname,
45+
'../packages/router/size-checks/dist/webRouter_experimental.js'
46+
),
4347
].map(checkFileSize)
4448
)
4549
})()

0 commit comments

Comments
 (0)