@lynx-js/lynx-bundle-rslib-config-canary 0.0.2 → 0.1.0-canary-20251225-6bccf69c
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 +17 -11
- package/lib/externalBundleRslibConfig.d.ts +3 -3
- package/lib/externalBundleRslibConfig.js +3 -3
- package/lib/index.d.ts +0 -38
- package/lib/index.js +0 -38
- package/lib/webpack/ExternalBundleWebpackPlugin.d.ts +3 -3
- package/lib/webpack/ExternalBundleWebpackPlugin.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/lynx-bundle-rslib-config
|
|
2
2
|
|
|
3
|
+
## 0.1.0-canary-20251225040646-6bccf69cc42fa754d2e8e58d1911b1c4d844a3a0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Update external bundle minimum SDK version to 3.5. ([#2037](https://github.com/lynx-family/lynx-stack/pull/2037))
|
|
8
|
+
|
|
3
9
|
## 0.0.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -8,23 +14,23 @@
|
|
|
8
14
|
|
|
9
15
|
```js
|
|
10
16
|
// webpack.config.js
|
|
11
|
-
import { ExternalsLoadingPlugin } from
|
|
17
|
+
import { ExternalsLoadingPlugin } from "@lynx-js/externals-loading-webpack-plugin";
|
|
12
18
|
|
|
13
19
|
export default {
|
|
14
20
|
plugins: [
|
|
15
21
|
new ExternalsLoadingPlugin({
|
|
16
|
-
mainThreadLayer:
|
|
17
|
-
backgroundLayer:
|
|
22
|
+
mainThreadLayer: "main-thread",
|
|
23
|
+
backgroundLayer: "background",
|
|
18
24
|
externals: {
|
|
19
25
|
lodash: {
|
|
20
|
-
url:
|
|
21
|
-
background: { sectionPath:
|
|
22
|
-
mainThread: { sectionPath:
|
|
26
|
+
url: "http://lodash.lynx.bundle",
|
|
27
|
+
background: { sectionPath: "background" },
|
|
28
|
+
mainThread: { sectionPath: "main-thread" },
|
|
23
29
|
},
|
|
24
30
|
},
|
|
25
31
|
}),
|
|
26
32
|
],
|
|
27
|
-
}
|
|
33
|
+
};
|
|
28
34
|
```
|
|
29
35
|
|
|
30
36
|
## 0.0.1
|
|
@@ -35,14 +41,14 @@
|
|
|
35
41
|
|
|
36
42
|
```js
|
|
37
43
|
// rslib.config.js
|
|
38
|
-
import { defineExternalBundleRslibConfig } from
|
|
44
|
+
import { defineExternalBundleRslibConfig } from "@lynx-js/lynx-bundle-rslib-config";
|
|
39
45
|
|
|
40
46
|
export default defineExternalBundleRslibConfig({
|
|
41
|
-
id:
|
|
47
|
+
id: "utils-lib",
|
|
42
48
|
source: {
|
|
43
49
|
entry: {
|
|
44
|
-
utils:
|
|
50
|
+
utils: "./src/utils.ts",
|
|
45
51
|
},
|
|
46
52
|
},
|
|
47
|
-
})
|
|
53
|
+
});
|
|
48
54
|
```
|
|
@@ -6,11 +6,11 @@ import type { LibConfig, RslibConfig } from '@rslib/core';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface EncodeOptions {
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The engine version of the external bundle.
|
|
10
10
|
*
|
|
11
|
-
* @defaultValue '3.
|
|
11
|
+
* @defaultValue '3.5'
|
|
12
12
|
*/
|
|
13
|
-
|
|
13
|
+
engineVersion?: string;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* The Layer name of background and main-thread.
|
|
@@ -153,7 +153,7 @@ export function defineExternalBundleRslibConfig(userLibConfig, encodeOptions = {
|
|
|
153
153
|
],
|
|
154
154
|
plugins: [
|
|
155
155
|
externalBundleEntryRsbuildPlugin(),
|
|
156
|
-
externalBundleRsbuildPlugin(encodeOptions.
|
|
156
|
+
externalBundleRsbuildPlugin(encodeOptions.engineVersion),
|
|
157
157
|
],
|
|
158
158
|
};
|
|
159
159
|
}
|
|
@@ -237,7 +237,7 @@ const externalBundleEntryRsbuildPlugin = () => ({
|
|
|
237
237
|
});
|
|
238
238
|
},
|
|
239
239
|
});
|
|
240
|
-
const externalBundleRsbuildPlugin = (
|
|
240
|
+
const externalBundleRsbuildPlugin = (engineVersion) => ({
|
|
241
241
|
name: 'lynx:gen-external-bundle',
|
|
242
242
|
async setup(api) {
|
|
243
243
|
const { getEncodeMode } = await import('@lynx-js/tasm');
|
|
@@ -249,7 +249,7 @@ const externalBundleRsbuildPlugin = (targetSdkVersion) => ({
|
|
|
249
249
|
{
|
|
250
250
|
bundleFileName: `${libName}.lynx.bundle`,
|
|
251
251
|
encode: getEncodeMode(),
|
|
252
|
-
|
|
252
|
+
engineVersion,
|
|
253
253
|
},
|
|
254
254
|
])
|
|
255
255
|
.end();
|
package/lib/index.d.ts
CHANGED
|
@@ -2,44 +2,6 @@
|
|
|
2
2
|
* @packageDocumentation
|
|
3
3
|
*
|
|
4
4
|
* `@lynx-js/lynx-bundle-rslib-config` is the package that provides the configurations for bundling Lynx bundle with {@link https://rslib.rs/ | Rslib}.
|
|
5
|
-
*
|
|
6
|
-
* 1. Install the package:
|
|
7
|
-
*
|
|
8
|
-
* ```bash
|
|
9
|
-
* pnpm add @lynx-js/lynx-bundle-rslib-config @rslib/core -D
|
|
10
|
-
* ```
|
|
11
|
-
*
|
|
12
|
-
* 2. Add the following code to `rslib.config.ts`:
|
|
13
|
-
*
|
|
14
|
-
* ```ts
|
|
15
|
-
* import { defineExternalBundleRslibConfig } from '@lynx-js/lynx-bundle-rslib-config'
|
|
16
|
-
*
|
|
17
|
-
* export default defineExternalBundleRslibConfig({
|
|
18
|
-
* id: 'my-utils',
|
|
19
|
-
* source: {
|
|
20
|
-
* entry: {
|
|
21
|
-
* utils: './src/utils.ts'
|
|
22
|
-
* }
|
|
23
|
-
* }
|
|
24
|
-
* })
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* 3. Run the command `pnpm rslib build` and you will get the `my-utils.lynx.bundle` in the `dist` directory. You can upload the bundle to CDN or server.
|
|
28
|
-
*
|
|
29
|
-
* 4. Finally, you can fetch and load the external bundle through:
|
|
30
|
-
*
|
|
31
|
-
* ```js
|
|
32
|
-
* const bundleUrl = 'http://cdn.com/my-utils.lynx.bundle'
|
|
33
|
-
* lynx.fetchBundle(bundleUrl).wait(3) // timeout is 3s
|
|
34
|
-
*
|
|
35
|
-
* if (__BACKGROUND__) {
|
|
36
|
-
* const utils = lynx.loadScript('utils', { bundleName: bundleUrl })
|
|
37
|
-
* } else {
|
|
38
|
-
* const utils = lynx.loadScript('utils__main-thread', { bundleName: bundleUrl })
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*
|
|
42
|
-
* For more detail, please refer to the {@link defineExternalBundleRslibConfig}.
|
|
43
5
|
*/
|
|
44
6
|
export { defineExternalBundleRslibConfig, defaultExternalBundleLibConfig, LAYERS, } from './externalBundleRslibConfig.js';
|
|
45
7
|
export type { EncodeOptions } from './externalBundleRslibConfig.js';
|
package/lib/index.js
CHANGED
|
@@ -5,44 +5,6 @@
|
|
|
5
5
|
* @packageDocumentation
|
|
6
6
|
*
|
|
7
7
|
* `@lynx-js/lynx-bundle-rslib-config` is the package that provides the configurations for bundling Lynx bundle with {@link https://rslib.rs/ | Rslib}.
|
|
8
|
-
*
|
|
9
|
-
* 1. Install the package:
|
|
10
|
-
*
|
|
11
|
-
* ```bash
|
|
12
|
-
* pnpm add @lynx-js/lynx-bundle-rslib-config @rslib/core -D
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* 2. Add the following code to `rslib.config.ts`:
|
|
16
|
-
*
|
|
17
|
-
* ```ts
|
|
18
|
-
* import { defineExternalBundleRslibConfig } from '@lynx-js/lynx-bundle-rslib-config'
|
|
19
|
-
*
|
|
20
|
-
* export default defineExternalBundleRslibConfig({
|
|
21
|
-
* id: 'my-utils',
|
|
22
|
-
* source: {
|
|
23
|
-
* entry: {
|
|
24
|
-
* utils: './src/utils.ts'
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* })
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* 3. Run the command `pnpm rslib build` and you will get the `my-utils.lynx.bundle` in the `dist` directory. You can upload the bundle to CDN or server.
|
|
31
|
-
*
|
|
32
|
-
* 4. Finally, you can fetch and load the external bundle through:
|
|
33
|
-
*
|
|
34
|
-
* ```js
|
|
35
|
-
* const bundleUrl = 'http://cdn.com/my-utils.lynx.bundle'
|
|
36
|
-
* lynx.fetchBundle(bundleUrl).wait(3) // timeout is 3s
|
|
37
|
-
*
|
|
38
|
-
* if (__BACKGROUND__) {
|
|
39
|
-
* const utils = lynx.loadScript('utils', { bundleName: bundleUrl })
|
|
40
|
-
* } else {
|
|
41
|
-
* const utils = lynx.loadScript('utils__main-thread', { bundleName: bundleUrl })
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
44
|
-
*
|
|
45
|
-
* For more detail, please refer to the {@link defineExternalBundleRslibConfig}.
|
|
46
8
|
*/
|
|
47
9
|
export { defineExternalBundleRslibConfig, defaultExternalBundleLibConfig, LAYERS, } from './externalBundleRslibConfig.js';
|
|
48
10
|
export { ExternalBundleWebpackPlugin } from './webpack/ExternalBundleWebpackPlugin.js';
|
|
@@ -32,11 +32,11 @@ export interface ExternalBundleWebpackPluginOptions {
|
|
|
32
32
|
buffer: Buffer;
|
|
33
33
|
}>;
|
|
34
34
|
/**
|
|
35
|
-
* The
|
|
35
|
+
* The engine version of the external bundle.
|
|
36
36
|
*
|
|
37
|
-
* @defaultValue '3.
|
|
37
|
+
* @defaultValue '3.5'
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
engineVersion?: string | undefined;
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* The webpack plugin to build and emit the external bundle.
|
|
@@ -56,8 +56,8 @@ export class ExternalBundleWebpackPlugin {
|
|
|
56
56
|
}), {});
|
|
57
57
|
const compilerOptions = {
|
|
58
58
|
enableFiberArch: true,
|
|
59
|
-
// lynx.fetchBundle
|
|
60
|
-
targetSdkVersion: this.options.
|
|
59
|
+
// `lynx.fetchBundle` and `lynx.loadScript` require engineVersion >= 3.5
|
|
60
|
+
targetSdkVersion: this.options.engineVersion ?? '3.5',
|
|
61
61
|
};
|
|
62
62
|
const encodeOptions = {
|
|
63
63
|
compilerOptions,
|