@pushwoosh/frontend-builder-engine 5.1.1 → 5.3.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/webpack.application.config.js +31 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -81,6 +81,25 @@ React 19, bundled into `index.mjs` while `react` itself stays external. Componen
|
|
|
81
81
|
handle are left as they are (the default `panicThreshold: 'none'`). The option affects application
|
|
82
82
|
builds only; `lib:build` does not read it.
|
|
83
83
|
|
|
84
|
+
### Shared kit (opt-in)
|
|
85
|
+
|
|
86
|
+
With `sharedKit: true` the kit stops being bundled into the app: `@pushwoosh/dumb-components`,
|
|
87
|
+
`smart-components-kit`, `kit-helpers`, `kit-constants`, `kit-typography`, `kit-charts`, `spa-context`,
|
|
88
|
+
`single-spa`, `brand-book` and `@pushwoosh/kit-icons` join `defaultExternals` and load from the CDN
|
|
89
|
+
through the root-config import map, like `@pushwoosh/http-client`. `applicationExternals` receives the
|
|
90
|
+
extended list.
|
|
91
|
+
|
|
92
|
+
```js
|
|
93
|
+
module.exports = {
|
|
94
|
+
sharedKit: true,
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
Only the package roots are external, because only roots are in the import map. A deep import such as
|
|
99
|
+
`@pushwoosh/dumb-components/polyglot` would be bundled into the app as a second copy of the module
|
|
100
|
+
(its own React contexts), so with `sharedKit` it fails the build instead; import the kit through its
|
|
101
|
+
roots. Turn the option on after every one of these names is in the import map.
|
|
102
|
+
|
|
84
103
|
## Migration from v3
|
|
85
104
|
|
|
86
105
|
v3 is deprecated: its `dist/index.js` is not an ES module, and the platform loads native ES modules
|
|
@@ -12,6 +12,7 @@ const defaultExternals = [
|
|
|
12
12
|
'react/jsx-runtime',
|
|
13
13
|
'react-dom',
|
|
14
14
|
'react-dom/client',
|
|
15
|
+
'react-router-dom',
|
|
15
16
|
'single-spa',
|
|
16
17
|
'history',
|
|
17
18
|
'tslib',
|
|
@@ -29,6 +30,32 @@ const defaultExternals = [
|
|
|
29
30
|
'@pushwoosh/session-store',
|
|
30
31
|
];
|
|
31
32
|
|
|
33
|
+
const sharedKitExternals = [
|
|
34
|
+
'@pushwoosh/dumb-components',
|
|
35
|
+
'@pushwoosh/smart-components-kit',
|
|
36
|
+
'@pushwoosh/kit-helpers',
|
|
37
|
+
'@pushwoosh/kit-constants',
|
|
38
|
+
'@pushwoosh/kit-typography',
|
|
39
|
+
'@pushwoosh/kit-charts',
|
|
40
|
+
'@pushwoosh/spa-context',
|
|
41
|
+
'@pushwoosh/single-spa',
|
|
42
|
+
'@pushwoosh/brand-book',
|
|
43
|
+
'@pushwoosh/kit-icons',
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
class SharedKitDeepImportGuard {
|
|
47
|
+
apply(compiler) {
|
|
48
|
+
compiler.hooks.normalModuleFactory.tap('SharedKitDeepImportGuard', (factory) => {
|
|
49
|
+
factory.hooks.beforeResolve.tap('SharedKitDeepImportGuard', ({ request }) => {
|
|
50
|
+
const root = sharedKitExternals.find((name) => request.startsWith(`${name}/`));
|
|
51
|
+
if (root) {
|
|
52
|
+
throw new Error(`${request}: with sharedKit the kit loads from the import map by its package root only, import from '${root}'`);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
32
59
|
module.exports = (webpackConfigEnv, argv) => {
|
|
33
60
|
const cwd = process.cwd();
|
|
34
61
|
const pushwooshConfig = loadPushwooshConfig();
|
|
@@ -42,6 +69,8 @@ module.exports = (webpackConfigEnv, argv) => {
|
|
|
42
69
|
const isProduction = NODE_ENV === 'production';
|
|
43
70
|
const variables = loadVariables(!isProduction);
|
|
44
71
|
|
|
72
|
+
const externals = pushwooshConfig.sharedKit ? [...defaultExternals, ...sharedKitExternals] : defaultExternals;
|
|
73
|
+
|
|
45
74
|
const defaultConfig = singleSpaDefaults({
|
|
46
75
|
orgName,
|
|
47
76
|
projectName,
|
|
@@ -68,8 +97,9 @@ module.exports = (webpackConfigEnv, argv) => {
|
|
|
68
97
|
'~/src': path.resolve(cwd, './src'),
|
|
69
98
|
},
|
|
70
99
|
},
|
|
71
|
-
externals: pushwooshConfig.applicationExternals ? pushwooshConfig.applicationExternals(
|
|
100
|
+
externals: pushwooshConfig.applicationExternals ? pushwooshConfig.applicationExternals(externals) : externals,
|
|
72
101
|
plugins: [
|
|
102
|
+
...(pushwooshConfig.sharedKit ? [new SharedKitDeepImportGuard()] : []),
|
|
73
103
|
new webpack.DefinePlugin({
|
|
74
104
|
process: {
|
|
75
105
|
env: JSON.stringify({
|