[esbuild-plugin-meta-url] has no effect
See original GitHub issueI recently started a project which tries to implement a map renderer in Rust. I’m currently evaluating which bundler is the best for the task as I require two features:
- Inlining webworkers (or any module)
- Resolving/Handling
import.meta.url
in CJS and ESM modules, especially for .wasm files.
I tried the plugin @chialab/esbuild-plugin-meta-url
to solve the second goal, but esbuild is not copying assets to the output directory.
Config:
build.mjs
import esbuild from 'esbuild';
import metaUrlPlugin from '@chialab/esbuild-plugin-meta-url';
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
format: "esm",
platform: "browser",
outdir: "dist/esbuild/",
plugins: [
metaUrlPlugin(),
],
});
Is there more configuration needed?
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
can add support for __dirname and __filename? #859 - GitHub
meta.url to get at the path of the final bundle. Using a plugin gives the user control instead of having esbuild pick a...
Read more >Plugins - esbuild
Plugins. The plugin API allows you to inject code into various parts of the build process. Unlike the rest of the API, it's...
Read more >@chialab/esbuild-plugin-meta-url - npm
A file loader plugin for esbuild for constructed URLs using import metadata.. Latest version: 0.17.2, last published: 2 months ago.
Read more >Changelog - esbuild - Breword 文档集合
This has the same effect as if you passed --target=es2021 to esbuild. ... achieve in an esbuild plugin because there was no way...
Read more >Why vite.js doesn't work when I use npm run dev
This was caused by esbuild#2177 (on which Vite depends), which was just recently reverted in esbuild version 0.14.36. This issue should no ...
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 Free
Top 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
Hello @maxammann. We have released a new version of the plugin (0.15.17). As you suggested, we tried to closely match the standard
URL
behavior, so we started to prefer local imports over modules resolution. We still support it for backward compatibility, but now it raises a warning. Thank you!I kind of agree that resolving modules could be handy for users. I would put that under a feature flag though as it does not conform to the default behavior.
In plain ES6
new URL("test.js", import.meta.url)
, called fromhttps://example.com/main.js
will resolve to:https://example.com/test.js
That means by definition resolving a file though URL + import.meta.url is relative. When transforming such a URL construct we should keep the relativity.
I tried the current implementation against the generated code by wasm_bindgen which expects it to be foremost relative.