Comments (8)
So, I have this internal webapp I often run npm-related tests in because it's been such a good example of modern "real world" webapps. It doesn't take long to find potential conflicts using npm ls
that could affect frontend deps:
Two different versions of regenerator-runtime
in a single tree
├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├── [email protected] └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └── [email protected]
Two different semver-major versions of querystringify
used by sockjs-client
└─┬ [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] └─┬ [email protected] └── [email protected]
Tree showing multiple locations of har-validator
at 3 different versions.
├─┬ [redacted]@10.0.7 │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └── [email protected] └─┬ [email protected] └─┬ [email protected] └─┬ [email protected] └── [email protected]
Another example from the same app involves 4 different semver-major versions of the same library:
Another npm ls
showing camelcase
at versions 1, 2, 3, and 4.
├─┬ @npm/[email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ @npm/[email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ @npmcorp/[email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ ├── [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] deduped │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped ├─┬ [email protected] │ └─┬ [email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ ├─┬ [email protected] │ │ ├── [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] deduped │ └─┬ [email protected] │ └── [email protected] ├─┬ [email protected] │ ├─┬ [email protected] │ │ └─┬ [email protected] │ │ └─┬ [email protected] │ │ └── [email protected] │ └─┬ [email protected] │ ├── [email protected] │ └─┬ [email protected] │ └── [email protected] deduped └─┬ [email protected] └─┬ [email protected] └── [email protected]
from import-maps.
I've definitely hit this in my projects with lodash 3 and 4, and not lodash-es.
Some similarly low-level common library like underscore, rxjs, etc. would probably yield examples.
from import-maps.
react-popper
, which still requires react
15 because it accesses import React from 'react'; React.PropTypes
, but that has been removed in react
16.
Though I guess react
+react-dom
is an example of the opposite problem; everything you load must use the exact same packages, as loading more than one will cause conflicts even if they're the exact same version; the bloat is the least of the problems.
I currently work around it by doing a string replace in the source code to import PropTypes from 'prop-types'
instead, but an alternative could be to have a package map just for that module that would export { default } from 'react'; export { default as PropTypes } from 'prop-types'
.
Note how, as this module would be providing react
itself for react-popper
, it still needs to be able to import the real react
by name, so the mapping would have to not apply for the shim package.
from import-maps.
@caub I don't think your question has anything to do with the TODO in this issue, so I'd ask you to move it elsewhere.
from import-maps.
Hey @zkat thanks! Can you put the last three example in code blocks? :)
from import-maps.
It seems they are in code blocks but the formatting is being crazy. GitHub also isn't correctly expanding the second <details>
.
from import-maps.
Sorry about that! Fixed!
from import-maps.
This has been incorporated into the overhauled proposal! https://github.com/domenic/import-maps#multiple-versions-of-the-same-module
from import-maps.
Related Issues (20)
- Modulepreload error caching HOT 9
- Should HTMLScriptElement.supports("importmap") return true? HOT 1
- Fire a load event or an error event when the script element of the import map is from an external file? HOT 2
- preparation-time document check should be done first at #register-an-import-map HOT 2
- Throwing TypeError in resolve a module specifier? HOT 2
- calling onerror of the script element if the import map string cannot be parsed HOT 1
- What should 'parse an import map string' return when it throws an Error? HOT 8
- Speculatively parsing with import map if there's a dynmic import before, HOT 4
- Official file extension? HOT 2
- Support stars in imports besides trailing slashes HOT 1
- `importmap` cannot resolve dependencies entered relatively. HOT 3
- [feat] `script.integrity` and import map HOT 2
- Specification is not restricting address from containing query- or fragment parts not ending with "/" HOT 3
- global variables (f.e. map `"jquery"` specifier to `globalThis.jquery` variable) HOT 1
- Specify package.json path in <script>, and then generate the import map from package.json. HOT 7
- Unable to create folder alias to use in further alias. HOT 2
- ability to specify a default extension for extensionless URLs HOT 3
- Fallbacks for failed URLs? HOT 1
- import maps for `import()` statements HOT 1
- Support for "package.json browser" style file replacement/removal within modules? HOT 2
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 import-maps.