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

Ability to use dependency manager and pin JS files form node_modules #277

Closed
thisismydesign opened this issue Oct 24, 2024 · 6 comments
Closed

Comments

@thisismydesign
Copy link

I know importmap-rails is not meant to be used with package.json but hear me out..

I'm all in favor of ditching the JS build step which complicates things a lot. But I would also like to have proper dependency management for JS. I don't think these exclude each other. I think the principles of importmaps work just fine with package.json, the example in the readme says as much: import React from "./node_modules/react"

Those of us who are ok with having yarn or npm installed could have the best of both worlds:

All my issues would be solved by: pin 'tom-select', to: 'node_modules/tom-select/dist/esm/tom-select.complete.js'

Is this possible? Is there a reason why this can't be an option?

@dhh
Copy link
Member

dhh commented Oct 25, 2024

We have jsbundling-rails for folks who want to have all of that. You're not getting around a build step if you have dynamic dependencies that aren't committed anyway. I think what you want is just jsbundling-rails.

@dhh dhh closed this as completed Oct 25, 2024
@thisismydesign
Copy link
Author

thisismydesign commented Oct 25, 2024

@dhh Many dependencies already include a bundled version. I don't need a build step, I can just reference the bundled file from node_modules.

Like in the tom-select example I gave above.

@nogweii
Copy link

nogweii commented Nov 12, 2024

I'd like to see this supported as I don't want to depend on the good graces of jspm.io working. That's a dependency I'm not a fan of. Being able to point to a local file would allow me to retrieve the file in whatever manner I'm comfortable with. ./bin/importmap pin would copy (move?) the local file into vendor/javascript. "Downloading" a local file, as it were.

Then people could use npm/yarn if they really want to manage dependencies that way, or any other tool could slot in.

@dhh
Copy link
Member

dhh commented Nov 12, 2024

Pin already downloads the file by default. There's no runtime dependency.

@thisismydesign
Copy link
Author

Yes but that isn't a safe or convenient way to manage dependencies. A dependency manager is.

Local files are already supported, so allowing an optional custom path for them should be straightforward, and it would solve these issues.

@dhh
Copy link
Member

dhh commented Nov 12, 2024

If you want a full-blown dependency manager, you should use npm with esbuild. We already have a great integration for that with jsbundling-rails. It's not what this setup is about.

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

No branches or pull requests

3 participants