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: handle module import ending / as module #728

Merged
merged 1 commit into from Aug 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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";