@lwc/metadata
Advanced tools
Comparing version 2.23.0-2 to 2.23.0-3
@@ -78,6 +78,6 @@ 'use strict'; | ||
} */ | ||
const version = '2.23.0-2'; | ||
const version = '2.23.0-3'; | ||
function collectBundleMetadata(config) { | ||
// validateBundleConfig(config); | ||
const { namespace, name, type, namespaceMapping, files, enableKomaci } = config; | ||
const { namespace, name, type, namespaceMapping, files, enableKomaci, strictCSSTokenCollection, } = config; | ||
const filesResult = []; | ||
@@ -101,3 +101,6 @@ files.forEach(({ fileName, source }) => { | ||
case '.css': | ||
filesResult.push(index.collectCssMetadataFromSource(fileName, source, { namespaceMapping })); | ||
filesResult.push(index.collectCssMetadataFromSource(fileName, source, { | ||
namespaceMapping, | ||
strictCSSTokenCollection, | ||
})); | ||
break; | ||
@@ -104,0 +107,0 @@ } |
@@ -15,2 +15,3 @@ export declare type NamespaceMapping = { | ||
enableKomaci?: boolean; | ||
strictCSSTokenCollection?: boolean; | ||
} |
import { Root } from 'postcss'; | ||
import { CSSFile } from '../schema/typescript-types/style-metadata-types'; | ||
export declare function collectCustomProperties(result: CSSFile, root: Root): void; | ||
export declare function collectCustomProperties(result: CSSFile, root: Root, strict?: boolean): void; |
@@ -13,3 +13,3 @@ 'use strict'; | ||
// Copyright (c) 2022, Salesforce, Inc., | ||
function collectCustomProperties(result, root) { | ||
function collectCustomProperties(result, root, strict) { | ||
root.walkDecls((decl) => { | ||
@@ -33,10 +33,19 @@ // Early exit if the declaration doesn't includes a var() function. This avoid parsing the | ||
} | ||
const { nodes } = parsedValue; | ||
// To keep the implementation backwards compatible with metadata-v1, only process declaration | ||
// values that start with a "var". This is not comprehensive, as lwc tokens nested with in | ||
// css functions are not collected. But doing so now will break existing usages in production | ||
const declarationValueStartsWithVar = nodes.filter((n) => { | ||
return n.type === 'function' && n.value === 'var'; | ||
}); | ||
postcssValueParser__default["default"].walk(declarationValueStartsWithVar, (node) => { | ||
// Use the 'strict' flag to determine whether to comprehensively collect lwc tokens nested within | ||
// css functions. Fallback to backwards compatible behavior when 'strict' is false. | ||
let nodeWalker; | ||
if (strict) { | ||
nodeWalker = parsedValue.walk.bind(parsedValue); | ||
} | ||
else { | ||
// To keep the implementation backwards compatible with metadata-v1, only process declaration | ||
// values that start with a "var". This is not comprehensive, as lwc tokens nested with in | ||
// css functions are not collected. But doing so now will break existing usages in production | ||
const { nodes } = parsedValue; | ||
const declarationValueStartsWithVar = nodes.filter((n) => { | ||
return n.type === 'function' && n.value === 'var'; | ||
}); | ||
nodeWalker = postcssValueParser__default["default"].walk.bind(postcssValueParser__default["default"], declarationValueStartsWithVar); | ||
} | ||
nodeWalker((node) => { | ||
if (node.type !== 'function' || node.value !== 'var') { | ||
@@ -43,0 +52,0 @@ return; |
@@ -5,3 +5,4 @@ import { NamespaceMapping } from '../shared/config'; | ||
namespaceMapping: NamespaceMapping; | ||
strictCSSTokenCollection?: boolean; | ||
}): CSSFile; | ||
/** End internal API **/ |
@@ -57,9 +57,9 @@ 'use strict'; | ||
} | ||
return collectCssMetadata(fileName, root, config.namespaceMapping); | ||
return collectCssMetadata(fileName, root, config.namespaceMapping, config.strictCSSTokenCollection); | ||
} | ||
/** Internal API, optimization to reuse existing ast from compilation process **/ | ||
function collectCssMetadata(fileName, root, namespaceMapping) { | ||
function collectCssMetadata(fileName, root, namespaceMapping, strictCSSTokenCollection) { | ||
const result = generateEmptyResult(fileName); | ||
imports.collectImports(result, root, namespaceMapping); | ||
customProperties.collectCustomProperties(result, root); | ||
customProperties.collectCustomProperties(result, root, strictCSSTokenCollection); | ||
componentReferences.collectComponentReferences(result, root, namespaceMapping); | ||
@@ -66,0 +66,0 @@ return result; |
{ | ||
"name": "@lwc/metadata", | ||
"version": "2.23.0-2", | ||
"version": "2.23.0-3", | ||
"description": "Extract metadata about Lightning Web Components modules. This software is provided as-is with no support provided.", | ||
@@ -17,6 +17,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@babel/parser": "~7.17.10", | ||
"@babel/traverse": "~7.17.10", | ||
"@babel/types": "~7.17.10", | ||
"postcss": "~8.4.13", | ||
"@babel/parser": "~7.19.1", | ||
"@babel/traverse": "~7.19.1", | ||
"@babel/types": "~7.19.0", | ||
"postcss": "~8.4.16", | ||
"postcss-selector-parser": "~6.0.10", | ||
@@ -26,3 +26,3 @@ "postcss-value-parser": "~4.2.0" | ||
"peerDependencies": { | ||
"@lwc/sfdc-compiler-utils": "2.23.0-2", | ||
"@lwc/sfdc-compiler-utils": "2.23.0-3", | ||
"@lwc/errors": "~2.23.0", | ||
@@ -33,4 +33,4 @@ "@lwc/template-compiler": "~2.23.0" | ||
"@types/babel__core": "^7.1.19", | ||
"@types/babel__traverse": "^7.17.1", | ||
"@types/glob": "^7.2.0" | ||
"@types/babel__traverse": "^7.18.1", | ||
"@types/glob": "^8.0.0" | ||
}, | ||
@@ -37,0 +37,0 @@ "engines": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
322265
4905
+ Added@babel/parser@7.19.6(transitive)
+ Added@babel/traverse@7.19.6(transitive)
+ Added@babel/types@7.19.4(transitive)
+ Added@lwc/sfdc-compiler-utils@2.23.0-3(transitive)
- Removed@babel/parser@7.17.12(transitive)
- Removed@babel/traverse@7.17.12(transitive)
- Removed@babel/types@7.17.12(transitive)
- Removed@lwc/sfdc-compiler-utils@2.23.0-2(transitive)
Updated@babel/parser@~7.19.1
Updated@babel/traverse@~7.19.1
Updated@babel/types@~7.19.0
Updatedpostcss@~8.4.16