@lynx-js/lynx-bundle-rslib-config-canary 0.2.0 → 0.2.1-canary-20260126-c691f87a
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/lynx-bundle-rslib-config
|
|
2
2
|
|
|
3
|
+
## 0.2.1-canary-20260126040139-c691f87a04693fedfdd15d2f7841e2b61339112b
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Add [`globalObject`](https://webpack.js.org/configuration/output/#outputglobalobject) config for external bundle loading, user can configure it to `globalThis` for BTS external bundle sharing. ([#2123](https://github.com/lynx-family/lynx-stack/pull/2123))
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -24,23 +30,23 @@
|
|
|
24
30
|
|
|
25
31
|
```js
|
|
26
32
|
// webpack.config.js
|
|
27
|
-
import { ExternalsLoadingPlugin } from
|
|
33
|
+
import { ExternalsLoadingPlugin } from "@lynx-js/externals-loading-webpack-plugin";
|
|
28
34
|
|
|
29
35
|
export default {
|
|
30
36
|
plugins: [
|
|
31
37
|
new ExternalsLoadingPlugin({
|
|
32
|
-
mainThreadLayer:
|
|
33
|
-
backgroundLayer:
|
|
38
|
+
mainThreadLayer: "main-thread",
|
|
39
|
+
backgroundLayer: "background",
|
|
34
40
|
externals: {
|
|
35
41
|
lodash: {
|
|
36
|
-
url:
|
|
37
|
-
background: { sectionPath:
|
|
38
|
-
mainThread: { sectionPath:
|
|
42
|
+
url: "http://lodash.lynx.bundle",
|
|
43
|
+
background: { sectionPath: "background" },
|
|
44
|
+
mainThread: { sectionPath: "main-thread" },
|
|
39
45
|
},
|
|
40
46
|
},
|
|
41
47
|
}),
|
|
42
48
|
],
|
|
43
|
-
}
|
|
49
|
+
};
|
|
44
50
|
```
|
|
45
51
|
|
|
46
52
|
## 0.0.1
|
|
@@ -51,14 +57,14 @@
|
|
|
51
57
|
|
|
52
58
|
```js
|
|
53
59
|
// rslib.config.js
|
|
54
|
-
import { defineExternalBundleRslibConfig } from
|
|
60
|
+
import { defineExternalBundleRslibConfig } from "@lynx-js/lynx-bundle-rslib-config";
|
|
55
61
|
|
|
56
62
|
export default defineExternalBundleRslibConfig({
|
|
57
|
-
id:
|
|
63
|
+
id: "utils-lib",
|
|
58
64
|
source: {
|
|
59
65
|
entry: {
|
|
60
|
-
utils:
|
|
66
|
+
utils: "./src/utils.ts",
|
|
61
67
|
},
|
|
62
68
|
},
|
|
63
|
-
})
|
|
69
|
+
});
|
|
64
70
|
```
|
|
@@ -22,6 +22,16 @@ export type Externals = Record<string, string | string[]>;
|
|
|
22
22
|
export type LibOutputConfig = Required<LibConfig>['output'];
|
|
23
23
|
export interface OutputConfig extends LibOutputConfig {
|
|
24
24
|
externals?: Externals;
|
|
25
|
+
/**
|
|
26
|
+
* This option indicates what global object will be used to mount the library.
|
|
27
|
+
*
|
|
28
|
+
* In Lynx, the library will be mounted to `lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")]` by default.
|
|
29
|
+
*
|
|
30
|
+
* If you have enabled share js context and want to reuse the library by mounting to the global object, you can set this option to `'globalThis'`.
|
|
31
|
+
*
|
|
32
|
+
* @default 'lynx'
|
|
33
|
+
*/
|
|
34
|
+
globalObject?: 'lynx' | 'globalThis';
|
|
25
35
|
}
|
|
26
36
|
export interface ExternalBundleLibConfig extends LibConfig {
|
|
27
37
|
output?: OutputConfig;
|
|
@@ -45,7 +45,7 @@ export const defaultExternalBundleLibConfig = {
|
|
|
45
45
|
include: [/node_modules/],
|
|
46
46
|
},
|
|
47
47
|
};
|
|
48
|
-
function transformExternals(externals) {
|
|
48
|
+
function transformExternals(externals, globalObject) {
|
|
49
49
|
if (!externals)
|
|
50
50
|
return {};
|
|
51
51
|
return function ({ request }, callback) {
|
|
@@ -55,7 +55,7 @@ function transformExternals(externals) {
|
|
|
55
55
|
if (!libraryName)
|
|
56
56
|
return callback();
|
|
57
57
|
callback(undefined, [
|
|
58
|
-
'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")]
|
|
58
|
+
`${globalObject ?? 'lynx'}[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")]`,
|
|
59
59
|
...(Array.isArray(libraryName) ? libraryName : [libraryName]),
|
|
60
60
|
], 'var');
|
|
61
61
|
};
|
|
@@ -138,7 +138,7 @@ export function defineExternalBundleRslibConfig(userLibConfig, encodeOptions = {
|
|
|
138
138
|
...userLibConfig,
|
|
139
139
|
output: {
|
|
140
140
|
...userLibConfig.output,
|
|
141
|
-
externals: transformExternals(userLibConfig.output?.externals),
|
|
141
|
+
externals: transformExternals(userLibConfig.output?.externals, userLibConfig.output?.globalObject),
|
|
142
142
|
},
|
|
143
143
|
}),
|
|
144
144
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-bundle-rslib-config-canary",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1-canary-20260126-c691f87a",
|
|
4
4
|
"description": "The rsbuild config for building Lynx bundle",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Rsbuild",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@rslib/core": "^0.19.1",
|
|
40
40
|
"vitest": "^3.2.4",
|
|
41
41
|
"webpack": "^5.104.1",
|
|
42
|
-
"@lynx-js/react": "npm:@lynx-js/react-canary@0.116.
|
|
42
|
+
"@lynx-js/react": "npm:@lynx-js/react-canary@0.116.1-canary-20260126-c691f87a",
|
|
43
43
|
"@lynx-js/react-rsbuild-plugin": "npm:@lynx-js/react-rsbuild-plugin-canary@0.12.6",
|
|
44
44
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
45
45
|
},
|