Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

svelte-preprocess-cssmodules

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-preprocess-cssmodules - npm Package Compare versions

Comparing version 1.3.0 to 1.3.1

15

CHANGELOG.md
# 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)

2

dist/lib/patterns.js

@@ -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 @@ },

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc