Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect resolving for scoped import maps #33

Closed
costingeana opened this issue Jul 30, 2019 · 6 comments
Closed

Incorrect resolving for scoped import maps #33

costingeana opened this issue Jul 30, 2019 · 6 comments
Labels
question Further information is requested

Comments

@costingeana
Copy link
Collaborator

costingeana commented Jul 30, 2019

Hello, @guybedford,
The last es-module-shims version fails to identify the scoped import maps.

This is a piece of the import map that I use (generated with jspm):

{
  "imports": {
    "@hubgets/heros.uil.loader": "./jspm_packages/npm/@hubgets/[email protected]/lib/index.js",
    "@hubgets/heros.uil.loader/": "./jspm_packages/npm/@hubgets/[email protected]/"
},
 "scopes": {
    "jspm_packages/npm/@hubgets/[email protected]/": {
      "@hubgets/heros.datalocal": "../[email protected]/lib/index.js",
      "@hubgets/heros.datalocal/": "../[email protected]/",
      "@hubgets/lib.error": "../[email protected]/lib/index.js",
      "@hubgets/lib.error/": "../[email protected]/",
      "@hubgets/lib.useragent": "../[email protected]/lib/index.js",
      "@hubgets/lib.useragent/": "../[email protected]/"
    }
}

I investigated a little bit and I think the problem's root is in parseImportMap:

scopes[resolvedScopeName] = resolvePackages(scope, baseUrl) || {};

I think this line should be:

scopes[resolvedScopeName] = resolvePackages(scope, resolvedScopeName) || {};

baseUrl for scoped packages should be the resolved url of their 'parent'.

Please let me know if you think I identified correctly the cause of the issue and I'll come up with a pull request.

Thanks!

@costingeana costingeana added the bug Something isn't working label Jul 30, 2019
@guybedford
Copy link
Owner

This is actually working as designed, and is a bug in jspm itself rather (and SystemJS, with the PR for SystemJS currently at systemjs/systemjs#1975).

The import maps specification changed such that scopes are resolved relative to the import map base, instead of the scope itself.

@guybedford guybedford added question Further information is requested and removed bug Something isn't working labels Jul 31, 2019
@costingeana
Copy link
Collaborator Author

Thanks for your answer. Is there any issue added in jspm related to this matter?

@guybedford
Copy link
Owner

See jspm/jspm-cli#2493.

@costingeana
Copy link
Collaborator Author

Thanks!

@guybedford
Copy link
Owner

Sure, this fix is now released in 2.0.0-beta.7. That should resolve this, but please let me know if you have further issues at all.

@costingeana
Copy link
Collaborator Author

I just tested it and it works. Thanks once again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants