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

Add ability to use import map in packages / modules #12213

Closed
ElikaFilin opened this issue Sep 24, 2021 · 6 comments
Closed

Add ability to use import map in packages / modules #12213

ElikaFilin opened this issue Sep 24, 2021 · 6 comments
Labels
suggestion suggestions for new features (yet to be agreed) web related to Web APIs

Comments

@ElikaFilin
Copy link

When we are using import map in any package(for example package A). After we want to import into package B this package A with import map usage, Deno won't search for deps resultion in package A, it will try to search only in package B.
Therefore suggest to add feature of recursive search of import_map in package, or ability to inline into import_map in package B address of import_map of package A

@bartlomieju
Copy link
Member

This is currently not supported by the spec and we're wary of adding non-standard features to standardized functionality.

Ref WICG/import-maps#252 WICG/import-maps#261

@bartlomieju bartlomieju added the web related to Web APIs label Oct 5, 2021
@stale
Copy link

stale bot commented Dec 4, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Dec 4, 2021
@kitsonk kitsonk added the suggestion suggestions for new features (yet to be agreed) label Dec 4, 2021
@stale stale bot removed the stale label Dec 4, 2021
@castarco
Copy link

castarco commented Jan 22, 2022

I believe that waiting for the standard to advance, when there's nobody working on it, is the wrong move.

I've seen people advocating for dynamic import maps, dynamic import maps generation... but the main problem can be solved mostly statically with just a few metadata annotations.

It is a real problem to handle nested dependencies when you want to publish a Deno-compatible library, and it gets even worse if you want to make it compatible with NodeJS at the same time.

Having the ability to write something like in our library files...

// This is just an example, I'm not sure what's the ideal syntax
// @pragma-import-map: https://path.to/import-map
// or
/// <reference import-map="https://path.to/import-map" />

import { whatever } from 'package-name'  // This gets resolved thanks to the import-map metadata

would make wonders. Of course, the "pragma" annotation would only be applied at this level (and below) of the import tree, to avoid unexpected side effects at the nodes that live upper in the tree, closer to its root.

If something like that got the approval from Deno's team, I would be really happy to collaborate on its development, as I'm suffering this problem a lot.

@kitsonk
Copy link
Contributor

kitsonk commented Jan 22, 2022

I believe that waiting for the standard to advance, when there's nobody working on it, is the wrong move.

I disagree. Almost every choice we would make could easily and likely be changed when the standard changes. The internet is littered with "preemptive" movements let alone ones closer to home (like TypeScript decorators). The best thing to do is advocate with the standards body to move forward.

@ahuigo
Copy link

ahuigo commented Sep 16, 2022

I think every package should have a import_map.json.

Since we know the main package's URI(https://github.com/WICG/import-maps#packages-via-trailing-slashes). e.g. :

{
  "imports": {
    "moment": "/node_modules/moment/src/moment.js",
    "moment/": "/node_modules/moment/src/"
  }
}

Maybe,it is better use ${package}/import_map.json as package's import_map path. e.g.

/node_modules/moment/src/import_map.json

@lucacasonato
Copy link
Member

This is possible when using JSR: https://jsr.io/docs/publishing-packages#importing-npm-packages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions for new features (yet to be agreed) web related to Web APIs
Projects
None yet
Development

No branches or pull requests

6 participants