fix(01-08): resolve ebml via CJS main entry to bypass Vite/Rollup tree-shake bug
Vite's @rollup/plugin-commonjs failed to bridge ts-ebml's
`require("ebml")` against ebml's mixed-main/module/browser package.
Rollup tree-shook ebml.esm.js entirely, leaving `var Pc={}` as a
dangling placeholder. ts-ebml/tools.js's destructure
`{tools:f}=Pc` threw TypeError at SW top-level module init,
blocking handler registration -> chrome://serviceworker-internals
Status=STARTING forever.
`resolve.alias: { ebml: 'ebml/lib/ebml.js' }` forces resolution to
the CJS main entry whose assignment-style exports survive
plugin-commonjs's namespace allocation. Empirically verified:
bundle init progresses ~340 KB further; readVint error gone.
Probes C1 (resolve.mainFields), C2 (treeshake.moduleSideEffects),
C3 (C1+C2 combined), C4 (commonjsOptions.strictRequires) were
all falsified before C-config landed.
Resolves: .planning/debug/01-08-sw-incompatibility.md
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -11,6 +11,11 @@ export default defineConfig({
|
||||
},
|
||||
}),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
ebml: 'ebml/lib/ebml.js',
|
||||
},
|
||||
},
|
||||
build: {
|
||||
rollupOptions: {
|
||||
input: {
|
||||
|
||||
Reference in New Issue
Block a user