Skip to content

Commit

Permalink
Update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ai committed Sep 15, 2020
1 parent 52fa950 commit ea73628
Show file tree
Hide file tree
Showing 8 changed files with 787 additions and 695 deletions.
190 changes: 190 additions & 0 deletions apis.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
let { readFileSync, readFile } = require('fs')
let { promisify } = require('util')
let { join } = require('path')
let postcss = require('postcss')

let readFileAsync = promisify(readFile)
let example = join(__dirname, 'cache', 'bootstrap.css')
let css = readFileSync(example).toString()

for (let i = 0; i < 4; i++) {
css = css + css
}

let walkColorPlugin = () => {
return {
postcssPlugin: 'walkColorPlugin',
Root (root) {
root.walkDecls('color', decl => {
decl.value = 'black'
})
}
}
}
walkColorPlugin.postcss = true

let walkWebkitPlugin = () => {
return {
postcssPlugin: 'walkWebkitPlugin',
Root (root) {
root.walkDecls(/^webkit-*/, decl => {
decl.remove()
})
}
}
}
walkWebkitPlugin.postcss = true

let walkSyncPlugin = () => {
return {
postcssPlugin: 'walkSyncPlugin',
Root (root) {
root.walkAtRules(node => {
readFileSync(example)
node.remove()
})
}
}
}
walkSyncPlugin.postcss = true

let walkAsyncPlugin = () => {
return {
postcssPlugin: 'walkAsyncPlugin',
async Root (root) {
let atRules = []
root.walkAtRules(atRule => {
atRules.push(atRule)
atRule.remove()
})
for (let i = 0; i < atRules.length; i++) {
await readFileAsync(example)
}
}
}
}
walkAsyncPlugin.postcss = true

let visitColorPlugin = () => {
return {
postcssPlugin: 'visitColorPlugin',
Declaration: {
color: decl => {
decl.value = 'black'
}
}
}
}
visitColorPlugin.postcss = true

let visitWebkitPlugin = () => {
return {
postcssPlugin: 'visitWebkitPlugin',
Declaration (decl) {
if (decl.prop.startsWith('-webkit-')) {
decl.remove()
}
}
}
}
visitWebkitPlugin.postcss = true

let visitSyncPlugin = () => {
return {
postcssPlugin: 'visitSyncPlugin',
AtRule (node) {
readFileSync(example)
node.remove()
}
}
}
visitSyncPlugin.postcss = true

let visitAsyncPlugin = () => {
return {
postcssPlugin: 'visitAsyncPlugin',
async AtRule (node) {
await readFileAsync(example)
node.remove()
}
}
}
visitAsyncPlugin.postcss = true

function multiple (count, value) {
return Array(count).fill(value)
}

let walkerSync = postcss(
multiple(10, walkColorPlugin)
.concat(multiple(10, walkWebkitPlugin))
.concat([walkSyncPlugin])
)
let walkerAsync = postcss(
multiple(10, walkColorPlugin)
.concat(multiple(10, walkWebkitPlugin))
.concat([walkAsyncPlugin])
)
let visiterSync = postcss(
multiple(10, visitColorPlugin)
.concat(multiple(10, visitWebkitPlugin))
.concat([visitSyncPlugin])
)
let visiterAsync = postcss(
multiple(10, visitColorPlugin)
.concat(multiple(10, visitWebkitPlugin))
.concat([visitAsyncPlugin])
)

module.exports = {
name: 'API',
maxTime: 15,
tests: [
{
name: 'Walk sync API',
defer: true,
fn: done => {
walkerSync.process(css, { from: example, map: false }).css
walkerSync.process(css, { from: example, map: false }).css
walkerSync.process(css, { from: example, map: false }).css
done.resolve()
}
},
{
name: 'Visitor sync API',
defer: true,
fn: done => {
visiterSync.process(css, { from: example, map: false }).css
visiterSync.process(css, { from: example, map: false }).css
visiterSync.process(css, { from: example, map: false }).css
done.resolve()
}
},
{
name: 'Walk async API',
defer: true,
fn: done => {
Promise.all([
walkerAsync.process(css, { from: example, map: false }),
walkerAsync.process(css, { from: example, map: false }),
walkerAsync.process(css, { from: example, map: false })
]).then(() => {
done.resolve()
})
}
},
{
name: 'Visitor async API',
defer: true,
fn: done => {
Promise.all([
visiterAsync.process(css, { from: example, map: false }),
visiterAsync.process(css, { from: example, map: false }),
visiterAsync.process(css, { from: example, map: false })
]).then(() => {
done.resolve()
})
}
}
]
}
22 changes: 16 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,31 @@ gulp.task('bootstrap', async () => {
})
})

