Skip to content

Commit c348281

Browse files
jhnnsevilebottnawi
authored andcommitted
fix: Bare imports not working sometimes (#579)
Fixes #566 Supersedes #577
1 parent 2efb8cf commit c348281

File tree

6 files changed

+17
-2
lines changed

6 files changed

+17
-2
lines changed

lib/importsToResolve.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require("path");
44
const utils = require("loader-utils");
55

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

88
/**
99
* When libsass tries to resolve an import, it uses a special algorithm.

test/index.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ describe("sass-loader", () => {
205205
sourceMap.should.not.have.property("file");
206206
sourceMap.should.have.property("sourceRoot", fakeCwd);
207207
// This number needs to be updated if imports.scss or any dependency of that changes
208-
sourceMap.sources.should.have.length(11);
208+
sourceMap.sources.should.have.length(13);
209209
sourceMap.sources.forEach(sourcePath =>
210210
fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath))
211211
);

test/node_modules/module

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/node_modules/other-module

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/sass/imports.sass

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@
2222
// See https://github.com/webpack-contrib/sass-loader/issues/556
2323
/* @import util */
2424
@import util
25+
/* @import ~module */
26+
@import ~module
27+
/* @import ~other-module */
28+
@import ~other-module

test/scss/imports.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,9 @@
2323
}
2424
// The local util file should take precedence over Node's util module
2525
// See https://github.com/webpack-contrib/sass-loader/issues/556
26+
/* @import "util"; */
2627
@import "util";
28+
/* @import "~module"; */
29+
@import "~module";
30+
/* @import "~other-module"; */
31+
@import "~other-module";

0 commit comments

Comments
 (0)