postcss-modules-values-replace
Advanced tools
Comparing version 3.3.0 to 3.4.0
25
index.js
@@ -103,5 +103,10 @@ const postcss = require('postcss'); | ||
const imports = getImports(aliases); | ||
const definitions = await walkFile(exportsPath, fromDir, imports); | ||
const definitions = await walkFile(exportsPath, fromDir, imports); | ||
return Object.assign(existingDefinitions, definitions); | ||
// Map the exported symbols to their aliased names in the importing module. | ||
Object.keys(imports).forEach((key) => { | ||
existingDefinitions[imports[key]] = definitions[key]; | ||
}); | ||
return existingDefinitions; | ||
} | ||
@@ -120,10 +125,5 @@ | ||
if (requiredDefinitions) { | ||
const validDefinitions = {}; | ||
Object.keys(requiredDefinitions).forEach((key) => { | ||
validDefinitions[requiredDefinitions[key]] = definitions[key]; | ||
}); | ||
result.messages.push({ | ||
type: INNER_PLUGIN, | ||
value: validDefinitions, | ||
value: definitions, | ||
}); | ||
@@ -162,5 +162,12 @@ | ||
const definitionCache = new Map(); | ||
async function walkFile(from, dir, requiredDefinitions) { | ||
const request = importsAsModuleRequests ? urlToRequest(from) : from; | ||
const resolvedFrom = await resolve(concordContext, dir, request); | ||
const cached = definitionCache.get(resolvedFrom); | ||
if (cached) { | ||
return cached; | ||
} | ||
const content = await readFile(resolvedFrom); | ||
@@ -174,2 +181,4 @@ const plugins = [ | ||
definitionCache.set(resolvedFrom, result.messages[0].value); | ||
return result.messages[0].value; | ||
@@ -176,0 +185,0 @@ } |
{ | ||
"name": "postcss-modules-values-replace", | ||
"version": "3.3.0", | ||
"version": "3.4.0", | ||
"description": "PostCSS plugin to work around CSS Modules values limitations", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13140
166