@pushwoosh/frontend-builder-engine 3.3.0 → 4.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 CHANGED
@@ -39,6 +39,48 @@ 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, no `System.register`. 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 builds SystemJS (`dist/index.js`); it stays published and is maintained on the `v3` branch, so a
56
+ micro-frontend moves to v4 on its own schedule. Moving one:
57
+
58
+ 1. Bump `@pushwoosh/frontend-builder-engine` to `^4.0.0` in `devDependencies`.
59
+ 2. Replace `module.hot` with `import.meta.webpackHot` (same API):
60
+
61
+ ```ts
62
+ if (import.meta.webpackHot) {
63
+ import.meta.webpackHot.accept();
64
+ }
65
+ ```
66
+
67
+ 3. The build output is `dist/index.mjs` instead of `dist/index.js`. Nothing to change in CI: the
68
+ shared `frontend/microfrontend-release.yml` registers `index.mjs` in the import map when `dist`
69
+ has it. The manual dev stand (`microfrontend-dev.yml`) still prints an `index.js` override URL —
70
+ replace it with `index.mjs` by hand.
71
+ 4. `pushwoosh.config.js` (`applicationExternals`, `applicationWebpack`) needs no changes, unless
72
+ `applicationWebpack` sets `output.libraryTarget`/`output.library` or adds
73
+ `SystemJSPublicPathWebpackPlugin` itself — drop those.
74
+
75
+ **Release order.** Every external becomes a native `import`, resolved by the browser's import map,
76
+ not by SystemJS. Do not roll out the first v4 micro-frontend before:
77
+
78
+ - root-config ships the SystemJS ↔ ESM bridge (DEV-984) — without it the first `index.mjs` in the map
79
+ breaks every v3 micro-frontend;
80
+ - `@pushwoosh/http-client`, `@pushwoosh/session-store`, `@pushwoosh/rpc-gateway-*` and
81
+ `@pushwoosh/rpc-v2-http-api-data` are in the map as `.mjs` (DEV-987, DEV-988) — while they are
82
+ `.js` (System bundles), a v4 app that imports them fails to load.
83
+
42
84
  ### Library commands (reusable packages)
43
85
 
44
86
  ```bash
@@ -59,3 +101,6 @@ cd examples/library && npm install && npm start
59
101
  ### Release
60
102
 
61
103
  Releases are triggered by Git tags in CI. Tag with `v*` for stable, include `beta` for beta channel.
104
+ v4 is released from `master`, v3.x fixes from the `v3` branch. CI publishes every non-beta tag as
105
+ npm `latest`, so after a v3.x patch move `latest` back:
106
+ `npm dist-tag add @pushwoosh/frontend-builder-engine@<newest 4.x> latest`.
@@ -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
  ];
@@ -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.0.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",