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 API to update import map in-place #11

Closed
bartlomieju opened this issue Oct 1, 2021 · 0 comments · Fixed by #12
Closed

Add API to update import map in-place #11

bartlomieju opened this issue Oct 1, 2021 · 0 comments · Fixed by #12
Assignees

Comments

@bartlomieju
Copy link
Member

Need an API that can be used to update import map in-place after initial creation. This API will be used to inject mapping for built-in Node modules. The reason a special API is needed is that this injection is non-standard and will happen behind the scenes if users provide a CLI flag. The API must validate there are no entries already present in the import map that would clash with injected mappings.

Eg:

let mut node_mappings = HashMap::new();
node_mappings.insert("fs", "https://deno.land/std@0.110.0/node/fs.ts");
node_mappings.insert("net", "https://deno.land/std@0.110.0/node/net.ts");
...

let mut import_map = ImportMap::from_json(...)?;
import_map.update_in_place(node_mappings)?;  // <--- this will error out if any of the mappings is already in import map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant