Closed DrSensor closed 1 year ago
Ok, it makes sense.
esbuild plugin process one file each time. splitting
mode requires to process all files at the same time, in order to discover common dependencies. I'll take a look.
I have added support for this. Can you test it, please?
Update Lume to the latest development version with deno task lume upgrade --dev
.
Thanks!
Alright it works!
But it's quite tricky since I need to specify outdir
too
Okay, I've done some changes to have better defaults when splitting: true
.
Now you only need:
site.use(esbuild({
options: {
splitting: true,
},
}));
And the dest files will replicate the src directory structure.
I think
splitting: true
should be default.
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.
I just notice the new release and when splitting:true
it keep the file extensions instead of renaming it to .js
.use(
esbuild({
extensions: [".ts"],
options: {
splitting: true,
mangleProps: /^_/,
minify: false,
},
}),
)
🔥 /demo/counter/module.js /demo/counter/module.js
🔥 /demo/counter/index.html /demo/counter/index.html
🔥 /lib/render-scope.ts /lib/render-scope.ts
🔥 /lib/std.ts /lib/std.ts
🔥 /chunk-DZLRBH36.js (generated)
Ups! Sorry, I'll fix it. Meanwhile, you can use a procesor to fix it:
site.process([".ts"], (page) => page.data.url.replace(/\.ts$/, ".js");
Fixed in Lume v1.14.0
@oscarotero Bad news, it broke again 😅
$ deno task build
Loading config file file:///run/media/wildan/Projects/Examples/lume-code-splitting/_config.ts
✘ [ERROR] The JSX syntax extension is not currently enabled
deno:file:///run/media/wildan/Projects/Examples/lume-code-splitting/index.html:1:0:
1 │ <!DOCTYPE html>
╵ ^
The esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able
to parse JSX syntax. You can use "loader: { '.js': 'jsx' }" to do that.
✘ [ERROR] Expected identifier but found "!"
deno:file:///run/media/wildan/Projects/Examples/lume-code-splitting/index.html:1:1:
1 │ <!DOCTYPE html>
╵ ^
Error: Build failed with 2 errors:
deno:file:///run/media/wildan/Projects/Examples/lume-code-splitting/index.html:1:0: ERROR: The JSX syntax extension is not currently enabled
deno:file:///run/media/wildan/Projects/Examples/lume-code-splitting/index.html:1:1: ERROR: Expected identifier but found "!"
at failureErrorWithLog (https://deno.land/x/esbuild@v0.15.16/mod.js:1554:15)
at (https://deno.land/x/esbuild@v0.15.16/mod.js:1012:28)
at runOnEndCallbacks (https://deno.land/x/esbuild@v0.15.16/mod.js:1426:61)
at buildResponseToResult (httprun/media/wildans://deno.land/x/esbuild@v0.15.16/mod.js:1010:7)
at (https://deno.land/x/esbuild@v0.15.16/mod.js:1122:14)
at responseCallbacks.<computed> (https://deno.land/x/esbuild@v0.15.16/mod.js:659:9)
at handleIncomingPacket (https://deno.land/x/esbuild@v0.15.16/mod.js:714:9)
at readFromStdout (https://deno.land/x/esbuild@v0.15.16/mod.js:635:7)
at (https://deno.land/x/esbuild@v0.15.16/mod.js:1836:11)
Somehow it treats all files as esbuild input 🤔
@DrSensor Ops, sorry. I can't believe I miss that!! I just tagged the hotfix v1.14.1 and now it should work fine.
Version
1.31.1
Platform
Linux
What steps will reproduce the bug?
Here is my
_config.ts
How often does it reproduce? Is there a required condition?
When
splitting
option enabled in esbuildWhat is the expected behavior?
For example, I have this project structure:
where both
render-scope.ts
andpage-link.ts
depend onlib/utils.ts
.If I run it with esbuild CLI, the result would look like this:
What do you see instead?
I have also try specifying
outdir
but it conflict withoutfile
. I guess the plugin dynamically populate theoutfile
option 🤔Additional information
No response