@kaliber/build 0.0.146 → 0.0.147
Sign up to get free protection for your applications and to get access to all the features.
- package/.stylelintrc +8 -2
- package/lib/build.js +18 -4
- package/lib/serve.js +1 -1
- package/package.json +2 -2
- package/stylelint-plugins/rules/layout-related-properties/index.js +3 -3
- package/stylelint-plugins/rules/parent-child-policy/index.js +3 -3
- package/stylelint-plugins/rules/parent-child-policy/test.js +13 -0
- package/webpack-plugins/copy-unused-files-plugin.js +15 -21
- package/webpack-plugins/config-loader-plugin.js +0 -22
package/.stylelintrc
CHANGED
@@ -195,7 +195,7 @@
|
|
195
195
|
],
|
196
196
|
"string-no-newline": true,
|
197
197
|
"unit-case": "lower",
|
198
|
-
"unit-no-unknown":
|
198
|
+
"unit-no-unknown": null,
|
199
199
|
"unit-whitelist": [
|
200
200
|
"em",
|
201
201
|
"rem",
|
@@ -210,7 +210,13 @@
|
|
210
210
|
"vmax",
|
211
211
|
"deg",
|
212
212
|
"turn",
|
213
|
-
"fr"
|
213
|
+
"fr",
|
214
|
+
"dvh",
|
215
|
+
"dvw",
|
216
|
+
"svh",
|
217
|
+
"svw",
|
218
|
+
"lvh",
|
219
|
+
"lvw"
|
214
220
|
],
|
215
221
|
"value-list-comma-newline-after": "always-multi-line",
|
216
222
|
"value-list-comma-space-after": "always-single-line",
|
package/lib/build.js
CHANGED
@@ -22,7 +22,6 @@ const walkSync = require('walk-sync')
|
|
22
22
|
const webpack = require('webpack')
|
23
23
|
|
24
24
|
const chunkManifestPlugin = require('../webpack-plugins/chunk-manifest-plugin')
|
25
|
-
const configLoaderPlugin = require('../webpack-plugins/config-loader-plugin')
|
26
25
|
const copyUnusedFilesPlugin = require('../webpack-plugins/copy-unused-files-plugin')
|
27
26
|
const hotCssReplacementPlugin = require('../webpack-plugins/hot-css-replacement-plugin')
|
28
27
|
const hotModuleReplacementPlugin = require('../webpack-plugins/hot-module-replacement-plugin')
|
@@ -61,7 +60,23 @@ const {
|
|
61
60
|
const recognizedTemplates = Object.keys(templateRenderers)
|
62
61
|
|
63
62
|
const kaliberBuildClientModules = [/(@kaliber\/build\/lib\/(stylesheet|javascript|polyfill|withPolyfill|hot-module-replacement-client|rollbar|universalComponents)|ansi-regex)/]
|
64
|
-
const compileWithBabel = kaliberBuildClientModules.concat(
|
63
|
+
const compileWithBabel = kaliberBuildClientModules.concat(
|
64
|
+
userDefinedcompileWithBabel.map(x => {
|
65
|
+
if (x.source !== '@kaliber\\/') return x
|
66
|
+
|
67
|
+
console.log(
|
68
|
+
'================================================================================\n' +
|
69
|
+
'WARNING, you specified /@kaliber\\// to be compiled with babel, not all @kaliber\n' +
|
70
|
+
'libraries need to be compiled. An example of this is the @kaliber/config. To get\n' +
|
71
|
+
'rid of this warning, exclude them from the regular expression like this:\n' +
|
72
|
+
' /@kaliber\\/(?|config)\n' +
|
73
|
+
'We replaced /@kaliber\\// with /@kaliber\\/(?|config)/ but this might also cause\n' +
|
74
|
+
'problems with other libraries that dynamically perform requires.\n' +
|
75
|
+
'================================================================================'
|
76
|
+
)
|
77
|
+
return /@kaliber\/(?!config)/
|
78
|
+
})
|
79
|
+
)
|
65
80
|
|
66
81
|
const babelLoader = {
|
67
82
|
loader: 'babel-loader',
|
@@ -378,7 +393,6 @@ module.exports = function build({ watch }) {
|
|
378
393
|
watch && websocketCommunicationPlugin(),
|
379
394
|
new TimeFixPlugin(),
|
380
395
|
new ExtendedAPIPlugin(),
|
381
|
-
configLoaderPlugin(),
|
382
396
|
watchContextPlugin(),
|
383
397
|
reactUniversalPlugin(webOptions()), // claims .entry.js
|
384
398
|
templatePlugin(templateRenderers), // does work on .*.js
|
@@ -404,7 +418,7 @@ module.exports = function build({ watch }) {
|
|
404
418
|
function externalConfForModulesDir(modulesDir) {
|
405
419
|
return {
|
406
420
|
modulesDir,
|
407
|
-
allowlist: [
|
421
|
+
allowlist: [...compileWithBabel, /\.css$/]
|
408
422
|
}
|
409
423
|
}
|
410
424
|
|
package/lib/serve.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
const compression = require('compression')
|
2
2
|
const express = require('express')
|
3
|
-
const helmet = require('helmet')
|
3
|
+
const helmet = require('helmet').default
|
4
4
|
const { access } = require('fs')
|
5
5
|
const { parsePath } = require('history')
|
6
6
|
const { resolve } = require('path')
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "0.0.
|
2
|
+
"version": "0.0.147",
|
3
3
|
"name": "@kaliber/build",
|
4
4
|
"description": "Zero configuration, opinionated webpack / react build setup",
|
5
5
|
"scripts": {
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"fs-extra": "^10.0.0",
|
55
55
|
"generic-names": "^3.0.0",
|
56
56
|
"gm": "^1.23.1",
|
57
|
-
"helmet": "^
|
57
|
+
"helmet": "^7.1.0",
|
58
58
|
"history": "^5.0.0",
|
59
59
|
"hoist-non-react-statics": "^3.3.2",
|
60
60
|
"icss-utils": "^4.1.1",
|
@@ -6,7 +6,7 @@ const {
|
|
6
6
|
} = require('../../machinery/ast')
|
7
7
|
const { flexChildProps, gridChildProps, flexOrGridChildProps } = require('../../machinery/css')
|
8
8
|
|
9
|
-
const intrinsicUnits = ['px', 'em', 'rem', 'vw', 'vh']
|
9
|
+
const intrinsicUnits = ['px', 'em', 'rem', 'vw', 'vh', 'dvw', 'dvh', 'svh', 'svw', 'lvh', 'lvw']
|
10
10
|
const intrinsicProps = ['width', 'height', 'max-width', 'min-width', 'max-height', 'min-height']
|
11
11
|
|
12
12
|
const allowedInRootAndChild = [
|
@@ -22,7 +22,7 @@ const layoutRelatedProps = [ // only allowed in child
|
|
22
22
|
'top', 'right', 'bottom', 'left', 'inset',
|
23
23
|
'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
|
24
24
|
'max-width', 'min-width', 'max-height', 'min-height',
|
25
|
-
'justify-self', 'align-self',
|
25
|
+
'justify-self', 'align-self', 'place-self',
|
26
26
|
...flexChildProps,
|
27
27
|
...gridChildProps,
|
28
28
|
...flexOrGridChildProps,
|
@@ -41,7 +41,7 @@ const messages = {
|
|
41
41
|
`one of \`${intrinsicUnits.join('`, `')}\` and add \`!important\``
|
42
42
|
: ''
|
43
43
|
),
|
44
|
-
'nested - only layout related props in nested':
|
44
|
+
'nested - only layout related props in nested': prop =>
|
45
45
|
`illegal non-layout related prop\n` +
|
46
46
|
`\`${prop}\` can only be used by root rules - ` +
|
47
47
|
`move to another root rule`,
|
@@ -34,7 +34,7 @@ const messages = {
|
|
34
34
|
`add \`display: flex;\` or \`display: grid;\` to the containing root rule or, if this is caused by a media query ` +
|
35
35
|
`that overrides \`display: flex;\` or \`display: grid;\`, use \`${prop}: unset\``,
|
36
36
|
'layoutClassname - must be nested in a parent selector':
|
37
|
-
`layoutClassNames (classes ending with the \`Layout\` suffix) can only be targetted by a parent selector, using the direct child selector. ` +
|
37
|
+
`layoutClassNames (classes ending with the \`Layout\` suffix) can only be targetted by a parent selector, using the direct child selector. ` +
|
38
38
|
`Consequentially, you can only use layout related properties in layoutClassNames.`,
|
39
39
|
'invalid pointer events':
|
40
40
|
`Incorrect pointer events combination\n` +
|
@@ -72,13 +72,13 @@ const childParentRelations = {
|
|
72
72
|
rootHasDisplayGrid: {
|
73
73
|
nestedHasOneOf: gridChildProps,
|
74
74
|
requireInRoot: [
|
75
|
-
['display', 'grid']
|
75
|
+
['display', ['grid', 'inline-grid']]
|
76
76
|
]
|
77
77
|
},
|
78
78
|
rootHasDisplayFlexOrGrid: {
|
79
79
|
nestedHasOneOf: flexOrGridChildProps,
|
80
80
|
requireInRoot: [
|
81
|
-
['display', ['flex', 'grid']]
|
81
|
+
['display', ['flex', 'grid', 'inline-grid']]
|
82
82
|
]
|
83
83
|
},
|
84
84
|
validPointerEvents: {
|
@@ -35,6 +35,19 @@ test('parent-child-policy', {
|
|
35
35
|
}
|
36
36
|
`,
|
37
37
|
},
|
38
|
+
{
|
39
|
+
title: `don't report when display inline-grid is present`,
|
40
|
+
code: `
|
41
|
+
.good {
|
42
|
+
display: inline-grid;
|
43
|
+
|
44
|
+
& > .test {
|
45
|
+
grid: 0; grid-area: 0; grid-column: 0; grid-row: 0; order: 0;
|
46
|
+
grid-column-start: 0; grid-column-end: 0; grid-row-start: 0; grid-row-end: 0;
|
47
|
+
}
|
48
|
+
}
|
49
|
+
`,
|
50
|
+
},
|
38
51
|
{
|
39
52
|
code: '.good { pointer-events: auto; }',
|
40
53
|
},
|
@@ -20,31 +20,29 @@ module.exports = function copyUnusedFilesPlugin() {
|
|
20
20
|
const chunk = {
|
21
21
|
name: 'unused file',
|
22
22
|
ids: ['_'],
|
23
|
-
files: []
|
23
|
+
files: /** @type {Array<string>} */([])
|
24
24
|
}
|
25
25
|
compilation.chunks.push(chunk)
|
26
26
|
|
27
27
|
const filesCopied = Promise.all(
|
28
|
-
walkSync(context).map(
|
29
|
-
const source =
|
28
|
+
walkSync.entries(context).map(entry => {
|
29
|
+
const source = entry.fullPath
|
30
30
|
|
31
31
|
if (compilation.fileDependencies.has(source)) return null
|
32
32
|
|
33
|
+
const filePath = entry.relativePath
|
33
34
|
const target = path.resolve(compiler.options.output.path, filePath)
|
34
|
-
|
35
|
-
|
36
|
-
if (stats.isDirectory()) return
|
37
|
-
if (compilation.assets[filePath]) throw new Error(`Unexpected problem: ${filePath} is marked as unused but it is in the compilation assets - create an issue with an example to reproduce and we will figure out a solution`)
|
35
|
+
if (entry.isDirectory()) return null
|
36
|
+
if (compilation.assets[filePath]) throw new Error(`Unexpected problem: ${filePath} is marked as unused but it is in the compilation assets - create an issue with an example to reproduce and we will figure out a solution`)
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
38
|
+
const asset = compilation.assets[filePath] = {
|
39
|
+
size: () => entry.size,
|
40
|
+
emitted: false
|
41
|
+
}
|
42
|
+
chunk.files.push(filePath)
|
44
43
|
|
45
|
-
|
46
|
-
|
47
|
-
})
|
44
|
+
return copy(source, target)
|
45
|
+
.then(_ => { asset.emitted = true })
|
48
46
|
})
|
49
47
|
)
|
50
48
|
|
@@ -54,14 +52,10 @@ module.exports = function copyUnusedFilesPlugin() {
|
|
54
52
|
}
|
55
53
|
}
|
56
54
|
|
55
|
+
/** @returns {Promise<void>} */
|
57
56
|
function copy(source, target) {
|
58
57
|
return new Promise((resolve, reject) => {
|
59
|
-
fs.copy(source, target, err => { err ? reject(err) : resolve() })
|
58
|
+
fs.copy(source, target, { preserveTimestamps: true }, err => { err ? reject(err) : resolve() })
|
60
59
|
})
|
61
|
-
}
|
62
60
|
|
63
|
-
function stat(filePath) {
|
64
|
-
return new Promise((resolve, reject) => {
|
65
|
-
fs.stat(filePath, (err, stats) => { err ? reject(err) : resolve(stats) })
|
66
|
-
})
|
67
61
|
}
|
@@ -1,22 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
This plugin determines when @kaliber/config is imported and pushes the custom config-loader
|
3
|
-
*/
|
4
|
-
const p = 'config-loader-plugin'
|
5
|
-
|
6
|
-
module.exports = function configLoaderPlugin() {
|
7
|
-
return {
|
8
|
-
apply: compiler => {
|
9
|
-
compiler.hooks.normalModuleFactory.tap(p, normalModuleFactory => {
|
10
|
-
|
11
|
-
normalModuleFactory.hooks.afterResolve.tap(p, data => {
|
12
|
-
const { loaders, rawRequest } = data
|
13
|
-
|
14
|
-
if (rawRequest === '@kaliber/config')
|
15
|
-
loaders.push({ loader: require.resolve('../webpack-loaders/config-loader') })
|
16
|
-
|
17
|
-
return data
|
18
|
-
})
|
19
|
-
})
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|