-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Custom importer sass.NULL usage #1291
Comments
This is assuming the importer implementation does a require('node-sass') to get a node-sass reference. How else would it be able to access sass.NULL |
In some situation using peerDependencies will solve it, but probably not everywhere |
Would that help if we would just return undefined? I actually think we should drop sass.NULL and use that native node type, just haven't got around to implementing it yet. |
@chriseppstein I'd like to hear your thoughts on this since I expect any decision here will impact eyeglass. |
@kenborge, you have made a very good point and thanks for spotting and reporting this issue. - done(result === module.exports.NULL ? null : result);
+ done(result.toString() === module.exports.NULL.toString() ? null : result);
// both will return `[object SassNull]` which is different than `[object Object]` or - done(result === module.exports.NULL ? null : result);
+ done(result.constructor.toString() === module.exports.NULL.constructor.toString() ? null : result); The idea was to not advertise these export too much and still able to provide control for explicitly returning |
Actually asking for |
In JavaScript |
@am11 What about
This is what this patch is checking against. |
@saper, either test the type |
My patch uses |
A couple things.
This is essentially forcing a peer dependency, which I agree is bad.
I agree that with returning
Technically not true.
We could strictly check against Although technically My preference would be move sass-types into it's own repo as discussed in #1088 (comment) This solves the peerDependency problem, preserves the semantics of returning |
It's also worth noting that we currently do not distinguish between custom importers returning The exception being #1308 where we don't correctly handle return |
I've added test coverage for the existing importer noop return semantics in #1319. This will prevent us from unintentionally introducing BC breaks. |
There are several problems with explicitly using |
Maybe we would better off by moving this code into the C++ binding. We should know better in C++ if the value was returned and how. |
@xzyfer Returning |
@pmowrer I believe this has been patched in the current beta. Try |
With sass#1291 custom importers can now return `null` instead of `sass.NULL`. This means custom importer modules no longer need to have node-sass as a dependency.
With sass#1291 custom importers can now return `null` instead of `sass.NULL`. This means custom importer modules no longer need to have node-sass as a dependency.
Returning `sass.NULL` when not handling an import was causing issues when multiple installs of `node-sass` were present as they would have independent instances of `sass.NULL`. See discussion here: sass/node-sass#1291 It appears using `null` instead of `sass.NULL` works as of `node-sass` 3.5.x.
----- It is inappropriate to include political and offensive content in public code repositories. Public code repositories should be neutral spaces for collaboration and community, free from personal or political views that could alienate or discriminate against others. Political content, especially that which targets or disparages minority groups, can be harmful and divisive. It can make people feel unwelcome and unsafe, and it can create a hostile work environment. Please refrain from adding such content to public code repositories.
The documentions for custom importers state that
If an importer does not want to handle a particular path, it should return sass.NULL
But if you implement the importer in a package, that will be used as a dependency, this package will have a dependency on node-sass and have node-sass package in it's node_modules.
So when this importer is run from another package, like grunt-sass that has its own dependency on node-sass, the node-sass module used in grunt-sass and in the importer will not be the same object and the object reference equality check in node-sass will fail.
This cause node-sass to think all imports are handled by this importer no matter what.
The text was updated successfully, but these errors were encountered: