-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Proposal: add import maps to the config file #12800
Comments
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. |
Hi, I'm not sure if I completely understand the proposal. Would that, somehow, help to "chain" import maps related to "nested" imports? I'm putting myself in the role of library maintainer, for a library that has other external dependencies and wants to keep compatibility with NodeJS as well. |
No, it would not. Currently import maps are not chainable. |
I think having Say you have two |
I agree with @jespertheend Apart from this nitpick I think the proposal is fine. I hope it'll land in the near feature |
For import maps in deno.json, makes sense to only reference an import map file for now. In the future, for an embedded import map in deno.json, I think it can be viewed the same way as an import map found in an html file under a |
It seems this can be now achieved by referencing the config file itself as the import map: {
"importMap": "deno.json",
"imports": {
"foo": "bar"
}
} The only downside seems to be this:
|
@kidonng |
There are already precedences like Velociraptor using That said, I don't think taking away the ability to do this for no apparent benefit is worth it. If Deno later uses There are already warnings against this approach (albeit it's from import map instead of config diagnostics), if people accept the risks, let them. |
Context
Deno currently supports a config file and Deno currently supports import maps. Deno does not currently support "combining" import maps and the config file. This leads to potentially complicated command line invocations.
In addition the feature of
deno vendor
is being added (see: #13346) as well as there is other tooling which automates the building of import maps within Deno.As of Deno 1.18, the configuration file is automatically detected, that coupled with significant use of the community of import maps, it is a significantly better developer experience to be able to store the import map in the configuration file and be able to elide that on the command line, just as users can elide the
--config
file option now.Edit: This proposal has been updated from its original form
Semantics
"importMap"
, the value of the key will be interpreted as a path or URL using the config file as a base.--import-map
is supplied on the command line, the value will be used as it is today. If a config file applies and contains an import map, the user will be warned that the value on the command line argument is being ignored, unless the value ofimportMap
and--import-map
resolve to the same resource.Originally the semantics included support for the top level
"imports"
and"scopes"
keys in the configuration file. This has been removed from this proposal and can be revisited in the future.Examples
Considerations
--import-map
or the import map in a config file taking precedence is debatable to the author of the proposal and the author isn't tied to one or the other, but we should defined semantics, and warn the user if there is one or the other being ignored. This was discussed in the core team, and it was agreed that--import-map
should take precedence over the configuration file"imports"
and"scopes"
. The argument has been "what if import maps change and then we have conflicts". The author of the proposal considers these not specifically material of the chance of change to the import map. Import maps was specifically designed to allow for excess keys in them and for them to be ignored, and there is a significant usability upside to allow an existing import map to be used as a config file without any changes. Basically people using an import map would be able to switch to--config
without any changes to their import map, and tooling that maintains an import map could easily be applied directly to a config file without any changes. The biggest "risk" is that compositing import maps is still an open issue in the import map standard, but it hasn't really received any traction. Even then, it is likely we would have to adjust our import map implementation to accomodate it, but it doesn't feel right to hold back from making Deno more usable while there is a non-forward moving risk in the standard that may or may not cause challenges. Edit: this has been removed from the proposal and can be revisited in the futureThe text was updated successfully, but these errors were encountered: