Open onlywei opened 6 years ago
Hi @onlywei
Yes indeed, using "@empty"
{
"name": "my-package",
"dependencies": {
"a": "^0.1.0",
"b": "^2.3.5"
},
"map": {
"b": "@empty"
}
}
@aluanhaddad any idea if this is jspm 0.17.x only? We're on 0.16.47 and it's not working.
@aluanhaddad the working example you have provided and the written example you gave are inconsistent. One is using "map" an the other is using "dependencies". Which one is correct?
@onlywei I figured that out trying to answer @josephschmitt's question.
Total fail on my part.
"map": {
"dep": "@empty"
}
works correctly and in both 0.17 and master.
@aluanhaddad ok sorry, just to confirm, in the package with the dependency, I add this "map" key in the root of the package.json? Not inside "jspm"? So it would be:
{
"name": "my-package",
"dependencies": {
"my-unwanted-dep": "1.0.0"
},
"map": {
"my-unwanted-dep": "@empty"
}
}
Yes, just like you have it there. Note I tested with the master branch, not with 0.16.47.
It feels like a bug that it doesn't work in the nested "jspm"
section.
Sorry for the confusion.
I'm going to leave this issue open to track that bug.
@aluanhaddad ok. Doesn't seem to work with 0.16.47
at all, either in the root or nested in "jspm"
. Hopefully we can figure out why at some point. Thanks
looking into it now
@aluanhaddad I'm also experiencing that it does not work in the root nor nested in "jspm"
. Maybe I can try upgrading.
I just upgraded to 0.16.53
and I am not seeing a difference. Using "@empty" does not seem to have any effect at all.
@onlywei, @josephschmitt sorry for not replying sooner.
I have created a package, to demonstrate that this works. You can find it at https://github.com/aluanhaddad/jspm-registry-1070
The package has two dependencies, jsdom, and jquery.
I have used "map"
to specify that JSPM users should not install the dependency on jsdom.
To test, run
$ jspm install github:aluanhaddad/jspm-registry-1070
Observe that jsdom is not installed, but jquery is.
Then run
$ npm install aluanhaddad/jspm-registry-1070
Observe that jsdom and jquery are both installed.
Let me know if this helps
@aluanhaddad thanks, we were finally able to get this working for the most part, closing out this issue.
However, I do want to bring attention to a new issue I'm going to create soon related to this. It seems that if we use this technique of setting @empty
, but do so on a dependency which we're not installing in our target app but instead use the sytemjs config's "paths" option, then it'll actually re-write the dependency as import * from '@empty'
, which then throws errors.
Not sure if this project is the right place to file this issue, but I'll work on creating a stand-alone reproducible example in the mean time I can link you to.
Thanks again for your help.
@aluanhaddad here's the new issue I've filed https://github.com/jspm/registry/issues/1072 Additionally, I've set up this repo as a way to easily reproduce the bug we're seeing https://github.com/josephschmitt/jspm-empty-demo
Let me know if someone is able to help out.
Yup this is definitely a bug. I'm not sure what the best fix would be though.
Note that jspm 0.17 fixed up a lot of these sorts of mapping cases, it may be worth trying that version if you can.
For example, can I do something like this in my
package.json
?Such that when I do
jspm install npm:my-package
, I also want JSPM to install "a", but not "b"?