for (let name of ['preprocessors', 'parsers', 'prefixers', 'tokenizers']) {
for (let name of [
'preprocessors',
'parsers',
'prefixers',
'tokenizers',
'apis'
]) {
gulp.task(
name,
gulp.series('bootstrap', () => {
let bench = require('gulp-bench')
let summary = require('gulp-bench-summary')
return gulp
.src(`./${name}.js`, { read: false })
.pipe(bench())
.pipe(summary(name === 'prefixers' ? 'Autoprefixer' : 'PostCSS'))
let benchmark = gulp.src(`./${name}.js`, { read: false }).pipe(bench())
if (name === 'apis') {
return benchmark
} else {
return benchmark.pipe(
summary(name === 'prefixers' ? 'Autoprefixer' : 'PostCSS')
)
}
})
)
}

gulp.task(
'default',
gulp.series('preprocessors', 'parsers', 'prefixers', 'tokenizers')
gulp.series('preprocessors', 'parsers', 'prefixers', 'tokenizers', 'apis')
)
31 changes: 14 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"test": "eslint . && gulp"
},
"dependencies": {
"autoprefixer": "^9.8.6",
"autoprefixer": "^10.0.0",
"css-tree": "^1.0.0-alpha14",
"cssom": "^0.4.4",
"fs-extra": "^9.0.1",
Expand All @@ -18,12 +18,11 @@
"myth": "^1.5.0",
"node-sass": "^4.14.1",
"parserlib": "^1.1.1",
"postcss": "^7.0.32",
"postcss-calc": "^7.0.3",
"postcss-mixins": "^6.2.3",
"postcss-nested": "^4.2.3",
"postcss": "^8.0.3",
"postcss-mixins": "^7.0.0",
"postcss-nested": "^5.0.0",
"postcss-selector-parser": "^6.0.2",
"postcss-simple-vars": "^5.0.2",
"postcss-simple-vars": "^6.0.0",
"postcss-value-parser": "^4.1.0",
"rework": "^1.0.1",
"sass": "^1.26.10",
Expand All @@ -32,29 +31,26 @@
"stylecow-plugin-nested-rules": "^5.0.1",
"stylecow-plugin-prefixes": "^6.0.5",
"stylecow-plugin-variables": "^5.1.4",
"stylis": "^3.5.0",
"stylis-calc": "^0.0.1",
"stylis-custom-properties": "^0.0.4",
"stylis-mixin": "^0.0.1",
"stylis": "^4.0.3",
"through2": "^4.0.2"
},
"devDependencies": {
"@logux/eslint-config": "^40.0.1",
"@logux/eslint-config": "^40.0.4",
"@logux/sharec-config": "^0.7.4",
"eslint": "^7.6.0",
"eslint": "^7.9.0",
"eslint-config-standard": "^14.1.1",
"eslint-plugin-es5": "^1.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jest": "^23.20.0",
"eslint-plugin-jest": "^24.0.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prefer-let": "^1.0.2",
"eslint-plugin-prettierx": "^0.12.1",
"eslint-plugin-prefer-let": "^1.1.0",
"eslint-plugin-prettierx": "^0.14.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-security": "^1.4.0",
"eslint-plugin-standard": "^4.0.1",
"eslint-plugin-unicorn": "^21.0.0",
"husky": "^4.2.5",
"lint-staged": "^10.2.11"
"husky": "^4.3.0",
"lint-staged": "^10.3.0"
},
"engines": {
"node": ">=10.0.0"
Expand All @@ -63,6 +59,7 @@
"extends": "@logux/eslint-config",
"rules": {
"security/detect-non-literal-require": "off",
"no-unused-expressions": "off",
"node/global-require": "off"
}
},
Expand Down
10 changes: 4 additions & 6 deletions parsers.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ let csstree = require('css-tree')
let postcss = require('postcss')
let rework = require('rework')
let mensch = require('mensch')
let Stylis = require('stylis')
let stylis = require('stylis')
let CSSOM = require('cssom')

let example = join(__dirname, 'cache', 'bootstrap.css')
let css = readFileSync(example).toString()

let stylis = new Stylis()

module.exports = {
name: 'Bootstrap',
name: 'Parsers',
maxTime: 15,
tests: [
{
Expand Down Expand Up @@ -112,7 +110,7 @@ module.exports = {
{
name: 'Stylis',
fn: () => {
stylis('', css)
stylis.compile(css)
}
}
]
Expand All @@ -122,7 +120,7 @@ let devPath = join(__dirname, '../postcss/lib/postcss.js')
if (existsSync(devPath)) {
let devPostcss = require(devPath)
module.exports.tests.splice(1, 0, {
name: 'PostCSS dev',
name: 'Next PostCSS',
defer: true,
fn: done => {
devPostcss.parse(css, { from: example }).toResult()
Expand Down
14 changes: 1 addition & 13 deletions prefixers.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ let autoprefixer = require('autoprefixer')
let stylecow = require('stylecow-core')
let { join } = require('path')
let postcss = require('postcss')
let Stylis = require('stylis')

let example = join(__dirname, 'cache', 'bootstrap.css')
let origin = readFileSync(example).toString()
Expand All @@ -27,11 +26,8 @@ let stylecowOut = new stylecow.Coder()
let stylecower = new stylecow.Tasks()
stylecower.use(stylecowPrefixes)

// Stylis
let stylis = new Stylis()

module.exports = {
name: 'Bootstrap',
name: 'Prefixers',
maxTime: 15,
tests: [
{
Expand All @@ -57,14 +53,6 @@ module.exports = {
stylecowOut.run(code)
done.resolve()
}
},
{
name: 'Stylis',
defer: true,
fn: done => {
stylis('', css)
done.resolve()
}
}
]
}
Expand Down
Loading

0 comments on commit ea73628

Please sign in to comment.