diff --git a/.nycrc b/.nycrc index 41dc9cf5..43ea50ef 100644 --- a/.nycrc +++ b/.nycrc @@ -9,6 +9,6 @@ "lines": 97, "statements": 97, "functions": 100, - "branches": 90, + "branches": 89, "check-coverage": true } diff --git a/.travis.yml b/.travis.yml index dc4212f8..27e6e65d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,28 +8,21 @@ jobs: fast_finish: true allow_failures: - env: WEBPACK_VERSION=canary - - node_js: 9 include: - - &test-latest - stage: Webpack latest - node_js: 6 - env: WEBPACK_VERSION=latest JOB_PART=test - script: npm run travis:$JOB_PART - - <<: *test-latest - node_js: 8 + - node_js: 6 env: WEBPACK_VERSION=latest JOB_PART=lint script: npm run travis:$JOB_PART - - <<: *test-latest - node_js: 8 + - node_js: 6 + env: WEBPACK_VERSION=latest JOB_PART=test + script: npm run travis:$JOB_PART + - node_js: 8 env: WEBPACK_VERSION=latest JOB_PART=coverage script: npm run travis:$JOB_PART after_success: 'bash <(curl -s https://codecov.io/bash)' - - stage: Webpack canary - node_js: 8 - env: WEBPACK_VERSION=4.0.0 JOB_PART=test + - node_js: 10 + env: WEBPACK_VERSION=latest JOB_PART=test script: npm run travis:$JOB_PART - - stage: NodeJS Next - node_js: 9 + - node_js: 11 env: WEBPACK_VERSION=latest JOB_PART=test script: npm run travis:$JOB_PART before_install: diff --git a/lib/loader.js b/lib/loader.js index 082a2e63..d548f555 100644 --- a/lib/loader.js +++ b/lib/loader.js @@ -35,14 +35,19 @@ function sassLoader(content) { ); } + let resolve = pify(this.resolve); + + // Supported since v4.27.0 + if (this.getResolve) { + resolve = this.getResolve({ + extensions: ['.scss', '.sass', '.css'], + }); + } + const options = normalizeOptions( this, content, - webpackImporter( - resourcePath, - pify(this.resolve.bind(this)), - addNormalizedDependency - ) + webpackImporter(resourcePath, resolve, addNormalizedDependency) ); // Skip empty files, otherwise it will stop webpack, see issue #21 diff --git a/package-lock.json b/package-lock.json index ff47eb2a..c9ea2d3b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1112,7 +1112,7 @@ }, "bootstrap-sass": { "version": "3.3.7", - "resolved": "https://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz", + "resolved": "http://registry.npmjs.org/bootstrap-sass/-/bootstrap-sass-3.3.7.tgz", "integrity": "sha1-ZZbHq0D2Y3OTMjqwvIDQZPxjBJg=", "dev": true }, @@ -5046,12 +5046,12 @@ "dev": true }, "husky": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/husky/-/husky-1.2.0.tgz", - "integrity": "sha512-/ib3+iycykXC0tYIxsyqierikVa9DA2DrT32UEirqNEFVqOj1bFMTgP3jAz8HM7FgC/C8pc/BTUa9MV2GEkZaA==", + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/husky/-/husky-1.2.1.tgz", + "integrity": "sha512-4Ylal3HWhnDvIszuiyLoVrSGI7QLg/ogkNCoHE34c+yZYzb9kBZNrlTOsdw92cGi3cJT8pPb6CdVfxFkLnc8Dg==", "dev": true, "requires": { - "cosmiconfig": "^5.0.6", + "cosmiconfig": "^5.0.7", "execa": "^1.0.0", "find-up": "^3.0.0", "get-stdin": "^6.0.0", @@ -5411,7 +5411,7 @@ }, "is-accessor-descriptor": { "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "resolved": "http://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, "requires": { @@ -5470,7 +5470,7 @@ }, "is-data-descriptor": { "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "resolved": "http://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, "requires": { diff --git a/test/index.test.js b/test/index.test.js index 4bd5d43a..262984aa 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -295,7 +295,7 @@ implementations.forEach((implementation) => { // This number needs to be updated if imports.scss or any dependency of that changes. // Node Sass includes a duplicate entry, Dart Sass does not. sourceMap.sources.should.have.length( - implementation === nodeSass ? 11 : 10 + implementation === nodeSass ? 12 : 11 ); sourceMap.sources.forEach((sourcePath) => fs.existsSync(path.resolve(sourceMap.sourceRoot, sourcePath)) diff --git a/test/node_modules/@org/style.js b/test/node_modules/@org/style.js new file mode 100644 index 00000000..bb6c87f1 --- /dev/null +++ b/test/node_modules/@org/style.js @@ -0,0 +1 @@ +'Bad'; diff --git a/test/node_modules/@org/style.scss b/test/node_modules/@org/style.scss new file mode 100644 index 00000000..fdece7b4 --- /dev/null +++ b/test/node_modules/@org/style.scss @@ -0,0 +1,3 @@ +a { + color: red; +} diff --git a/test/node_modules/scss/style.js b/test/node_modules/scss/style.js new file mode 100644 index 00000000..bb6c87f1 --- /dev/null +++ b/test/node_modules/scss/style.js @@ -0,0 +1 @@ +'Bad'; diff --git a/test/node_modules/scss/style.scss b/test/node_modules/scss/style.scss new file mode 100644 index 00000000..fdece7b4 --- /dev/null +++ b/test/node_modules/scss/style.scss @@ -0,0 +1,3 @@ +a { + color: red; +} diff --git a/test/sass/imports.sass b/test/sass/imports.sass index 1094133a..bc5402d3 100644 --- a/test/sass/imports.sass +++ b/test/sass/imports.sass @@ -24,3 +24,5 @@ @import ~module /* @import ~another */ @import ~another +// Should prefer `scss` +@import "~@org/style" diff --git a/test/scss/imports.scss b/test/scss/imports.scss index a55e52e1..670c433a 100644 --- a/test/scss/imports.scss +++ b/test/scss/imports.scss @@ -24,3 +24,6 @@ @import "~module"; /* @import "~another"; */ @import "~another"; +/* @import "~@org/style"; */ +// Should prefer `scss` +@import "~@org/style";