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

Import from node_modules with bare module specifiers #360

Closed
mbostock opened this issue Dec 9, 2023 · 5 comments · Fixed by #1156
Closed

Import from node_modules with bare module specifiers #360

mbostock opened this issue Dec 9, 2023 · 5 comments · Fixed by #1156
Assignees
Labels
enhancement New feature or request

Comments

@mbostock
Copy link
Member

mbostock commented Dec 9, 2023

We currently support npm: protocol imports for importing directly from npm (via the jsDelivr CDN). But we could also support importing from your local node_modules with bare module specifiers, using rollup to build an ES module as needed.

@mbostock mbostock added the enhancement New feature or request label Dec 9, 2023
@mbostock mbostock added this to the General availability milestone Dec 9, 2023
@mbostock
Copy link
Member Author

(Related #20, which also self-hosts libraries during build using npm: protocol imports.)

@mbostock mbostock modified the milestones: General availability, Future Jan 23, 2024
@Fil Fil mentioned this issue Mar 18, 2024
4 tasks
@Fil
Copy link
Contributor

Fil commented Mar 18, 2024

I've started to experiment with this — sharing in #1101 (current status: "it works for 'earcut'").

@danmarshall
Copy link
Contributor

Hello! I'm new to Framework, so perhaps I'm missing a nuance of importing modules. Was there a design decision to specifically not use package.json as a way to specify dependencies? I've also seen #1009 that seems like might also have an industry-solved solution via usage of (both yarn & npm) package-lock files.
Lock files also have the added benefit of being crawled by Dependabot for security patches.

@mbostock
Copy link
Member Author

@danmarshall Framework supports “implicit imports” for convenience, so you can e.g. start using d3 and it “just works” without you having to remember to npm install d3 ahead of time. By the same extension, we’ve made import * from "npm:whatever" “just work” for any library you want to use without needing to run npm install first.

Our intent is to support both implicit imports and explicit imports using a package manager (such as npm); that’s what this issue is about. So if you would rather manage your dependencies and versions explicitly using npm and package.json, you will be able to do that. But it won’t be a requirement — we’ll offer implicit imports in addition.

@mbostock mbostock removed this from the Future milestone Mar 24, 2024
@g1776
Copy link

g1776 commented Mar 24, 2024

Adding node_modules support would also make versioning of specific packages more transparent, as well as allow better typescript support if we can have it as a devDependency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants