Skip to content

Commit

Permalink
fix: logic for custom importers
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Jan 11, 2021
1 parent 3ea0d30 commit 111c247
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 73 deletions.
7 changes: 6 additions & 1 deletion src/index.js
Expand Up @@ -81,7 +81,12 @@ async function loader(content) {
}

result.stats.includedFiles.forEach((includedFile) => {
this.addDependency(path.normalize(includedFile));
const normalizedIncludedFile = path.normalize(includedFile);

// Custom `importer` can return only `contents` so includedFile will be relative
if (path.isAbsolute(normalizedIncludedFile)) {
this.addDependency(normalizedIncludedFile);
}
});

callback(null, result.css.toString(), map);
Expand Down
84 changes: 12 additions & 72 deletions test/__snapshots__/sassOptions-option.test.js.snap
Expand Up @@ -2012,45 +2012,25 @@ exports[`sassOptions option should work with the "importer" as a array of functi

exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (sass): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (scss): css 1`] = `""`;

exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (scss): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a array of functions option (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (sass): css 1`] = `""`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (sass): errors 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (sass): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (scss): css 1`] = `""`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (scss): errors 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (scss): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a array of functions option (node-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): css 1`] = `""`;

Expand All @@ -2064,19 +2044,9 @@ exports[`sassOptions option should work with the "importer" as a single function

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): errors 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): warnings 2`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (sass): warnings 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): css 1`] = `""`;

Expand All @@ -2090,19 +2060,9 @@ exports[`sassOptions option should work with the "importer" as a single function

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): errors 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): warnings 2`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (dart-sass) (scss): warnings 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): css 1`] = `""`;

Expand All @@ -2116,19 +2076,9 @@ exports[`sassOptions option should work with the "importer" as a single function

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): errors 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): warnings 2`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (sass): warnings 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): css 1`] = `""`;

Expand All @@ -2142,19 +2092,9 @@ exports[`sassOptions option should work with the "importer" as a single function

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): errors 2`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): warnings 1`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): warnings 1`] = `Array []`;

exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): warnings 2`] = `
Array [
"InvalidDependenciesModuleWarning: Invalid dependencies have been reported by plugins or loaders for this module. All reported dependencies need to be absolute paths.
Invalid dependencies may lead to broken watching and caching.",
]
`;
exports[`sassOptions option should work with the "importer" as a single function option (node-sass) (scss): warnings 2`] = `Array []`;

exports[`sassOptions option should work with the "includePaths" option (dart-sass) (sass): css 1`] = `
".include-path-module {
Expand Down

0 comments on commit 111c247

Please sign in to comment.