postcss-modules-values-replace
Advanced tools
Comparing version 1.2.1 to 2.0.0
31
index.js
@@ -1,6 +0,6 @@ | ||
import postcss from 'postcss'; | ||
import path from 'path'; | ||
import promisify from 'es6-promisify'; | ||
import { CachedInputFileSystem, NodeJsInputFileSystem, ResolverFactory } from 'enhanced-resolve'; | ||
import replaceSymbols, { replaceAll } from 'icss-replace-symbols'; | ||
const postcss = require('postcss'); | ||
const path = require('path'); | ||
const promisify = require('es6-promisify'); | ||
const { CachedInputFileSystem, NodeJsInputFileSystem, ResolverFactory } = require('enhanced-resolve'); | ||
const { replaceValueSymbols } = require('icss-utils'); | ||
@@ -25,5 +25,5 @@ const matchImports = /^(.+?|\([\s\S]+?\))\s+from\s+("[^"]*"|'[^']*'|[\w-]+)$/; | ||
while (matches = matchValueDefinition.exec(atRule.params)) { | ||
const [/* match*/, requiredName, middle, value, end] = matches; | ||
const [/* match */, requiredName, middle, value, end] = matches; | ||
// Add to the definitions, knowing that values can refer to each other | ||
definition[requiredName] = replaceAll(existingDefinitions, value); | ||
definition[requiredName] = replaceValueSymbols(value, existingDefinitions); | ||
@@ -46,3 +46,3 @@ if (!requiredDefinitions) { | ||
if (tokens) { | ||
const [/* match*/, theirName, myName = theirName] = tokens; | ||
const [/* match */, theirName, myName = theirName] = tokens; | ||
imports[theirName] = myName; | ||
@@ -71,6 +71,7 @@ } else { | ||
// eslint-disable-next-line prefer-const | ||
let [/* match*/, aliases, pathString] = matches; | ||
let [/* match */, aliases, pathString] = matches; | ||
// We can use constants for path names | ||
if (existingDefinitions[pathString]) { | ||
// eslint-disable-next-line prefer-destructuring | ||
pathString = existingDefinitions[pathString]; | ||
@@ -140,3 +141,9 @@ } | ||
}); | ||
replaceSymbols(root, definitions); | ||
root.walk((node) => { | ||
if (node.type === 'decl') { | ||
// eslint-disable-next-line no-param-reassign | ||
node.value = replaceValueSymbols(node.value, definitions); | ||
} | ||
}); | ||
}; | ||
@@ -146,4 +153,4 @@ | ||
const plugin = postcss.plugin(PLUGIN, factory); | ||
module.exports = plugin; // support old good require | ||
export default plugin; | ||
module.exports = plugin; | ||
exports.default = plugin; | ||
{ | ||
"name": "postcss-modules-values-replace", | ||
"version": "1.2.1", | ||
"version": "2.0.0", | ||
"description": "PostCSS plugin to work around CSS Modules values limitations", | ||
@@ -11,6 +11,4 @@ "keywords": [ | ||
], | ||
"main": "lib", | ||
"files": [ | ||
"index.js", | ||
"lib" | ||
"index.js" | ||
], | ||
@@ -25,32 +23,18 @@ "author": "Eugene Datsky <eugene@datsky.ru>", | ||
"dependencies": { | ||
"@ava/babel-preset-stage-4": "^1.0.0", | ||
"enhanced-resolve": "^3.1.0", | ||
"es6-promisify": "^5.0.0", | ||
"icss-replace-symbols": "^1.0.2", | ||
"postcss": "^5.2.5" | ||
"icss-utils": "^3.0.1", | ||
"postcss": "^6.0.1" | ||
}, | ||
"devDependencies": { | ||
"ava": "^0.18.1", | ||
"babel-cli": "^6.18.0", | ||
"babel-core": "^6.18.2", | ||
"babel-polyfill": "^6.16.0", | ||
"babel-register": "^6.22.0", | ||
"eslint": "^3.9.0", | ||
"eslint-config-airbnb-base": "^10.0.1", | ||
"eslint-plugin-import": "^2.2.0" | ||
"ava": "^0.24.0", | ||
"eslint": "^4.15.0", | ||
"eslint-config-airbnb-base": "^12.1.0", | ||
"eslint-plugin-import": "^2.5.0" | ||
}, | ||
"scripts": { | ||
"build": "babel --out-dir lib index.js", | ||
"lint": "eslint *.js", | ||
"prepublish": "npm run lint && npm run build", | ||
"prepublish": "npm test", | ||
"test": "npm run lint && ava" | ||
}, | ||
"ava": { | ||
"require": "babel-register" | ||
}, | ||
"babel": { | ||
"presets": [ | ||
"@ava/stage-4" | ||
] | ||
}, | ||
"eslintConfig": { | ||
@@ -57,0 +41,0 @@ "extends": "eslint-config-airbnb-base" |
@@ -75,3 +75,3 @@ # PostCSS Modules Values Replace [![Build Status][ci-img]][ci] | ||
require('postcss-modules-values-replace')({fs: ctx.webpack._compiler.inputFileSystem}), | ||
require('postcss-color-function'), | ||
require('postcss-calc'), | ||
] | ||
@@ -157,3 +157,4 @@ }); | ||
[postcss-color-function] and other plugins probably won't work *inside* **@value** as they don't traverse media queries. | ||
[postcss-calc] and [postcss-color-function] are known to work *inside* **@value** as they traverse media queries. | ||
Experience with other plugins may differ if they ignore media queries. | ||
@@ -160,0 +161,0 @@ ### Extracting values for programmatic use |
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
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
4
4
176
10283
3
116
1
+ Addedicss-utils@^3.0.1
+ Addedansi-styles@3.2.1(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedicss-utils@3.0.1(transitive)
+ Addedpostcss@6.0.23(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsupports-color@5.5.0(transitive)
- Removed@ava/babel-preset-stage-4@^1.0.0
- Removedicss-replace-symbols@^1.0.2
- Removed@ava/babel-preset-stage-4@1.1.0(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.1(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-builder-binary-assignment-operator-visitor@6.24.1(transitive)
- Removedbabel-helper-call-delegate@6.24.1(transitive)
- Removedbabel-helper-explode-assignable-expression@6.24.1(transitive)
- Removedbabel-helper-function-name@6.24.1(transitive)
- Removedbabel-helper-get-function-arity@6.24.1(transitive)
- Removedbabel-helper-hoist-variables@6.24.1(transitive)
- Removedbabel-helper-regex@6.26.0(transitive)
- Removedbabel-helper-remap-async-to-generator@6.24.1(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-check-es2015-constants@6.22.0(transitive)
- Removedbabel-plugin-syntax-async-functions@6.13.0(transitive)
- Removedbabel-plugin-syntax-exponentiation-operator@6.13.0(transitive)
- Removedbabel-plugin-syntax-trailing-function-commas@6.22.0(transitive)
- Removedbabel-plugin-transform-async-to-generator@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-destructuring@6.23.0(transitive)
- Removedbabel-plugin-transform-es2015-function-name@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-modules-commonjs@6.26.2(transitive)
- Removedbabel-plugin-transform-es2015-parameters@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-spread@6.22.0(transitive)
- Removedbabel-plugin-transform-es2015-sticky-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-es2015-unicode-regex@6.24.1(transitive)
- Removedbabel-plugin-transform-exponentiation-operator@6.24.1(transitive)
- Removedbabel-plugin-transform-strict-mode@6.24.1(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedchalk@1.1.3(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removedesutils@2.0.3(transitive)
- Removedglobals@9.18.0(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@1.0.0(transitive)
- Removedicss-replace-symbols@1.1.0(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedjs-base64@2.6.4(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedjsesc@0.5.0(transitive)
- Removedlodash@4.17.21(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmd5-hex@1.3.0(transitive)
- Removedmd5-o-matic@0.1.1(transitive)
- Removedms@2.0.0(transitive)
- Removedpackage-hash@1.2.0(transitive)
- Removedpostcss@5.2.18(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregexpu-core@2.0.0(transitive)
- Removedregjsgen@0.2.0(transitive)
- Removedregjsparser@0.1.5(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.03.2.3(transitive)
- Removedto-fast-properties@1.0.3(transitive)
Updatedpostcss@^6.0.1