svelte-preprocess-cssmodules
Advanced tools
Comparing version 1.3.0 to 1.3.1
# Svelte preprocess CSS Modules, changelog | ||
## 1.3.1 (Nov 22, 2020) | ||
Add support for old version of nodes (node 8 & node 10 tested) | ||
## 1.3.0 (Nov 22, 2020) | ||
- Feature: CSS Modules from imports | ||
- Fix: *global selector* Regex is now working with an attached bracket to the selector (missing space was throwing an error) `.myclass{ }` | ||
- Dev: use of typescript, set up eslint and prettier | ||
### Feature | ||
Apply CSS Modules from imported stylesheets | ||
### Fixes | ||
*global selector* Regex is now working with an attached bracket to the selector (missing space was throwing an error) `.myclass{ }` | ||
### Plugin Development | ||
Set up typescript, eslint and prettier | ||
## 1.2.1 (Oct 31, 2020) | ||
@@ -9,0 +18,0 @@ - Fix class chaining and pseudo selector [pull request #8](https://github.com/micantoine/svelte-preprocess-cssmodules/pull/8) |
@@ -8,5 +8,5 @@ "use strict"; | ||
exports.PATTERN_IMPORT = /(?<!\/\/\s*)import\s*(?:(.+)\s+from\s+)?['|"](.+?(s?css))['|"];?/gm; | ||
exports.PATTERN_CLASS_SELECTOR = /\.(?<className>.+?(?=\W)+)(?![-_])/g; | ||
exports.PATTERN_CLASS_SELECTOR = /\.(.+?(?=\W)+)(?![-_])/g; | ||
exports.PATTERN_CLASS_DIRECTIVE = (className) => new RegExp(`<.+\\s*class:(${className})\\b`, 'gm'); | ||
exports.PATTERN_CLASSNAME = (className) => new RegExp(`\\.(${className})\\b(?![-_])`, 'gm'); | ||
exports.PATTERN_SELECTOR = (className) => new RegExp(`\\S*\\.(${className})\\b[^{\\s]*`, 'gm'); |
@@ -17,2 +17,4 @@ "use strict"; | ||
const fs_1 = __importDefault(require("fs")); | ||
const string_prototype_matchall_1 = __importDefault(require("string.prototype.matchall")); | ||
const object_fromentries_1 = __importDefault(require("object.fromentries")); | ||
const patterns_1 = require("../lib/patterns"); | ||
@@ -71,3 +73,4 @@ const lib_1 = require("../lib"); | ||
const classlist = new Map(); | ||
Array.from(fileContent.matchAll(patterns_1.PATTERN_CLASS_SELECTOR)).forEach((matchItem) => { | ||
Array.from(string_prototype_matchall_1.default(fileContent, patterns_1.PATTERN_CLASS_SELECTOR)).forEach((matchItem) => { | ||
const className = matchItem[1]; | ||
// set array from exported className | ||
@@ -78,3 +81,3 @@ const destructuredImportRegex = /\{([\w,\s]+)\}/gm; | ||
if (isDestructuredImport) { | ||
const destructuredImport = Object.values(Object.fromEntries(varName.matchAll(destructuredImportRegex)))[0]; | ||
const destructuredImport = Object.values(object_fromentries_1.default(string_prototype_matchall_1.default(varName, destructuredImportRegex)))[0].toString(); | ||
if (destructuredImport) { | ||
@@ -84,9 +87,9 @@ destructuredImportNames = destructuredImport.replace(/\s/g, '').split(','); | ||
} | ||
const camelCaseClassName = lib_1.camelCase(matchItem.groups.className); | ||
const camelCaseClassName = lib_1.camelCase(className); | ||
if (!classlist.has(camelCaseClassName) && | ||
(!isDestructuredImport || | ||
(isDestructuredImport && destructuredImportNames.includes(camelCaseClassName)))) { | ||
const interpolatedName = lib_1.createClassName(filename, content, fileContent, matchItem.groups.className, pluginOptions); | ||
const interpolatedName = lib_1.createClassName(filename, content, fileContent, className, pluginOptions); | ||
classlist.set(camelCaseClassName, interpolatedName); | ||
cssModuleList[matchItem.groups.className] = interpolatedName; | ||
cssModuleList[className] = interpolatedName; | ||
// consider use with class directive | ||
@@ -104,3 +107,3 @@ const directiveClass = isDestructuredImport | ||
} | ||
return `const ${varName} = ${JSON.stringify(Object.fromEntries(classlist))};`; | ||
return `const ${varName} = ${JSON.stringify(object_fromentries_1.default(classlist))};`; | ||
} | ||
@@ -107,0 +110,0 @@ catch (err) { |
{ | ||
"name": "svelte-preprocess-cssmodules", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Svelte preprocessor to generate CSS Modules classname on Svelte components", | ||
@@ -48,7 +48,10 @@ "keywords": [ | ||
"dependencies": { | ||
"loader-utils": "^2.0.0" | ||
"loader-utils": "^2.0.0", | ||
"object.fromentries": "^2.0.2", | ||
"string.prototype.matchall": "^4.0.3" | ||
}, | ||
"devDependencies": { | ||
"@types/cssesc": "^3.0.0", | ||
"@types/loader-utils": "^2.0.1", | ||
"@types/object.fromentries": "^2.0.0", | ||
"@types/string.prototype.matchall": "^4.0.0", | ||
"@typescript-eslint/eslint-plugin": "^4.4.0", | ||
@@ -68,3 +71,3 @@ "@typescript-eslint/parser": "^4.4.0", | ||
"peerDependencies": { | ||
"svelte": "3.20.0", | ||
"svelte": "^3.20.0", | ||
"typescript": "^4.0.0" | ||
@@ -71,0 +74,0 @@ }, |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
43965
506
0
5
15
+ Addedobject.fromentries@^2.0.2
+ Addedarray-buffer-byte-length@1.0.1(transitive)
+ Addedarraybuffer.prototype.slice@1.0.3(transitive)
+ Addedavailable-typed-arrays@1.0.7(transitive)
+ Addedcall-bind@1.0.7(transitive)
+ Addeddata-view-buffer@1.0.1(transitive)
+ Addeddata-view-byte-length@1.0.1(transitive)
+ Addeddata-view-byte-offset@1.0.0(transitive)
+ Addeddefine-data-property@1.1.4(transitive)
+ Addeddefine-properties@1.2.1(transitive)
+ Addedes-abstract@1.23.3(transitive)
+ Addedes-define-property@1.0.0(transitive)
+ Addedes-errors@1.3.0(transitive)
+ Addedes-object-atoms@1.0.0(transitive)
+ Addedes-set-tostringtag@2.0.3(transitive)
+ Addedes-to-primitive@1.2.1(transitive)
+ Addedfor-each@0.3.3(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedfunction.prototype.name@1.1.6(transitive)
+ Addedfunctions-have-names@1.2.3(transitive)
+ Addedget-intrinsic@1.2.4(transitive)
+ Addedget-symbol-description@1.0.2(transitive)
+ Addedglobalthis@1.0.4(transitive)
+ Addedgopd@1.0.1(transitive)
+ Addedhas-bigints@1.0.2(transitive)
+ Addedhas-property-descriptors@1.0.2(transitive)
+ Addedhas-proto@1.0.3(transitive)
+ Addedhas-symbols@1.0.3(transitive)
+ Addedhas-tostringtag@1.0.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedinternal-slot@1.0.7(transitive)
+ Addedis-array-buffer@3.0.4(transitive)
+ Addedis-bigint@1.0.4(transitive)
+ Addedis-boolean-object@1.1.2(transitive)
+ Addedis-callable@1.2.7(transitive)
+ Addedis-data-view@1.0.1(transitive)
+ Addedis-date-object@1.0.5(transitive)
+ Addedis-negative-zero@2.0.3(transitive)
+ Addedis-number-object@1.0.7(transitive)
+ Addedis-regex@1.1.4(transitive)
+ Addedis-shared-array-buffer@1.0.3(transitive)
+ Addedis-string@1.0.7(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedis-typed-array@1.1.13(transitive)
+ Addedis-weakref@1.0.2(transitive)
+ Addedisarray@2.0.5(transitive)
+ Addedobject-inspect@1.13.3(transitive)
+ Addedobject-keys@1.1.1(transitive)
+ Addedobject.assign@4.1.5(transitive)
+ Addedobject.fromentries@2.0.8(transitive)
+ Addedpossible-typed-array-names@1.0.0(transitive)
+ Addedregexp.prototype.flags@1.5.3(transitive)
+ Addedsafe-array-concat@1.1.2(transitive)
+ Addedsafe-regex-test@1.0.3(transitive)
+ Addedset-function-length@1.2.2(transitive)
+ Addedset-function-name@2.0.2(transitive)
+ Addedside-channel@1.0.6(transitive)
+ Addedstring.prototype.matchall@4.0.11(transitive)
+ Addedstring.prototype.trim@1.2.9(transitive)
+ Addedstring.prototype.trimend@1.0.8(transitive)
+ Addedstring.prototype.trimstart@1.0.8(transitive)
+ Addedsvelte@3.59.2(transitive)
+ Addedtyped-array-buffer@1.0.2(transitive)
+ Addedtyped-array-byte-length@1.0.1(transitive)
+ Addedtyped-array-byte-offset@1.0.2(transitive)
+ Addedtyped-array-length@1.0.6(transitive)
+ Addedunbox-primitive@1.0.2(transitive)
+ Addedwhich-boxed-primitive@1.0.2(transitive)
+ Addedwhich-typed-array@1.1.15(transitive)
- Removedsvelte@3.20.0(transitive)