question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lazily require node-sass

See original GitHub issue

This issue is very closely related to #715 and #731, but I’m suggesting a different solution.

node-sass is always installed (with all its problems) even if it won’t be used. I don’t think I have to explain why this is a bad idea, but fixing this would for one solve(/prevent) all the “dependency needs to be updated” issues.

Instead of requiring the user to always explicitly pass the compiler like @stof suggested (which I personally still think is the best solution), I suggest we at least lazily load the node-sass module, i.e. not require-ing it if the compiler option is specified. We can then move node-sass to devDependencies so users won’t automatically install it if they’re not going to use it. Unlike @stof 's suggestion this doesn’t require a breaking change.

I see you’ve closed the aforementioned prior issues on this topic on grounds of ‘not planned’, but I fail to see a reason why one wouldn’t want to implement (or rather fix) this. I think it’s illogical to advertising this module as being compatible with both node- and dart-sass while actually always installing node-sass “in the background”. You mentioned that people can use gulp-dart-sass instead, which is entirely true, but I don’t see why we need to create (and maintain) a fork for this trivial functionality.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:18
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
MartijnCuppenscommented, Dec 30, 2019

This is a breaking change indeed. But I think it’s worth it. Apart from dart Sass supporting the module system, dart sass also has a smaller dependency tree (install size vs node-sass install size). Imo sass should also be the default instead of node-sass, since it’s recommended by Sass itself.

About gulp-dart-sass: sass seems to be a dependency which isn’t updated regularly, which is kind of an issue.

4reactions
jens-tcommented, Oct 26, 2020

LibSass is officially deprecated: https://sass-lang.com/blog/libsass-is-deprecated

So maybe now is the time for that breaking change …

Read more comments on GitHub >

github_iconTop Results From Across the Web

lazy-require - npm
Lazy require allows you to require modules lazily, meaning that when you lazy require a module that is missing, lazy require will ...
Read more >
Node.js lazy require module - Stack Overflow
Since node require tree resolution is evaluated/analyzed statically and webpack assumes this it fails on dynamic resolution.
Read more >
Lazy – A Node.js Module You Should Know About
Basically you create a new lazy object, and pump data into it via data events (it's an event emitter). Then you can manipulate...
Read more >
sindresorhus/import-lazy: Import a module lazily - GitHub
Pass in `require` or a custom import function const importLazy = require('import-lazy')(require); const _ = importLazy('lodash'); // Instead of referring to ...
Read more >
Lazy-loading modules - A progressive Node.js framework
Lazy loading can help decrease bootstrap time by loading only modules required by the specific serverless function invocation. In addition, you could also ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found