Skip to content

Commit

Permalink
fix: handle module import ending / as module
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Aug 16, 2019
1 parent 071fa88 commit 34e4eb7
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
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
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
@@ -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
@@ -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 34e4eb7

Please sign in to comment.