Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ package-lock.json

!serviceModels/logs
dist
tests/bundlers/dist-min

.idea/
*.iml
Expand All @@ -53,7 +54,6 @@ workspace
.turbo
turbo.dev.json
coverage
dist
dist-*

/verdaccio/*
Expand Down
13 changes: 10 additions & 3 deletions tests/bundlers/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@

# asserts that bundles contain expected content.
test:
node test.spec.mjs
node bundlers.spec.mjs
du -sh ./dist-min/*

# create bundles
build:
rm -rf ./dist/*
rm -rf ./dist-min/*
make vite webpack esbuild

# note: vite deletes files in the build folders and must run first.
vite:
npx vite build
npx vite build --config vite.config.ts
npx vite build --config vite.min.config.ts

webpack:
npx webpack
npx webpack -c webpack.min.config.js

esbuild:
npx esbuild ./source.ts --bundle --outfile=./dist/esbuild-dist.js --format=esm --tree-shaking=true
npx esbuild ./source.ts --bundle --outfile=./dist/esbuild-dist.js --format=esm --tree-shaking=true
npx esbuild ./source.ts --bundle --outfile=./dist-min/esbuild-dist.min.js --format=esm --tree-shaking=true --minify
File renamed without changes.
1 change: 1 addition & 0 deletions tests/bundlers/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as path from "node:path";

export default defineConfig({
build: {
outDir: "./dist",
lib: {
entry: path.join(__dirname, "source.ts"),
name: "dist",
Expand Down
30 changes: 30 additions & 0 deletions tests/bundlers/vite.min.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { defineConfig } from "vite";
import * as path from "node:path";

export default defineConfig({
build: {
outDir: "./dist-min",
lib: {
entry: path.join(__dirname, "source.ts"),
name: "dist-min",
// the proper extensions will be added
fileName: "vite-dist.min",
},
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: [],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {},
// to get an easier aggregate accounting of bundle contents
inlineDynamicImports: true,
},
},
minify: true,
terserOptions: {
mangle: true,
},
},
});
17 changes: 17 additions & 0 deletions tests/bundlers/webpack.min.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import path from "node:path";
import { fileURLToPath } from "node:url";

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

export default {
mode: "production",
entry: "./source.ts",
target: "web",
output: {
path: path.resolve(__dirname, "dist-min"),
filename: "webpack-dist.min.js",
library: "dist",
},
optimization: {},
stats: {},
};
Loading