Skip to content

Commit

Permalink
fix: remove exported importer function
Browse files Browse the repository at this point in the history
As discussed in code review, this is more the responsibility of the
consumer, as `sass-loader/dist/utils.js` already exports all the
necessary functionality.
  • Loading branch information
vvanpo committed Aug 6, 2020
1 parent b0f9b9a commit c649db0
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 213 deletions.
1 change: 0 additions & 1 deletion package.json
Expand Up @@ -77,7 +77,6 @@
"css-loader": "^4.2.0",
"del": "^5.1.0",
"del-cli": "^3.0.1",
"enhanced-resolve": "^4.3.0",
"eslint": "^7.6.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.21.2",
Expand Down
73 changes: 0 additions & 73 deletions src/importer.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/utils.js
Expand Up @@ -24,6 +24,11 @@ function getDefaultSassImplementation() {
return require(sassImplPkg);
}

/**
* @public
* This function is not Webpack-specific and can be used by tools wishing to
* mimic `sass-loader`'s behaviour, so its signature should not be changed.
*/
function getSassImplementation(implementation) {
let resolvedImplementation = implementation;

Expand Down Expand Up @@ -273,6 +278,22 @@ const isSpecialModuleImport = /^~[^/]+$/;
// `[drive_letter]:\` + `\\[server]\[sharename]\`
const isNativeWin32Path = /^[a-zA-Z]:[/\\]|^\\\\/i;

/**
* @public
* Create the resolve function used in the custom Sass importer.
*
* Can be used by external tools to mimic how `sass-loader` works, for example
* in a Jest transform. Such usages will want to wrap `resolve.create` from
* [`enhanced-resolve`]{@link https://github.com/webpack/enhanced-resolve} to
* pass as the `resolverFactory` argument.
*
* @param {Object} implementation - The imported Sass implementation, both
* `sass` (Dart Sass) and `node-sass` are supported.
* @param {Function} resolverFactory - A factory function for creating a Webpack
* resolver.
* @param {string[]} [includePaths] - The list of include paths passed to Sass.
* @param {boolean} [rootContext] - The configured Webpack root context.
*/
function getWebpackResolver(
implementation,
resolverFactory,
Expand Down
95 changes: 0 additions & 95 deletions test/__snapshots__/importer.test.js.snap

This file was deleted.

44 changes: 0 additions & 44 deletions test/importer.test.js

This file was deleted.

0 comments on commit c649db0

Please sign in to comment.