no bundler can emit multiple format with shared chunks at the same time.
For example:
a.ts-><script href=a.js>
b.mts->import ā¦ from "./b.js"
both a.js (via import("ā¦")[^1]) and b.js (via import ā¦ from "ā¦") import same chunk-<hash>.js.
esbuild
--splitting Emit too many chunks.
Also, it give me one empty chunk.
rollup+sucrase+esbuild
Unlike esbuild, output dir doesn't retain folder structure of input entries.
Can't code split on build.write({ format:"iife" }). [^1]
Can't inline const enum. Sometimes it doesn't inline const variable too. [^2]
[^1]: Dynamic import() on non-module <script> is supported in all latest browser but without top-level await.
[^2]: The current setup emit constant/colon.ts as a chunk but other constant/*.ts got inlined. The current workaround is to not import it directly but re-export it on different module (i.e export * as ColonFor from "./constant/colon.ts" in registry.ts) with a caveat that it's not tree-shaken and wrapped inside Object.freeze.
List of JS bundler specific issues
<script href=a.js>
import ā¦ from "./b.js"
a.js
(viaimport("ā¦")
[^1]) andb.js
(viaimport ā¦ from "ā¦"
) import samechunk-<hash>.js
.esbuild
--splitting
Emit too many chunks.rollup+sucrase+esbuild
build.write({ format:"iife" })
. [^1]const enum
. Sometimes it doesn't inlineconst
variable too. [^2][^1]: Dynamic
import()
on non-module<script>
is supported in all latest browser but without top-levelawait
. [^2]: The current setup emitconstant/colon.ts
as a chunk but otherconstant/*.ts
got inlined. The current workaround is to not import it directly but re-export it on different module (i.eexport * as ColonFor from "./constant/colon.ts"
inregistry.ts
) with a caveat that it's not tree-shaken and wrapped insideObject.freeze
.TODO