postcss-modules-scope
Advanced tools
Comparing version 1.0.0-beta1 to 1.0.0-beta2
@@ -9,4 +9,2 @@ 'use strict'; | ||
function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i['return']) _i['return'](); } finally { if (_d) throw _e; } } return _arr; } else { throw new TypeError('Invalid attempt to destructure non-iterable instance'); } } | ||
var _postcss = require('postcss'); | ||
@@ -95,5 +93,5 @@ | ||
var importedNames = {}; | ||
css.eachRule(function (rule) { | ||
css.walkRules(function (rule) { | ||
if (/^:import\(.+\)$/.test(rule.selector)) { | ||
rule.eachDecl(function (decl) { | ||
rule.walkDecls(function (decl) { | ||
importedNames[decl.prop] = true; | ||
@@ -105,7 +103,7 @@ }); | ||
// Find any :local classes | ||
css.eachRule(function (rule) { | ||
css.walkRules(function (rule) { | ||
var selector = _cssSelectorTokenizer2['default'].parse(rule.selector); | ||
var newSelector = traverseNode(selector); | ||
rule.selector = _cssSelectorTokenizer2['default'].stringify(newSelector); | ||
rule.eachDecl('composes', function (decl) { | ||
rule.walkDecls('composes', function (decl) { | ||
var localNames = getSingleLocalNamesForComposes(selector); | ||
@@ -128,5 +126,5 @@ var classes = decl.value.split(/\s+/); | ||
}); | ||
decl.removeSelf(); | ||
decl.remove(); | ||
}); | ||
rule.eachDecl(function (decl) { | ||
rule.walkDecls(function (decl) { | ||
var tokens = decl.value.split(/(,|'[^']*'|"[^"]*")/); | ||
@@ -149,21 +147,9 @@ tokens = tokens.map(function (token, idx) { | ||
css.eachAtRule(function (atrule) { | ||
// Find any :local keyframes and rewrite them | ||
// Find any :local keyframes | ||
css.walkAtRules(function (atrule) { | ||
if (/keyframes$/.test(atrule.name)) { | ||
var localKeyFrames = /^\s*:local\s*\((.+?)\)\s*$/.exec(atrule.params); | ||
if (localKeyFrames) { | ||
atrule.params = exportScopedName(localKeyFrames[1]); | ||
var localMatch = /^\s*:local\s*\((.+?)\)\s*$/.exec(atrule.params); | ||
if (localMatch) { | ||
atrule.params = exportScopedName(localMatch[1]); | ||
} | ||
// Find any local() custom media, export them, but leave them as they are | ||
} else if (atrule.name === 'custom-media') { | ||
var customMedia = /^\s*(--\S+)\s*(.*)$/.exec(atrule.params); | ||
if (customMedia) { | ||
var _customMedia = _slicedToArray(customMedia, 3); | ||
var breakpointName = _customMedia[1]; | ||
var mediaExpr = _customMedia[2]; | ||
exports[breakpointName] = ['"' + mediaExpr + '"']; | ||
atrule.params = '' + breakpointName + ' ' + mediaExpr; | ||
} | ||
} | ||
@@ -181,3 +167,3 @@ }); | ||
value: exports[exportedName].join(' '), | ||
before: '\n ', | ||
raws: { before: '\n ' }, | ||
_autoprefixerDisabled: true | ||
@@ -197,3 +183,2 @@ }); | ||
exports['default'] = processor; | ||
module.exports = exports['default']; | ||
/*match*/ | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss-modules-scope", | ||
"version": "1.0.0-beta1", | ||
"version": "1.0.0-beta2", | ||
"description": "A CSS Modules transform to extract export statements from local-scope classes", | ||
@@ -38,16 +38,16 @@ "main": "lib/index.js", | ||
"css-selector-tokenizer": "^0.5.0", | ||
"postcss": "^4.1.11" | ||
"postcss": "^5.0.4" | ||
}, | ||
"devDependencies": { | ||
"babel": "^5.4.7", | ||
"babel-eslint": "^3.1.9", | ||
"babel-istanbul": "^0.2.10", | ||
"babel-eslint": "^4.1.3", | ||
"babel-istanbul": "^0.3.20", | ||
"babelify": "^6.1.2", | ||
"chokidar-cli": "^0.2.1", | ||
"chokidar-cli": "^1.0.1", | ||
"codecov.io": "^0.1.2", | ||
"coveralls": "^2.11.2", | ||
"css-selector-parser": "^1.0.4", | ||
"eslint": "^0.21.2", | ||
"eslint": "^1.5.0", | ||
"mocha": "^2.2.5" | ||
} | ||
} |
@@ -28,3 +28,3 @@ # CSS Modules: Scope Locals & Extend | ||
import styles from './buttons.css' | ||
elem.innerHTML = `<button class="${buttons.continueButton}">Continue</button>` | ||
elem.innerHTML = `<button class="${styles.continueButton}">Continue</button>` | ||
``` | ||
@@ -31,0 +31,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
10337
157
+ Addedansi-regex@2.1.1(transitive)
+ Addedansi-styles@2.2.1(transitive)
+ Addedchalk@1.1.3(transitive)
+ Addedescape-string-regexp@1.0.5(transitive)
+ Addedhas-ansi@2.0.0(transitive)
+ Addedhas-flag@1.0.0(transitive)
+ Addedjs-base64@2.6.4(transitive)
+ Addedpostcss@5.2.18(transitive)
+ Addedsource-map@0.5.7(transitive)
+ Addedstrip-ansi@3.0.1(transitive)
+ Addedsupports-color@2.0.03.2.3(transitive)
- Removedamdefine@1.0.1(transitive)
- Removedes6-promise@2.3.0(transitive)
- Removedjs-base64@2.1.9(transitive)
- Removedpostcss@4.1.16(transitive)
- Removedsource-map@0.4.4(transitive)
Updatedpostcss@^5.0.4