Skip to content

Commit fc7d896

Browse files
kuhesmilkuri
authored andcommitted
test(bundlers): update test to report minified filesizes (#7300)
1 parent 706835b commit fc7d896

File tree

6 files changed

+59
-4
lines changed

6 files changed

+59
-4
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ package-lock.json
3434

3535
!serviceModels/logs
3636
dist
37+
tests/bundlers/dist-min
3738

3839
.idea/
3940
*.iml
@@ -53,7 +54,6 @@ workspace
5354
.turbo
5455
turbo.dev.json
5556
coverage
56-
dist
5757
dist-*
5858

5959
/verdaccio/*

tests/bundlers/Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,24 @@
22

33
# asserts that bundles contain expected content.
44
test:
5-
node test.spec.mjs
5+
node bundlers.spec.mjs
6+
du -sh ./dist-min/*
67

78
# create bundles
89
build:
10+
rm -rf ./dist/*
11+
rm -rf ./dist-min/*
912
make vite webpack esbuild
1013

14+
# note: vite deletes files in the build folders and must run first.
1115
vite:
12-
npx vite build
16+
npx vite build --config vite.config.ts
17+
npx vite build --config vite.min.config.ts
1318

1419
webpack:
1520
npx webpack
21+
npx webpack -c webpack.min.config.js
1622

1723
esbuild:
18-
npx esbuild ./source.ts --bundle --outfile=./dist/esbuild-dist.js --format=esm --tree-shaking=true
24+
npx esbuild ./source.ts --bundle --outfile=./dist/esbuild-dist.js --format=esm --tree-shaking=true
25+
npx esbuild ./source.ts --bundle --outfile=./dist-min/esbuild-dist.min.js --format=esm --tree-shaking=true --minify
File renamed without changes.

tests/bundlers/vite.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as path from "node:path";
33

44
export default defineConfig({
55
build: {
6+
outDir: "./dist",
67
lib: {
78
entry: path.join(__dirname, "source.ts"),
89
name: "dist",

tests/bundlers/vite.min.config.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig } from "vite";
2+
import * as path from "node:path";
3+
4+
export default defineConfig({
5+
build: {
6+
outDir: "./dist-min",
7+
lib: {
8+
entry: path.join(__dirname, "source.ts"),
9+
name: "dist-min",
10+
// the proper extensions will be added
11+
fileName: "vite-dist.min",
12+
},
13+
rollupOptions: {
14+
// make sure to externalize deps that shouldn't be bundled
15+
// into your library
16+
external: [],
17+
output: {
18+
// Provide global variables to use in the UMD build
19+
// for externalized deps
20+
globals: {},
21+
// to get an easier aggregate accounting of bundle contents
22+
inlineDynamicImports: true,
23+
},
24+
},
25+
minify: true,
26+
terserOptions: {
27+
mangle: true,
28+
},
29+
},
30+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import path from "node:path";
2+
import { fileURLToPath } from "node:url";
3+
4+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
5+
6+
export default {
7+
mode: "production",
8+
entry: "./source.ts",
9+
target: "web",
10+
output: {
11+
path: path.resolve(__dirname, "dist-min"),
12+
filename: "webpack-dist.min.js",
13+
library: "dist",
14+
},
15+
optimization: {},
16+
stats: {},
17+
};

0 commit comments

Comments
 (0)