@mozaic-ds/postcss-media-queries-packer-on-demand
Advanced tools
Comparing version 1.0.1 to 1.11.0
@@ -6,2 +6,10 @@ # Change Log | ||
# [1.11.0](https://github.com/adeo/mozaic-design-system/compare/v1.10.0...v1.11.0) (2021-06-09) | ||
**Note:** Version bump only for package @mozaic-ds/postcss-media-queries-packer-on-demand | ||
## [1.0.1](https://github.com/adeo/mozaic-design-system/compare/v1.0.1-beta.22...v1.0.1) (2020-12-09) | ||
@@ -8,0 +16,0 @@ |
97
index.js
@@ -9,9 +9,9 @@ const postcss = require('postcss') | ||
const parseQueryList = queryList => { | ||
const parseQueryList = (queryList) => { | ||
const queries = [] | ||
list.comma(queryList).forEach(query => { | ||
list.comma(queryList).forEach((query) => { | ||
const expressions = {} | ||
list.space(query).forEach(expression => { | ||
list.space(query).forEach((expression) => { | ||
let newExpression = expression.toLowerCase() | ||
@@ -44,3 +44,3 @@ | ||
const inspectLength = length => { | ||
const inspectLength = (length) => { | ||
if (length === '0') { | ||
@@ -86,6 +86,6 @@ return 0 | ||
const pickMinimumMinWidth = expressions => { | ||
const pickMinimumMinWidth = (expressions) => { | ||
const minWidths = [] | ||
expressions.forEach(feature => { | ||
expressions.forEach((feature) => { | ||
let minWidth = feature['min-width'] | ||
@@ -114,3 +114,3 @@ | ||
queryLists.forEach(queryList => { | ||
queryLists.forEach((queryList) => { | ||
mapQueryLists.push(parseQueryList(queryList)) | ||
@@ -125,3 +125,3 @@ }) | ||
.sort((a, b) => a.value - b.value) | ||
.map(e => queryLists[e.index]) | ||
.map((e) => queryLists[e.index]) | ||
} | ||
@@ -140,3 +140,3 @@ | ||
node.each(rule => { | ||
node.each((rule) => { | ||
newAtRule.append(rule) | ||
@@ -153,3 +153,3 @@ }) | ||
if (typeof past === 'object') { | ||
node.each(rule => { | ||
node.each((rule) => { | ||
past.append(rule.clone()) | ||
@@ -165,42 +165,47 @@ }) | ||
module.exports = postcss.plugin( | ||
'postcss-media-queries-packer-on-demand', | ||
options => root => { | ||
const opts = { | ||
sort: false, | ||
...options, | ||
} | ||
root.each(node => { | ||
if (node.type === 'comment' && node.text === 'mqp:start') { | ||
startPacking = true | ||
node.remove() | ||
} | ||
module.exports = (options = {}) => { | ||
const opts = { | ||
sort: false, | ||
...options, | ||
} | ||
if (node.type === 'comment' && node.text === 'mqp:end') { | ||
startPacking = false | ||
} | ||
return { | ||
postcssPlugin: 'postcss-media-queries-packer-on-demand', | ||
Once(root) { | ||
root.each((node) => { | ||
if (node.type === 'comment' && node.text === 'mqp:start') { | ||
startPacking = true | ||
node.remove() | ||
} | ||
if ( | ||
node.type === 'atrule' && | ||
node.name === 'media' && | ||
startPacking === true | ||
) { | ||
addToAtRules(node) | ||
} | ||
if (node.type === 'comment' && node.text === 'mqp:end') { | ||
startPacking = false | ||
} | ||
if ( | ||
node.type === 'comment' && | ||
node.text === 'mqp:end' && | ||
startPacking === false | ||
) { | ||
sortQueryLists(queryLists, opts.sort).forEach(queryList => { | ||
node.before(queries[queryList]) | ||
}) | ||
if ( | ||
node.type === 'atrule' && | ||
node.name === 'media' && | ||
startPacking === true | ||
) { | ||
addToAtRules(node) | ||
} | ||
node.remove() | ||
queries = {} | ||
queryLists = [] | ||
} | ||
}) | ||
if ( | ||
node.type === 'comment' && | ||
node.text === 'mqp:end' && | ||
startPacking === false | ||
) { | ||
sortQueryLists(queryLists, opts.sort).forEach((queryList) => { | ||
node.before(queries[queryList]) | ||
}) | ||
node.remove() | ||
queries = {} | ||
queryLists = [] | ||
} | ||
}) | ||
}, | ||
} | ||
) | ||
} | ||
module.exports.postcss = true |
{ | ||
"name": "@mozaic-ds/postcss-media-queries-packer-on-demand", | ||
"version": "1.0.1", | ||
"version": "1.11.0", | ||
"description": "PostCSS plugin that group media queries on demand", | ||
"keywords": [ | ||
"css", | ||
"postcss", | ||
"css", | ||
"postcss-plugin", | ||
@@ -17,11 +17,9 @@ "media-queries" | ||
"license": "MIT", | ||
"dependencies": { | ||
"postcss": "^7.0.18" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-transform-runtime": "^7.6.2", | ||
"jest": "^24.9.0" | ||
"@babel/plugin-transform-runtime": "^7.14.3", | ||
"jest": "^27.0.3", | ||
"postcss": "^8.3.0" | ||
}, | ||
"engines": { | ||
"node": ">=8.0.0" | ||
"node": ">=12" | ||
}, | ||
@@ -28,0 +26,0 @@ "jest": { |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
10283
0
387
1
3
- Removedpostcss@^7.0.18
- Removedpicocolors@0.2.1(transitive)
- Removedpostcss@7.0.39(transitive)
- Removedsource-map@0.6.1(transitive)