You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While Rollup has facilities to let plugins add any implementation that they fancy, a require.resolve based
implementation will likely never make it into Rollup core. After all, Rollup does not even support require, and it feels less standard than the browser implementation. So I would definitely lean towards the new URL implementation, with the option for plugins to override this.
As I mentioned in the above parcel issue, I think it is weird that import.meta.resolve would influence the resolution rather than only resolving to what is already there.new URL('...', import.meta.url) creates a dependency, therefore moving the target module or asset to a separate file/bundle, and it would be weird if import.meta.resolve did that IMO. That would mean using import.meta.resolve would change the file structure of the output vs not using it. Maybe providing a URL reference to the resolved module within whatever bundle it ends up in via other dependencies would be more expected?
new URL('...', import.meta.url) creates a dependency, therefore moving the target module or asset to a separate file/bundle, and it would be weird if import.meta.resolve did that IMO.
I don't see why that would be weird or why they should behave differently. In my view, import.meta.resolve is a direct replacement for new URL('...', import.meta.url), just with a proper "meta" API instead of pattern-matching a somewhat brittle JS expression that is matched across tooling only by convention.
new URL('...', import.meta.url) creates a dependency, therefore moving the target module or asset to a separate file/bundle, and it would be weird if import.meta.resolve did that IMO.
I don't see why that would be weird or why they should behave differently. In my view, import.meta.resolve is a direct replacement for new URL('...', import.meta.url), just with a proper "meta" API instead of pattern-matching a somewhat brittle JS expression that is matched across tooling only by convention.
ERROR in 8b18a8cf57ffbfd052a4.js
8b18a8cf57ffbfd052a4.js from Terser plugin
Unexpected token: name (import) [8b18a8cf57ffbfd052a4.js:7,undefined]
at js_error (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:577:11)
at croak (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1377:9)
at token_error (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1385:9)
at unexpected (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1391:9)
at semicolon (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1429:56)
at simple_statement (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1707:73)
at statement (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1515:19)
at _embed_tokens_wrapper (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1442:26)
at block_ (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:2295:20)
at statement (/private/tmp/test/test/node_modules/terser/dist/bundle.min.js:1527:29)
webpack 5.109.0 compiled with 1 error and 1 warning in 1989 ms
Activity
TheLarkInn commentedon Apr 16, 2023
@devongovett @lukastaegert lets try to align on this picking which way to go on this so theres not a freaking mess .
lukastaegert commentedon Apr 16, 2023
While Rollup has facilities to let plugins add any implementation that they fancy, a
require.resolvebasedimplementation will likely never make it into Rollup core. After all, Rollup does not even support require, and it feels less standard than the browser implementation. So I would definitely lean towards the new URL implementation, with the option for plugins to override this.
devongovett commentedon Apr 16, 2023
As I mentioned in the above parcel issue, I think it is weird that
import.meta.resolvewould influence the resolution rather than only resolving to what is already there.new URL('...', import.meta.url)creates a dependency, therefore moving the target module or asset to a separate file/bundle, and it would be weird ifimport.meta.resolvedid that IMO. That would mean usingimport.meta.resolvewould change the file structure of the output vs not using it. Maybe providing a URL reference to the resolved module within whatever bundle it ends up in via other dependencies would be more expected?webpack-bot commentedon Jul 17, 2023
This issue had no activity for at least three months.
It's subject to automatic issue closing if there is no activity in the next 15 days.
webpack-bot commentedon Aug 1, 2023
Issue was closed because of inactivity.
If you think this is still a valid issue, please file a new issue with additional information.
latin-1 commentedon Aug 1, 2023
not stale
6 remaining items
alexander-akait commentedon Aug 1, 2024
Also we need to implement
import.meta.resolveWeak, ref #18633latin-1 commentedon Nov 17, 2024
bump @alexander-akait
RReverser commentedon Dec 22, 2024
I don't see why that would be weird or why they should behave differently. In my view,
import.meta.resolveis a direct replacement fornew URL('...', import.meta.url), just with a proper "meta" API instead of pattern-matching a somewhat brittle JS expression that is matched across tooling only by convention.lgarron commentedon Jan 4, 2025
I strongly agree with this.
import.meta.resolve(…)was designed as a standardized way to do what some bundlers have been doing by detectingnew URL(…, import.meta.url). It also comes with clear semantics for bare module names (i.e. resolving a package rather than a relative path):https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/import.meta/resolve#comparison_with_new_url
Having a standardized way to do this is absolutely crucial for those of us who maintain packages that include web workers or WASM.
jnields commentedon Apr 15, 2025
bump
lgarron commentedon Jul 25, 2026
I'm able to confirm that
v5.109.0handlesimport.meta.resolve(…)correctly resolves and includes paths in the import graph for local project code:That is very exciting!
However, I'm unable to confirm whether this works with a library (
cubing.js), because:npx create-webpack-appcreates a projects that crashes for me.Output: