Skip to content

Commit

Permalink
fix: handle module import ending / as module (#728)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Aug 20, 2019
1 parent 071fa88 commit 997a255
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/importsToResolve.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@ import path from 'path';

import utils from 'loader-utils';

const matchModuleImport = /^~([^/]+|@[^/]+[/][^/]+)$/;
// Examples:
// - ~package
// - ~package/
// - ~@org
// - ~@org/
// - ~@org/package
// - ~@org/package/
const matchModuleImport = /^~([^/]+|[^/]+\/|@[^/]+[/][^/]+|@[^/]+\/?|@[^/]+[/][^/]+\/)$/;

/**
* When libsass tries to resolve an import, it uses a special algorithm.
Expand Down
8 changes: 8 additions & 0 deletions test/helpers/getCodeFromSass.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,18 @@ function getCodeFromSass(testId, options) {
/^~@path-to-scss-dir\/dir-with-underscore-index$/,
pathToSCSSIndexAlias
)
.replace(
/^~@path-to-scss-dir\/dir-with-underscore-index\/$/,
pathToSCSSIndexAlias
)
.replace(
/^~@path-to-sass-dir\/dir-with-underscore-index$/,
pathToSassIndexAlias
)
.replace(
/^~@path-to-sass-dir\/dir-with-underscore-index\/$/,
pathToSassIndexAlias
)
.replace(
/^~@\/path-to-scss-dir\/dir-with-underscore-index$/,
pathToSCSSIndexAlias
Expand Down
1 change: 1 addition & 0 deletions test/sass/import-alias.sass
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import 'path-to-alias'
@import "~@sass"
@import "~@path-to-sass-dir/dir-with-underscore-index"
@import "~@path-to-sass-dir/dir-with-underscore-index/"
@import "~@/path-to-sass-dir/dir-with-underscore-index"
1 change: 1 addition & 0 deletions test/scss/import-alias.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import 'path-to-alias';
@import "~@scss";
@import "~@path-to-scss-dir/dir-with-underscore-index";
@import "~@path-to-scss-dir/dir-with-underscore-index/";
@import "~@/path-to-scss-dir/dir-with-underscore-index";

0 comments on commit 997a255

Please sign in to comment.