Comments (7)
I have to admit that this seems counter-intuitive to me. Maybe logical, but counter-intuitive:
If I do
import './foo?x=4'
Then I import the file ./foo.mjs
, and the x=4
is part of the cache key, so is used as a "cache buster".
But if I do
import 'foo?x=4'
Then we're importing the package in the folder/file node_modules/foo?x=4
? I would expect to load node_modules/foo
with a cache-busting x=4.
While I understand the logic—bare imports are not URLs, and should not be treated as such—I believe most people wouldn't understand this and would be surprised by this behavior, especially if
import 'foo/bar?x=4'
is treated (somewhat) as a URL and the x=4
suddenly becomes a cache-buster again.
In the interest of the principle of least-surprise, I hope it doesn't land this way.
from modules.
Wouldn't this also impact how folks were planning to handle reloading modules
(e.g. the cache buster hash trick from the browser)?
from modules.
\cc @iarna for npm since it's package name related.
from modules.
In the current implementation the above falls into the ResolveModule path at https://github.com/nodejs/node/blob/master/src/module_wrap.cc#L594. Which then concatenates the specifier into the node_modules lookup. Once found, the path is taken to be the part after the package name length.
So the above example would check the directory node_modules/foo?a
directly on the filesystem.
So we're actually already pretty locked down and in agreement with the package map approach here.
from modules.
@jdalton to an extent?
@guybedford that is a good catch and would have been considered a bug if I saw it before this issue. Since it was not my intention when writing that to have that specific behavior it seems we should still talk about it though.
from modules.
@giltayar you can post the issue I created in package name maps, but I did not see a way to argue about it if prohibiting the characters is seen as a bad idea. Any way it goes, we should match package name maps.
from modules.
Conclusion should stand and we aren't discussing this anymore.
from modules.
Related Issues (20)
- Mocking use cases HOT 13
- Enabling import meta resolve by default? HOT 16
- Relaxing the '#' restriction on imports HOT 8
- Node.js Modules Team Meeting 2020-09-09
- Empty path matching in patterns HOT 8
- Node.js Modules Team Meeting 2020-09-23 HOT 1
- Document node: scheme HOT 4
- Clarification for bundlers re "import" / "require" matching HOT 7
- Node.js Modules Team Meeting 2020-10-07 HOT 3
- File URL normalization changes HOT 1
- s/master/main HOT 3
- Node.js Modules Team Meeting 2020-10-21 HOT 4
- Experimental Status HOT 18
- Node.js Modules Team Meeting 2020-11-04
- Archiving modules repo and stopping team meetings HOT 1
- Use existing context for SourceTextModule evaluation? HOT 2
- Node.js Modules Team Meeting 2020-11-18
- import local files fails while import() succeeds HOT 5
- Proposal: ESM should not export PromiseLike instance HOT 5
- `import.meta.url` is `undefined` inside module file. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from modules.