From 6d95b0fffd5981141dc961002156cb8da8bff204 Mon Sep 17 00:00:00 2001 From: evilebottnawi Date: Fri, 14 Dec 2018 19:17:29 +0300 Subject: [PATCH] test: support import index file from package --- test/index.test.js | 5 +++++ test/node_modules/sass-package-with-index/index.sass | 2 ++ test/node_modules/scss-package-with-index/index.scss | 3 +++ test/sass/import-index.sass | 1 + test/scss/import-index.scss | 1 + test/tools/createSpec.js | 7 +++++++ 6 files changed, 19 insertions(+) create mode 100644 test/node_modules/sass-package-with-index/index.sass create mode 100644 test/node_modules/scss-package-with-index/index.scss create mode 100644 test/sass/import-index.sass create mode 100644 test/scss/import-index.scss diff --git a/test/index.test.js b/test/index.test.js index 63c99a92..419ba6a2 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -171,6 +171,11 @@ implementations.forEach((implementation) => { )); it('should resolve sass field correctly', () => execTest(`import-sass-field`)); + // Works only in dart-sass implementation + if (implementation === dartSass) { + it('should resolve index file in module correctly', () => + execTest('import-index')); + } }); describe('custom importers', () => { it('should use custom importer', () => diff --git a/test/node_modules/sass-package-with-index/index.sass b/test/node_modules/sass-package-with-index/index.sass new file mode 100644 index 00000000..aabe2c18 --- /dev/null +++ b/test/node_modules/sass-package-with-index/index.sass @@ -0,0 +1,2 @@ +a + color: red diff --git a/test/node_modules/scss-package-with-index/index.scss b/test/node_modules/scss-package-with-index/index.scss new file mode 100644 index 00000000..fdece7b4 --- /dev/null +++ b/test/node_modules/scss-package-with-index/index.scss @@ -0,0 +1,3 @@ +a { + color: red; +} diff --git a/test/sass/import-index.sass b/test/sass/import-index.sass new file mode 100644 index 00000000..edaf8ff4 --- /dev/null +++ b/test/sass/import-index.sass @@ -0,0 +1 @@ +@import "~sass-package-with-index" diff --git a/test/scss/import-index.scss b/test/scss/import-index.scss new file mode 100644 index 00000000..45820a11 --- /dev/null +++ b/test/scss/import-index.scss @@ -0,0 +1 @@ +@import "~scss-package-with-index"; diff --git a/test/tools/createSpec.js b/test/tools/createSpec.js index 62d0b743..b23fd8ef 100644 --- a/test/tools/createSpec.js +++ b/test/tools/createSpec.js @@ -113,6 +113,13 @@ function createSpec(ext) { return; } + if (fileWithoutExt === 'import-index' && implementation !== dartSass) { + // Skip CSS imports for all implementations that are not node-sass + // CSS imports is a legacy feature that we only support for node-sass + // See discussion https://github.com/webpack-contrib/sass-loader/pull/573/files?#r199109203 + return; + } + sassOptions.functions = customFunctions(implementation); const [name] = implementation.info.split('\t');