Skip to content

Commit

Permalink
fix: Bare imports not working sometimes (#579)
Browse files Browse the repository at this point in the history
Fixes #566
Supersedes #577
  • Loading branch information
jhnns authored and evilebottnawi committed Jun 4, 2018
1 parent 2efb8cf commit c348281
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/importsToResolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const path = require("path");
const utils = require("loader-utils");

const matchModuleImport = /^~([^\/]+|@[^\/]+[\/][^\/]+)$/g;
const matchModuleImport = /^~([^\/]+|@[^\/]+[\/][^\/]+)$/;

/**
* When libsass tries to resolve an import, it uses a special algorithm.
Expand Down
2 changes: 1 addition & 1 deletion test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ describe("sass-loader", () => {
sourceMap.should.not.have.property("file");
sourceMap.should.have.property("sourceRoot", fakeCwd);
// This number needs to be updated if imports.scss or any dependency of that changes
sourceMap.sources.should.have.length(11);
sourceMap.sources.should.have.length(13);
sourceMap.sources.forEach(sourcePath =>
fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath))
);
Expand Down
3 changes: 3 additions & 0 deletions test/node_modules/module

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions test/node_modules/other-module

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions test/sass/imports.sass
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@
// See https://github.com/webpack-contrib/sass-loader/issues/556
/* @import util */
@import util
/* @import ~module */
@import ~module
/* @import ~other-module */
@import ~other-module
5 changes: 5 additions & 0 deletions test/scss/imports.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,9 @@
}
// The local util file should take precedence over Node's util module
// See https://github.com/webpack-contrib/sass-loader/issues/556
/* @import "util"; */
@import "util";
/* @import "~module"; */
@import "~module";
/* @import "~other-module"; */
@import "~other-module";

2 comments on commit c348281

@fiso
Copy link

@fiso fiso commented on c348281 Jun 5, 2018

Choose a reason for hiding this comment

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

When can we expect to see this in a release? :)

@alexander-akait
Copy link
Member

@alexander-akait alexander-akait commented on c348281 Jun 5, 2018

Choose a reason for hiding this comment

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

@fiso in near future, we will try solve #556 for new release

Please sign in to comment.