Use esbuild metafile. Add support for 'entryNames' esbuild option.#678
Conversation
… files to pages. This adds support for the 'entryNames' option of esbuild lumeland#678
e87ed9f to
40a7029
Compare
… files to pages. This adds support for the 'entryNames' option of esbuild lumeland#678
40a7029 to
e835ec5
Compare
… files to pages. This adds support for the 'entryNames' option of esbuild lumeland#678
e835ec5 to
7961d31
Compare
oscarotero
left a comment
There was a problem hiding this comment.
Thanks for this! I didn't know the metafile option but it seems very useful!
I just left some comments in the review, some of them are optional. To me, the most sensible part is the change of the output directory, which can break the code.
… files to pages. This adds support for the 'entryNames' option of esbuild lumeland#678
7961d31 to
10e7353
Compare
… files to pages. This adds support for the 'entryNames' option of esbuild lumeland#678
10e7353 to
8620265
Compare
Note that the previous implementation completely ignored the esbuild output path and just wrote it to |
Yeah, to be honest, I hadn't thought about that situation until now! :) |
Description
Currently (before this PR) the esbuild plugin would always output JS asset files as
options.outdir + replaceExtension(page.data.url). Which means The esbuild optionentryNameswould not work.Additionally the esbuild plugin tries to map output files from esbuild to lume pages (JS eintry points). This looks similar to this:
When
entryPointsis set/changed this no longer works. The plugin then can not find a page for the outfile and adds it as a chunk.When using the
entryNamesoption like this:Given a source file
scripts/index.tsyou would get something like the following output files:js/index.WSRTVQIK.jsscripts/index.tsscripts/index.tsThis PR adds support for the
entryPointsoption. It now uses the esbuild metafile which contains information about input and output files and their relation. Using this metafile we can properly map esbuild outfiles to lume pages. It now also uses the esbuild outfile filename as finaldata.url:The replace is there to support url overwrites via
basename. Using lume url overwrites in combination with theentryNamesesbuild option works generally. However as we only write the file to a different location to what esbuild intended, JS imports to this file (e.g. via dynamic imports) are not rewritten! Esbuild currently does not offer any functionality to dynamically rewrite an outfile path per file (as far as I know). So this is as much as we can do.I have also mostly reverted the changes from commit 13796a7 as that workaround is no longer necessary.
Related Issues
None
Check List
CODE OF CONDUCT
CONTRIBUTING
send multiple pull request.
fmtto fix the code format before commit.CHANGELOG.md.