Created
December 12, 2024 10:49
-
-
Save vilindberg/2c81dc7e2091ede23f883ec32ab56247 to your computer and use it in GitHub Desktop.
typed-scss-modules+8.0.1.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js | |
index 6c728e5..23fc66a 100644 | |
--- a/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js | |
+++ b/node_modules/typed-scss-modules/dist/lib/sass/file-to-class-names.js | |
@@ -30,7 +30,7 @@ const NAME_FORMATS_WITH_TRANSFORMER = Object.keys(transformersMap); | |
exports.NAME_FORMATS = [...NAME_FORMATS_WITH_TRANSFORMER, "all"]; | |
exports.nameFormatDefault = "camel"; | |
const fileToClassNames = (file, { additionalData, includePaths = [], nameFormat: rawNameFormat, implementation, aliases, aliasPrefixes, importer, } = {}) => __awaiter(void 0, void 0, void 0, function* () { | |
- const { renderSync } = (0, implementations_1.getImplementation)(implementation); | |
+ const { compile } = (0, implementations_1.getImplementation)(implementation); | |
const nameFormat = (typeof rawNameFormat === "string" ? [rawNameFormat] : rawNameFormat); | |
const nameFormats = nameFormat | |
? nameFormat.includes("all") | |
@@ -38,11 +38,10 @@ const fileToClassNames = (file, { additionalData, includePaths = [], nameFormat: | |
: nameFormat | |
: [exports.nameFormatDefault]; | |
const data = fs_1.default.readFileSync(file).toString(); | |
- const result = renderSync({ | |
- file, | |
+ const result = compile(file, { | |
data: additionalData ? `${additionalData}\n${data}` : data, | |
- includePaths, | |
- importer: (0, importer_1.customImporters)({ aliases, aliasPrefixes, importer }), | |
+ loadPaths: includePaths, | |
+ importers: (0, importer_1.customImporters)({ aliases, aliasPrefixes, importer }), | |
}); | |
const classNames = yield (0, source_to_class_names_1.sourceToClassNames)(result.css, file); | |
const transformers = nameFormats.map((item) => transformersMap[item]); | |
diff --git a/node_modules/typed-scss-modules/dist/lib/sass/importer.js b/node_modules/typed-scss-modules/dist/lib/sass/importer.js | |
index 86e14a7..f51115c 100644 | |
--- a/node_modules/typed-scss-modules/dist/lib/sass/importer.js | |
+++ b/node_modules/typed-scss-modules/dist/lib/sass/importer.js | |
@@ -1,21 +1,18 @@ | |
"use strict"; | |
Object.defineProperty(exports, "__esModule", { value: true }); | |
exports.customImporters = exports.aliasImporter = void 0; | |
+const {pathToFileURL} = require('url'); | |
/** | |
* Construct a SASS importer to create aliases for imports. | |
*/ | |
const aliasImporter = ({ aliases, aliasPrefixes }) => (url) => { | |
if (url in aliases) { | |
const file = aliases[url]; | |
- return { | |
- file, | |
- }; | |
+ return new URL(file, pathToFileURL('node_modules')) | |
} | |
const prefixMatch = Object.keys(aliasPrefixes).find((prefix) => url.startsWith(prefix)); | |
if (prefixMatch) { | |
- return { | |
- file: aliasPrefixes[prefixMatch] + url.substr(prefixMatch.length), | |
- }; | |
+ return new URL(aliasPrefixes[prefixMatch] + url.substr(prefixMatch.length), pathToFileURL('node_modules')) | |
} | |
return null; | |
}; | |
@@ -27,7 +24,8 @@ exports.aliasImporter = aliasImporter; | |
* - Given custom SASS importer(s), append to the list of importers. | |
*/ | |
const customImporters = ({ aliases = {}, aliasPrefixes = {}, importer, }) => { | |
- const importers = [(0, exports.aliasImporter)({ aliases, aliasPrefixes })]; | |
+ const findFileUrl = (0, exports.aliasImporter)({ aliases, aliasPrefixes }) | |
+ const importers = [{ findFileUrl }] | |
if (typeof importer === "function") { | |
importers.push(importer); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment