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

fix: resolve conflict #558

Closed
wants to merge 1 commit into from
Closed

Conversation

alexander-akait
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Apr 13, 2018

Codecov Report

Merging #558 into master will increase coverage by 0.03%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #558      +/-   ##
==========================================
+ Coverage   97.58%   97.61%   +0.03%     
==========================================
  Files           6        6              
  Lines         124      126       +2     
==========================================
+ Hits          121      123       +2     
  Misses          3        3
Impacted Files Coverage Δ
lib/webpackImporter.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2759618...265f3db. Read the comment docs.

@ioanungurean
Copy link

@jhnns can we review and add this fix, please? I had errors with 'v7.0.0' and 'v7.0.1' and with this PR my build is working just fine.

Copy link
Member

@jhnns jhnns left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for prodiving test cases to reproduce the problem 👍
I don't think that the fix makes sense here (see my comment). It needs to be addressed in the importsToResolve function

@@ -46,6 +46,9 @@ function webpackImporter(resourcePath, resolve, addNormalizedDependency) {
Promise.reject() :
resolve(dir, importsToResolve[0])
.then(resolvedFile => {
if (!([".sass", ".scss", ".css"].includes(path.extname(resolvedFile)))) {
throw new Error("Alias should have 'sass', 'scss' or 'css' extension");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This requirement is very arbitrary and I don't think that we should introduce that. Why do aliases have to have a sass, scss or css extension? Furthermore, it's not necessarily an alias that caused this condition, so the error message is also misleading.

Copy link
Member Author

@alexander-akait alexander-akait Apr 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhnns i know 😞 , it is very interesting. Found solution:

  1. Add url + all paths from includePaths in https://github.com/webpack-contrib/sass-loader/blob/master/lib/importsToResolve.js#L56 (i.e. includePath[0]/${url}, includePath[1]/${url}, url)
  2. Node-sass should be try import first when we try import throw own implement (not sure it is possible)

Any ideas how we can fix this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently not. I wish we could let node-sass handle the imports as default and then use webpack's resolver, but that's not possible with the current node-sass API.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhnns 😞 I try to search solution todat, have some ideas.

@jhnns
Copy link
Member

jhnns commented Apr 25, 2018

This change introduces other problems as described here.

I think we need to go a similar route as with the less-loader here. If the includePaths option is specified, webpack's resolver isn't used at all (see less-loader). It makes no sense to specify includePaths and to use webpack's resolver (because webpack's resolver provides the same possibilities as includePaths do).

Actually, I'm even thinking about making webpack's resolver opt-in because I assume that the threadpool issue with custom importers #147 is the cause for the performance problems #296. Furthermore, most people don't need webpack's resolver. They just want to use Sass the regular way.

If the webpack resolver is used, the includePaths option is not valid anymore.

@jhnns jhnns closed this Apr 25, 2018
@alexander-akait alexander-akait deleted the fix-resolve-conflict branch April 25, 2018 12:12
@alexander-akait
Copy link
Member Author

@jhnns what about don't resolve path includes includePaths?

@jhnns
Copy link
Member

jhnns commented Apr 25, 2018

The problem is that we can only know after resolving that an import was supposed to be resolved by includePaths. Besides that, I think it makes sense to make the webpack resolver optional.

@alexander-akait
Copy link
Member Author

@jhnns optional solve problem, but many new people will be set this optional to true and get errors - create issue, i think better will be solve problem without new option to avoid this situation. Will you give me time to think more deeply about this?

@alexander-akait
Copy link
Member Author

alexander-akait commented Jun 1, 2018

@jhnns i faced with problem in some projects i need alias and includePaths, i think optional is not real solve problem

I think solution with using only css/sass/scss resolved files is only right. It is doesn't make sense when you resolve .js/.jsx/.vue/etc inside sass-loader - it is always broke node-sass compilation

@xzyfer xzyfer mentioned this pull request Jun 5, 2018
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