@pushwoosh/frontend-builder-engine 4.3.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/lib/babel.application.config.js +11 -0
- package/lib/eslint.config.mjs +23 -14
- package/package.json +8 -7
package/README.md
CHANGED
|
@@ -62,6 +62,25 @@ an uppercase `@LICENSE` comment is not extracted. To fall back to terser for one
|
|
|
62
62
|
ENGINE_MINIFIER=terser npm run build
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
### React Compiler (opt-in)
|
|
66
|
+
|
|
67
|
+
`babel-plugin-react-compiler` ships with the engine and is off by default: a project switches it on in
|
|
68
|
+
its `pushwoosh.config.js`, so micro-frontends move to it one at a time.
|
|
69
|
+
|
|
70
|
+
```js
|
|
71
|
+
module.exports = {
|
|
72
|
+
reactCompiler: true,
|
|
73
|
+
// or compiler options, e.g. compile only components marked with 'use memo':
|
|
74
|
+
// reactCompiler: { compilationMode: 'annotation' },
|
|
75
|
+
};
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
The plugin runs first in `lib/babel.application.config.js` with `target: '19'`, so it needs no
|
|
79
|
+
`react-compiler-runtime` package: the memo cache comes from `react/compiler-runtime` of the project's own
|
|
80
|
+
React 19, bundled into `index.mjs` while `react` itself stays external. Components the compiler cannot
|
|
81
|
+
handle are left as they are (the default `panicThreshold: 'none'`). The option affects application
|
|
82
|
+
builds only; `lib:build` does not read it.
|
|
83
|
+
|
|
65
84
|
## Migration from v3
|
|
66
85
|
|
|
67
86
|
v3 is deprecated: its `dist/index.js` is not an ES module, and the platform loads native ES modules
|
|
@@ -12,6 +12,16 @@ const fromEngine = (name) => require.resolve(name);
|
|
|
12
12
|
const runtimeVersion = require('@babel/runtime/package.json').version;
|
|
13
13
|
|
|
14
14
|
const { BROWSER_TARGETS } = require('./browser-targets');
|
|
15
|
+
const { loadPushwooshConfig } = require('./helpers');
|
|
16
|
+
|
|
17
|
+
// Opt-in per project (pushwoosh.config.js `reactCompiler`); the compiler has to run before every other plugin.
|
|
18
|
+
const reactCompilerPlugins = (option) => {
|
|
19
|
+
if (!option) {
|
|
20
|
+
return [];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return [[fromEngine('babel-plugin-react-compiler'), { target: '19', ...(typeof option === 'object' ? option : {}) }]];
|
|
24
|
+
};
|
|
15
25
|
|
|
16
26
|
module.exports = (api) => {
|
|
17
27
|
api.cache(true);
|
|
@@ -30,6 +40,7 @@ module.exports = (api) => {
|
|
|
30
40
|
fromEngine('@babel/preset-typescript')
|
|
31
41
|
],
|
|
32
42
|
plugins: [
|
|
43
|
+
...reactCompilerPlugins(loadPushwooshConfig().reactCompiler),
|
|
33
44
|
[
|
|
34
45
|
fromEngine('@babel/plugin-transform-runtime'),
|
|
35
46
|
{
|
package/lib/eslint.config.mjs
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
// @ts-check
|
|
2
2
|
|
|
3
3
|
import eslint from '@eslint/js';
|
|
4
|
+
import eslintReact from '@eslint-react/eslint-plugin';
|
|
4
5
|
import stylistic from '@stylistic/eslint-plugin';
|
|
5
|
-
import
|
|
6
|
-
import reactPlugin from 'eslint-plugin-react';
|
|
6
|
+
import { importX } from 'eslint-plugin-import-x';
|
|
7
7
|
import hooksPlugin from 'eslint-plugin-react-hooks';
|
|
8
8
|
import tseslint from 'typescript-eslint';
|
|
9
9
|
|
|
10
|
+
// Keeps the `import/` and `react/` rule prefixes so eslint-disable comments in consumers survive the plugin swap.
|
|
11
|
+
/** @type {(config: import('eslint').Linter.Config, from: string, to: string) => import('eslint').Linter.Config} */
|
|
12
|
+
const renamePlugin = (config, from, to) => ({
|
|
13
|
+
...config,
|
|
14
|
+
plugins: { [to]: config.plugins?.[from] ?? {} },
|
|
15
|
+
rules: Object.fromEntries(Object.entries(config.rules ?? {}).map(([rule, level]) => [rule.replace(`${from}/`, `${to}/`), level])),
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// eslint-plugin-react-hooks stays the source of truth for hooks and React Compiler rules.
|
|
19
|
+
const reactRecommended = eslintReact.configs['recommended-typescript'];
|
|
20
|
+
const reactConfig = renamePlugin({
|
|
21
|
+
...reactRecommended,
|
|
22
|
+
rules: Object.fromEntries(Object.entries(reactRecommended.rules ?? {}).filter(([rule]) => !(rule.replace('@eslint-react/', '') in hooksPlugin.rules))),
|
|
23
|
+
}, '@eslint-react', 'react');
|
|
24
|
+
|
|
10
25
|
export default tseslint.config(
|
|
11
26
|
eslint.configs.recommended,
|
|
12
|
-
|
|
27
|
+
renamePlugin(importX.flatConfigs.recommended, 'import-x', 'import'),
|
|
13
28
|
...tseslint.configs.recommended,
|
|
14
29
|
stylistic.configs.customize({
|
|
15
30
|
indent: 2,
|
|
@@ -22,28 +37,22 @@ export default tseslint.config(
|
|
|
22
37
|
commaDangle: 'always-multiline',
|
|
23
38
|
arrowParens: 'always',
|
|
24
39
|
}),
|
|
25
|
-
|
|
26
|
-
reactPlugin.configs.flat['jsx-runtime'],
|
|
40
|
+
reactConfig,
|
|
27
41
|
{
|
|
28
42
|
plugins: {
|
|
29
43
|
'@stylistic': stylistic,
|
|
30
44
|
'react-hooks': hooksPlugin,
|
|
31
45
|
},
|
|
32
|
-
settings: {
|
|
33
|
-
react: {
|
|
34
|
-
version: 'detect',
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
46
|
rules: {
|
|
38
47
|
...hooksPlugin.configs.recommended.rules,
|
|
39
48
|
'react-hooks/incompatible-library': 'error',
|
|
40
|
-
'react/display-name': 'off',
|
|
41
49
|
'react/no-array-index-key': 'error',
|
|
42
|
-
'react/
|
|
50
|
+
'react/dom-no-unknown-property': 'error',
|
|
51
|
+
'react/dom-no-unsafe-target-blank': 'error',
|
|
52
|
+
'@stylistic/jsx-max-props-per-line': [
|
|
43
53
|
'error',
|
|
44
54
|
{
|
|
45
|
-
|
|
46
|
-
maximum: 3,
|
|
55
|
+
maximum: { single: 3, multi: 1 },
|
|
47
56
|
},
|
|
48
57
|
],
|
|
49
58
|
'max-len': [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pushwoosh/frontend-builder-engine",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Pushwoosh frontend builder engine",
|
|
5
5
|
"main": "./lib/pushwoosh-frontend-builder-engine.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -27,22 +27,23 @@
|
|
|
27
27
|
"@babel/preset-typescript": "^7.24.1",
|
|
28
28
|
"@babel/runtime": "^7.29.7",
|
|
29
29
|
"@babel/types": "^7.24.0",
|
|
30
|
-
"@eslint/
|
|
30
|
+
"@eslint-react/eslint-plugin": "^5.28.8",
|
|
31
|
+
"@eslint/js": "^10.0.1",
|
|
31
32
|
"@stylistic/eslint-plugin": "^5.3.1",
|
|
32
33
|
"@svgr/webpack": "^8.1.0",
|
|
33
34
|
"@swc/core": "1.16.18",
|
|
34
35
|
"@types/eslint__js": "^8.42.3",
|
|
35
36
|
"@types/webpack-env": "^1.18.4",
|
|
36
37
|
"babel-loader": "^10.0.0",
|
|
38
|
+
"babel-plugin-react-compiler": "^1.0.0",
|
|
37
39
|
"babel-plugin-styled-components": "^2.1.4",
|
|
38
40
|
"babel-plugin-transform-imports": "^2.0.0",
|
|
39
41
|
"commander": "^12.0.0",
|
|
40
42
|
"css-loader": "^7.1.2",
|
|
41
43
|
"dotenv": "^16.4.5",
|
|
42
|
-
"eslint": "^
|
|
43
|
-
"eslint-plugin-import": "^
|
|
44
|
-
"eslint-plugin-react": "^7.
|
|
45
|
-
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
|
+
"eslint": "^10.14.0",
|
|
45
|
+
"eslint-plugin-import-x": "^4.17.1",
|
|
46
|
+
"eslint-plugin-react-hooks": "^7.1.1",
|
|
46
47
|
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
|
47
48
|
"html-webpack-plugin": "^5.6.0",
|
|
48
49
|
"knip": "^6.35.1",
|
|
@@ -51,7 +52,7 @@
|
|
|
51
52
|
"ts-loader": "^9.5.1",
|
|
52
53
|
"tsconfig-paths-webpack-plugin": "^4.1.0",
|
|
53
54
|
"typescript": "^6.0.3",
|
|
54
|
-
"typescript-eslint": "^8.
|
|
55
|
+
"typescript-eslint": "^8.72.1",
|
|
55
56
|
"webpack": "^5.94.0",
|
|
56
57
|
"webpack-bundle-analyzer": "^5.1.1",
|
|
57
58
|
"webpack-cli": "^6.0.1",
|