Skip to content

Commit 3d788f1

Browse files
committed
build size analysis tool
1 parent b8ea84f commit 3d788f1

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

repo-scripts/size-analysis/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"test": "run-p lint test:node",
1414
"test:ci": "node ../../scripts/run_tests_in_ci.js -s test:node",
1515
"pretest:node": "tsc -p test/test-inputs && rollup -c",
16-
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha **/*.test.ts --config ../../config/mocharc.node.js --timeout 60000"
16+
"test:node": "TS_NODE_COMPILER_OPTIONS='{\"module\":\"commonjs\"}' nyc --reporter lcovonly -- mocha **/*.test.ts --config ../../config/mocharc.node.js --timeout 60000",
17+
"build": "rollup -c"
1718
},
1819
"dependencies": {
1920
"rollup": "2.35.1",

repo-scripts/size-analysis/rollup.config.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ const deps = Object.keys(
2424
Object.assign({}, pkg.peerDependencies, pkg.dependencies)
2525
);
2626

27+
const nodeInternals = ['fs', 'path'];
28+
2729
export default [
2830
{
2931
input: 'test/test-inputs/subsetExports.ts',
@@ -49,5 +51,33 @@ export default [
4951
})
5052
],
5153
external: id => deps.some(dep => id === dep || id.startsWith(`${dep}/`))
54+
},
55+
{
56+
input: 'cli.ts',
57+
output: [
58+
{
59+
file: 'dist/cli.js',
60+
format: 'cjs',
61+
sourcemap: false
62+
}
63+
],
64+
plugins: [
65+
typescriptPlugin({
66+
typescript,
67+
tsconfigOverride: {
68+
compilerOptions: {
69+
target: 'es2017',
70+
module: 'es2015'
71+
}
72+
}
73+
}),
74+
json({
75+
preferConst: true
76+
})
77+
],
78+
external: id =>
79+
[...deps, ...nodeInternals].some(
80+
dep => id === dep || id.startsWith(`${dep}/`)
81+
)
5282
}
5383
];

0 commit comments

Comments
 (0)