Skip to content

Conversation

@rmacklin
Copy link
Contributor

Given that a major benefit of using the default importmap-rails approach is that you don't need nodejs at all, I think we should avoid using the term "node modules" and instead use "npm packages". This should hopefully avoid confusion/misunderstanding where folks mistakenly think they still need to install node: The CDNs allow them to still leverage the npm ecosystem even if their system doesn't have nodejs nor any local node_modules directories.

Given that a major benefit of using the default importmap-rails approach
is that you don't need nodejs at all, I think we should avoid using the
term "node modules" and instead use "npm packages". This should
hopefully avoid confusion/misunderstanding where folks mistakenly think
they still need to install node: The CDNs allow them to still leverage
the npm ecosystem even if their system doesn't have nodejs nor any local
`node_modules` directories.
@rmacklin rmacklin changed the title Change comment in importmap.rb template to avoid mentioning "node" Avoid mentioning "node" in importmap.rb template and README Sep 28, 2021
@dhh dhh merged commit 6dd4c43 into rails:main Sep 28, 2021
@rmacklin rmacklin deleted the avoid-potential-confusion-about-node branch September 28, 2021 15:41
rmacklin added a commit to rmacklin/rails-website that referenced this pull request Dec 16, 2021
The hash in this link needs to be updated because the heading was
renamed in rails/importmap-rails#44
@rromanchuk
Copy link

@rmacklin the lazy developer in me is still using yarn for cssbundling-rails vendored assets, but I haven't come up with a better way yet. Obviously bad because style and js can easily diverge if you forget to lock both, and confusing to see npm related toolchain when it has nothing to do with js. Is this just a consequence of the ecosystem or is there a better way?

Specific example of using this crutch via --load-path=node_modules

// app/assets/stylesheets/application.sass.scss
@import 'bootstrap/scss/bootstrap';
@import 'highlight.js/scss/github-dark-dimmed';
@import "video.js/dist/video-js";

in my package.json

 "scripts": {
    "build:css": "./bin/build-css"
  }

and build-css

#!/usr/bin/env bash

./node_modules/sass/sass.js \
  ./app/assets/stylesheets/application.sass.scss:./app/assets/builds/application.css \
  ./app/assets/stylesheets/three.sass.scss:./app/assets/builds/three.css \
  --no-source-map \
  --load-path=node_modules \
  $@

@rmacklin
Copy link
Contributor Author

If you're using a third party dependency that provides both CSS and JS, I'm not sure there's a way to avoid specifying the version of the dependency twice. But you could potentially write a test that fails if the two versions are not equal, in order to prevent them from diverging. As far as avoiding npm related tooling, you may be able to do so if you can pull the CSS from a CDN.

chilavadym pushed a commit to chilavadym/website that referenced this pull request Feb 12, 2023
The hash in this link needs to be updated because the heading was
renamed in rails/importmap-rails#44
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 this pull request may close these issues.

3 participants