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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,9 @@ Vite 8 / Rolldown specifics baked into `vite.config.ts` (do not "simplify" these
- Externals are regexes (`^dep(\/.+)?$`) so **subpath** imports (`dayjs/locale/de`) stay external; otherwise CJS `require()` glue leaks into the ESM output
- No minification, sourcemaps on, target from `tsconfig.lib.json` (`es2020`), all deps/peerDeps externalized
- Rolldown's strict CJS interop means default-imported CJS deps may need `.default` unwrapping at the call site
- `preserveModules` is on for the **ESM output only**, so `dist/es` mirrors `src` one file per module. Consumer bundlers drop whole unused modules first (guided by our `sideEffects` field) and only then attempt statement-level elimination — a single merged chunk leaves them nothing to drop. CJS stays chunked, since consumers do not tree-shake CJS
- `emptyOutDir` stays `false` because the four parallel build steps share `dist/`; `yarn build` already wipes it up front via `yarn clean`
- **`sideEffects` in `package.json` is load-bearing.** With one ESM file per module, consumer bundlers drop modules individually, so any module that runs code at import time must be listed there or it can be deleted out from under a consumer. Today that is `i18n/Streami18n` and `context/TranslationContext` (both call `Dayjs.extend` / `Dayjs.updateLocale` at module scope). Add an entry whenever you introduce module-level side effects

## Styling architecture

Expand Down
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@
},
"sideEffects": [
"*.css",
"./dist/i18n/Streami18n.js"
"./dist/es/i18n/Streami18n.mjs",
"./dist/es/context/TranslationContext.mjs"
],
"keywords": [
"chat",
Expand Down Expand Up @@ -233,11 +234,6 @@
"built": true
}
},
"browserslist": [
">0.2%",
"not ie <= 11",
"not op_mini all"
],
"packageManager": "yarn@4.15.0",
"workspaces": [
"examples/*"
Expand Down
6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default defineConfig({
'mp3-encoder': resolve(__dirname, './src/plugins/encoders/mp3.ts'),
},
},
// `yarn build` already wipes dist up front via `yarn clean`
emptyOutDir: false,
outDir: 'dist',
minify: false,
Expand All @@ -43,6 +44,11 @@ export default defineConfig({
chunkFileNames: `${dir}/[name].[hash].${extension}`,
entryFileNames: `${dir}/[name].${extension}`,
hashCharacters: 'hex',
// Emit the ESM build as one file per source module. Consumer bundlers
// drop whole modules (guided by our package.json `sideEffects`) before
// they attempt statement-level elimination. The CJS build stays chunked,
// as CJS is not tree-shaken by consumers either way.
preserveModules: format === 'es',
};
}),
},
Expand Down