-
-
Notifications
You must be signed in to change notification settings - Fork 430
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
Use the index of stdin instead of zero #681
Conversation
|
Codecov Report
@@ Coverage Diff @@
## master #681 +/- ##
==========================================
+ Coverage 98.02% 98.06% +0.03%
==========================================
Files 6 6
Lines 152 155 +3
==========================================
+ Hits 149 152 +3
Misses 3 3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, can you add tests?
I think the test cases actually do cover this, but I can't figure out how to make them break. stdin is in the 0th position of |
@FractalBoy hm, it is very strange, for |
Upgrading |
lib/loader.js
Outdated
result.map.sources[stdinIndex] = path.relative( | ||
process.cwd(), | ||
resourcePath | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for investigation, maybe rewrite this like:
if (stdinIndex !== -1) {
result.map.sources[stdinIndex] = path.relative(
process.cwd(),
resourcePath
);
}
This allow to us protect code if stdin was excluded from sources in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand the point - the way I've written it, stdinIndex
will never be -1. If it is, it will be 0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@FractalBoy I am afraid what in future node-sass
/sass
can remove stdin
from result.map.sources
so better check stdin
exists in sources
and then modify
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now - If stdin
not exists in sources
we break source map, because on 0
index will be contain path to source
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. I'll make the change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would actually be better to remove stdin if it exists and then always add the path?
const stdinIndex = result.map.sources.findIndex(
(source) => source.indexOf('stdin') !== -1
);
const relativeResourcePath = path.relative(
process.cwd(),
resourcePath
);
if (stdinIndex !== -1) {
result.map.sources[stdinIndex] = relativeResourcePath;
} else {
result.map.sources.push(relativeResourcePath);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, nevermind, that would probably screw up the source maps since it wouldn't line up correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job, thanks
@evilebottnawi do you know when your next release will be? |
@FractalBoy |
@evilebottnawi awesome, thanks |
@evilebottnawi will you be publishing a new release soon? i need this update for a project i'm working on. |
@evilebottnawi when will your next release be? it's been over a month since you said it would be released. |
@FractalBoy sorry for delay, next week, there are a lot of work, sass-loader already on top of my todo |
This PR contains a:
Motivation / Use-Case
Solves issue #671, which breaks the use of resolve-url-loader
Breaking Changes
None
Additional Info
This will look for "stdin" in the list of sources and replace it with the Sass file. If it can't find the string for whatever reason, it will
fall back to the previous functionality and just use the 0th indexnot do anything.fixes #671