Can't enable code splitting in esbuild
See original GitHub issueVersion
1.31.1
Platform
Linux
What steps will reproduce the bug?
Here is my _config.ts
import esbuild from "lume/plugins/esbuild.ts";
import minify_html from "lume/plugins/minify_html.ts";
import lume from "lume/mod.ts";
export default lume()
.ignore("lib")
.use(esbuild({
options: {
splitting: true,
mangleProps: /^_/,
},
}))
.use(minify_html());
How often does it reproduce? Is there a required condition?
When splitting
option enabled in esbuild
What is the expected behavior?
For example, I have this project structure:
lib
└── utils.ts
elements
├── render-scope.ts
└── page-link.ts
index.html
where both render-scope.ts
and page-link.ts
depend on lib/utils.ts
.
If I run it with esbuild CLI, the result would look like this:
$ esbuild elements/*.ts --bundle --splitting --outdir=_site/elements --format=esm
_site/elements/chunk-YLOKRXMB.js 5.0kb
_site/elements/page-link.js 2.0kb
_site/elements/render-scope.js 1.6kb
⚡ Done in 9ms
What do you see instead?
$ deno task build
Task build deno task lume
Task lume echo "import 'lume/task.ts'" | deno run --unstable --allow-read --allow-run --lock=lock.json -
Loading config file _config.ts
✘ [ERROR] Must use "outdir" when code splitting is enabled
✘ [ERROR] Must use "outdir" when code splitting is enabled
✘ [ERROR] Must use "outdir" when code splitting is enabled
✘ [ERROR] Must use "outdir" when code splitting is enabled
Error: Error processing page
- page: /demo/counter/module.js
- processor:
at (https://deno.land/x/lume@v1.13.1/core/processors.ts:44:19)
at async concurrent (https://deno.land/x/lume@v1.13.1/core/utils.ts:175:3)
at async Processors.run (https://deno.land/x/lume@v1.13.1/core/processors.ts:34:7)
at async Site.#buildPages (https://deno.land/x/lume@v1.13.1/core/site.ts:610:5)
at async Site.build (https://deno.land/x/lume@v1.13.1/core/site.ts:494:9)
at async build (https://deno.land/x/lume@v1.13.1/cli/build.ts:36:3)
at async Command.execute (https://deno.land/x/cliffy@v0.25.4/command/command.ts:1790:7)
at async (https://deno.land/x/lume@v1.13.1/cli.ts:147:3)
Caused by Error: Build failed with 1 error:
error: Must use "outdir" when code splitting is enabled
at failureErrorWithLog (https://deno.land/x/esbuild@v0.15.14/mod.js:1546:15)
at (https://deno.land/x/esbuild@v0.15.14/mod.js:1004:28)
at runOnEndCallbacks (https://deno.land/x/esbuild@v0.15.14/mod.js:1418:61)
at buildResponseToResult (https://deno.land/x/esbuild@v0.15.14/mod.js:1002:7)
at (https://deno.land/x/esbuild@v0.15.14/mod.js:1114:14)
at responseCallbacks.<computed> (https://deno.land/x/esbuild@v0.15.14/mod.js:651:9)
at handleIncomingPacket (https://deno.land/x/esbuild@v0.15.14/mod.js:706:9)
at readFromStdout (https://deno.land/x/esbuild@v0.15.14/mod.js:627:7)
at (https://deno.land/x/esbuild@v0.15.14/mod.js:1828:11)
I have also try specifying outdir
but it conflict with outfile
.
I guess the plugin dynamically populate the outfile
option 🤔
Additional information
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
[Feature] Code splitting on async import() statements. · Issue #16
I don't have a specific date but I'm currently focused on a rewrite of the bundler to enable code splitting, tree shaking, ES6...
Read more >API - esbuild
If applicable, enabling code splitting can further reduce download sizes when browsing to a second page whose entry point shares some already-downloaded ...
Read more >esbuild - Next-generation JavaScript bundler - Refine Dev
esbuild supports both bundling and code splitting. Bundling is when you want to deploy a single app.js target. Code splitting is when you ......
Read more >rollup.js
For code splitting, there are cases where Rollup splits code into chunks automatically, like dynamic loading or multiple entry points, and there is...
Read more >a guide to build tools + exploring Webpack, Parcel, Rollup, ES ...
And plugins allow us to inject code into the ES build, build process. ... Code splitting is still a work in progress it...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, I’ve done some changes to have better defaults when
splitting: true
. Now you only need:And the dest files will replicate the src directory structure.
This would be confusing if esbuild doen’t work in this way by default. Note that code splitting is still work in progress in esbuild.
@DrSensor Ops, sorry. I can’t believe I miss that!! I just tagged the hotfix v1.14.1 and now it should work fine.