@pushwoosh/frontend-builder-engine 3.3.0 → 4.1.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 CHANGED
@@ -39,6 +39,43 @@ A project whose parcel entry sits outside the globs above (a file no other entry
39
39
  its own `knip.json` in the project root and a plain `knip` call — the shared config is passed with
40
40
  `--config` and cannot be extended per project.
41
41
 
42
+ ### Output format
43
+
44
+ Since v4 an application builds as a native ES module: `dist/index.mjs` with `import … from "react"`
45
+ for every external. Externals resolve through the root-config `importmap`,
46
+ chunks and assets resolve against `import.meta.url` (`publicPath: 'auto'`). The browser floor is
47
+ Chrome/Edge 94, Firefox 108 (import maps), Safari/iOS 16.4. To see it from a project:
48
+
49
+ ```bash
50
+ npx browserslist "$(node -p "require('@pushwoosh/frontend-builder-engine/lib/browser-targets').BROWSERSLIST_QUERY")"
51
+ ```
52
+
53
+ ## Migration from v3
54
+
55
+ v3 is deprecated: its `dist/index.js` is not an ES module, and the platform loads native ES modules
56
+ only since root-config dropped its module loader (DEV-992), so a v3 build no longer starts there —
57
+ its `import()` fails with `ReferenceError: System is not defined` and the app slot stays empty.
58
+ Hotfixes for v3 go to the `v3` branch only. Moving a micro-frontend to v4:
59
+
60
+ 1. Bump `@pushwoosh/frontend-builder-engine` to `^4.0.0` in `devDependencies`.
61
+ 2. Replace `module.hot` with `import.meta.webpackHot` (same API):
62
+
63
+ ```ts
64
+ if (import.meta.webpackHot) {
65
+ import.meta.webpackHot.accept();
66
+ }
67
+ ```
68
+
69
+ 3. The build output is `dist/index.mjs` instead of `dist/index.js`. Nothing to change in CI: the
70
+ shared `frontend/microfrontend-release.yml` registers `index.mjs` in the import map, and
71
+ `microfrontend-dev.yml` prints the `index.mjs` override, both whenever `dist` has it.
72
+ 4. `pushwoosh.config.js` (`applicationExternals`, `applicationWebpack`) needs no changes, unless
73
+ `applicationWebpack` sets `output.libraryTarget`/`output.library` or adds a public-path plugin of
74
+ its own — drop those.
75
+
76
+ Every name in `defaultExternals` resolves through the root-config import map and must point at an
77
+ ES module (`.mjs`) there; all of them do since DEV-987/DEV-988.
78
+
42
79
  ### Library commands (reusable packages)
43
80
 
44
81
  ```bash
@@ -59,3 +96,8 @@ cd examples/library && npm install && npm start
59
96
  ### Release
60
97
 
61
98
  Releases are triggered by Git tags in CI. Tag with `v*` for stable, include `beta` for beta channel.
99
+ v4 is released from `master`, hotfixes for the deprecated v3 from the `v3` branch. CI publishes
100
+ every non-beta tag as npm `latest`, so after a v3.x patch move `latest` back:
101
+ `npm dist-tag add @pushwoosh/frontend-builder-engine@<newest 4.x> latest`, and re-run
102
+ `npm deprecate @pushwoosh/frontend-builder-engine@3.x "…"`: a deprecation covers only the versions
103
+ published before it.
@@ -11,8 +11,10 @@
11
11
  * config file in babel, and the BROWSERSLIST variable short-circuits config
12
12
  * lookup in browserslist itself.
13
13
  *
14
- * This is an honest ES2022 baseline — these are exactly the versions where the
15
- * last ES2022 feature (class static initialization blocks) landed. Keep it in
14
+ * This is an ES2022 baseline — the versions where the last ES2022 feature
15
+ * (class static initialization blocks) landed — except Firefox, raised to 108
16
+ * because that is where import maps landed and apps ship as native ES modules
17
+ * resolved through the root-config import map. Keep it in
16
18
  * sync with `target`/`lib` in `lib/tsconfig.json`: library packages are emitted
17
19
  * at that target and are never re-transpiled, because babel-loader excludes
18
20
  * node_modules.
@@ -40,7 +42,7 @@
40
42
  const BROWSER_TARGETS = [
41
43
  'Chrome >= 94',
42
44
  'Edge >= 94',
43
- 'Firefox >= 93',
45
+ 'Firefox >= 108',
44
46
  'Safari >= 16.4',
45
47
  'iOS >= 16.4',
46
48
  ];
@@ -36,7 +36,7 @@ export default tseslint.config(
36
36
  },
37
37
  rules: {
38
38
  ...hooksPlugin.configs.recommended.rules,
39
- 'react-hooks/set-state-in-effect': 'off',
39
+ 'react-hooks/set-state-in-effect': 'error',
40
40
  'react-hooks/refs': 'off',
41
41
  'react-hooks/incompatible-library': 'error',
42
42
  'react/display-name': 'off',
@@ -1,7 +1,6 @@
1
1
  const path = require('path');
2
2
  const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
3
3
  const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
4
- const SystemJSPublicPathPlugin = require('systemjs-webpack-interop/SystemJSPublicPathWebpackPlugin');
5
4
 
6
5
  const { BROWSERSLIST_QUERY } = require('../browser-targets');
7
6
 
@@ -54,10 +53,6 @@ function singleSpaDefaults(opts) {
54
53
  new BundleAnalyzerPlugin({
55
54
  analyzerMode: isAnalyze ? 'server' : 'disabled',
56
55
  }),
57
- new SystemJSPublicPathPlugin({
58
- systemjsModuleName: `@${opts.orgName}/${opts.projectName}`,
59
- rootDirectoryLevel: opts.rootDirectoryLevel,
60
- }),
61
56
  ];
62
57
 
63
58
  // Add TypeScript checker (skip in analyze mode)
@@ -81,14 +76,24 @@ function singleSpaDefaults(opts) {
81
76
  process.cwd(),
82
77
  `src/${opts.orgName}-${opts.projectName}.tsx`,
83
78
  ),
79
+ experiments: {
80
+ outputModule: true,
81
+ },
84
82
  output: {
85
- filename: `${opts.orgName}-${opts.projectName}.js`,
86
- libraryTarget: 'system',
83
+ filename: 'index.mjs',
84
+ module: true,
85
+ chunkFormat: 'module',
86
+ library: {
87
+ type: 'module',
88
+ },
87
89
  path: path.resolve(process.cwd(), 'dist'),
88
90
  uniqueName: opts.projectName,
89
91
  devtoolNamespace: opts.projectName,
90
- publicPath: '',
92
+ // Chunks and assets resolve against import.meta.url, wherever the import map points.
93
+ publicPath: 'auto',
91
94
  },
95
+ // Externals become native `import` statements resolved by the root-config import map.
96
+ externalsType: 'module',
92
97
  module: {
93
98
  rules: [
94
99
  {
@@ -48,7 +48,6 @@ module.exports = (webpackConfigEnv, argv) => {
48
48
  webpackConfigEnv,
49
49
  argv,
50
50
  // orgPackagesAsExternal: false,
51
- rootDirectoryLevel: 1,
52
51
  disableHtmlGeneration: true,
53
52
  });
54
53
 
@@ -62,7 +61,6 @@ module.exports = (webpackConfigEnv, argv) => {
62
61
  index: path.resolve(cwd, './src/index.tsx'),
63
62
  },
64
63
  output: {
65
- filename: '[name].js',
66
64
  path: path.resolve(cwd, './dist'),
67
65
  },
68
66
  resolve: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/frontend-builder-engine",
3
- "version": "3.3.0",
3
+ "version": "4.1.0",
4
4
  "description": "Pushwoosh frontend builder engine",
5
5
  "main": "./lib/pushwoosh-frontend-builder-engine.js",
6
6
  "publishConfig": {
@@ -46,7 +46,6 @@
46
46
  "html-webpack-plugin": "^5.6.0",
47
47
  "knip": "^6.35.1",
48
48
  "style-loader": "^4.0.0",
49
- "systemjs-webpack-interop": "^2.3.7",
50
49
  "ts-loader": "^9.5.1",
51
50
  "tsconfig-paths-webpack-plugin": "^4.1.0",
52
51
  "typescript": "^6.0.3",