@lynx-js/external-bundle-rsbuild-plugin-canary 0.0.0 → 0.0.1-canary-20251223-23796630

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 ADDED
@@ -0,0 +1,28 @@
1
+ # @lynx-js/external-bundle-rsbuild-plugin
2
+
3
+ ## 0.0.1-canary-20251223110143-23796630019f144e5ef03fe1788e71c60f7719b3
4
+
5
+ ### Patch Changes
6
+
7
+ - Introduce `@lynx-js/external-bundle-rsbuild-plugin`. ([#2006](https://github.com/lynx-family/lynx-stack/pull/2006))
8
+
9
+ ```ts
10
+ // lynx.config.ts
11
+ import { pluginExternalBundle } from "@lynx-js/external-bundle-rsbuild-plugin";
12
+ import { pluginReactLynx } from "@lynx-js/react-rsbuild-plugin";
13
+
14
+ export default {
15
+ plugins: [
16
+ pluginReactLynx(),
17
+ pluginExternalBundle({
18
+ externals: {
19
+ lodash: {
20
+ url: "http://lodash.lynx.bundle",
21
+ background: { sectionPath: "background" },
22
+ mainThread: { sectionPath: "mainThread" },
23
+ },
24
+ },
25
+ }),
26
+ ],
27
+ };
28
+ ```
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ <p align="center">
2
+ <a href="https://lynxjs.org/rspeedy" target="blank"><img src="https://lf-lynx.tiktok-cdns.com/obj/lynx-artifacts-oss-sg/lynx-website/assets/rspeedy-banner.png" alt="Rspeedy Logo" /></a>
3
+ </p>
4
+
5
+ <p>
6
+ <a aria-label="NPM version" href="https://www.npmjs.com/package/@lynx-js/external-bundle-rsbuild-plugin">
7
+ <img alt="" src="https://img.shields.io/npm/v/@lynx-js/external-bundle-rsbuild-plugin?logo=npm">
8
+ </a>
9
+ <a aria-label="License" href="https://www.npmjs.com/package/@lynx-js/external-bundle-rsbuild-plugin">
10
+ <img src="https://img.shields.io/badge/License-Apache--2.0-blue" alt="license" />
11
+ </a>
12
+ </p>
13
+
14
+ ## Getting Started
15
+
16
+ ```bash
17
+ npm install -D @lynx-js/external-bundle-rsbuild-plugin
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ```ts
23
+ // lynx.config.ts
24
+ import { pluginExternalBundle } from '@lynx-js/external-bundle-rsbuild-plugin'
25
+ import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
26
+
27
+ export default {
28
+ plugins: [
29
+ pluginReactLynx(),
30
+ pluginExternalBundle({
31
+ externals: {
32
+ lodash: {
33
+ url: 'http://lodash.lynx.bundle',
34
+ background: { sectionPath: 'background' },
35
+ mainThread: { sectionPath: 'mainThread' },
36
+ },
37
+ },
38
+ }),
39
+ ],
40
+ }
41
+ ```
42
+
43
+ ## Documentation
44
+
45
+ Visit [Lynx Website](https://lynxjs.org/api/rspeedy/external-bundle-rsbuild-plugin) to view the full documentation.
46
+
47
+ ## Contributing
48
+
49
+ Contributions to Rspeedy are welcome and highly appreciated. However, before you jump right into it, we would like you to review our [Contribution Guidelines](/CONTRIBUTING.md) to make sure you have a smooth experience contributing to this project.
50
+
51
+ ## License
52
+
53
+ Rspeedy is Apache-2.0 licensed.
package/lib/index.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * A rsbuild plugin for loading external bundles using externals-loading-webpack-plugin.
5
+ */
6
+ import type { RsbuildPlugin } from '@rsbuild/core';
7
+ import type { ExternalsLoadingPluginOptions } from '@lynx-js/externals-loading-webpack-plugin';
8
+ /**
9
+ * Options for the external-bundle-rsbuild-plugin.
10
+ *
11
+ * @public
12
+ */
13
+ export type PluginExternalBundleOptions = Pick<ExternalsLoadingPluginOptions, 'externals'>;
14
+ /**
15
+ * Create a rsbuild plugin for loading external bundles.
16
+ *
17
+ * This plugin wraps the externals-loading-webpack-plugin and automatically
18
+ * retrieves layer names from the react-rsbuild-plugin via api.useExposed.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * // lynx.config.ts
23
+ * import { pluginExternalBundle } from '@lynx-js/external-bundle-rsbuild-plugin'
24
+ * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
25
+ *
26
+ * export default {
27
+ * plugins: [
28
+ * pluginReactLynx(),
29
+ * pluginExternalBundle({
30
+ * externals: {
31
+ * lodash: {
32
+ * url: 'http://lodash.lynx.bundle',
33
+ * background: { sectionPath: 'background' },
34
+ * mainThread: { sectionPath: 'mainThread' },
35
+ * },
36
+ * },
37
+ * }),
38
+ * ],
39
+ * }
40
+ * ```
41
+ *
42
+ * @public
43
+ */
44
+ export declare function pluginExternalBundle(options: PluginExternalBundleOptions): RsbuildPlugin;
package/lib/index.js ADDED
@@ -0,0 +1,56 @@
1
+ // Copyright 2024 The Lynx Authors. All rights reserved.
2
+ // Licensed under the Apache License Version 2.0 that can be found in the
3
+ // LICENSE file in the root directory of this source tree.
4
+ import { ExternalsLoadingPlugin } from '@lynx-js/externals-loading-webpack-plugin';
5
+ /**
6
+ * Create a rsbuild plugin for loading external bundles.
7
+ *
8
+ * This plugin wraps the externals-loading-webpack-plugin and automatically
9
+ * retrieves layer names from the react-rsbuild-plugin via api.useExposed.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * // lynx.config.ts
14
+ * import { pluginExternalBundle } from '@lynx-js/external-bundle-rsbuild-plugin'
15
+ * import { pluginReactLynx } from '@lynx-js/react-rsbuild-plugin'
16
+ *
17
+ * export default {
18
+ * plugins: [
19
+ * pluginReactLynx(),
20
+ * pluginExternalBundle({
21
+ * externals: {
22
+ * lodash: {
23
+ * url: 'http://lodash.lynx.bundle',
24
+ * background: { sectionPath: 'background' },
25
+ * mainThread: { sectionPath: 'mainThread' },
26
+ * },
27
+ * },
28
+ * }),
29
+ * ],
30
+ * }
31
+ * ```
32
+ *
33
+ * @public
34
+ */
35
+ export function pluginExternalBundle(options) {
36
+ return {
37
+ name: 'lynx:external-bundle',
38
+ setup(api) {
39
+ api.modifyRspackConfig((config) => {
40
+ // Get layer names from react-rsbuild-plugin
41
+ const LAYERS = api.useExposed(Symbol.for('LAYERS'));
42
+ if (!LAYERS) {
43
+ throw new Error('external-bundle-rsbuild-plugin requires exposed `LAYERS`.');
44
+ }
45
+ config.plugins = config.plugins || [];
46
+ config.plugins.push(new ExternalsLoadingPlugin({
47
+ backgroundLayer: LAYERS.BACKGROUND,
48
+ mainThreadLayer: LAYERS.MAIN_THREAD,
49
+ externals: options.externals,
50
+ }));
51
+ return config;
52
+ });
53
+ },
54
+ };
55
+ }
56
+ //# sourceMappingURL=index.js.map
package/package.json CHANGED
@@ -1,9 +1,50 @@
1
1
  {
2
2
  "name": "@lynx-js/external-bundle-rsbuild-plugin-canary",
3
- "version": "0.0.0",
3
+ "version": "0.0.1-canary-20251223-23796630",
4
4
  "description": "A rsbuild plugin for loading lynx external bundles.",
5
- "keywords": [],
5
+ "keywords": [
6
+ "rsbuild",
7
+ "Lynx",
8
+ "externals",
9
+ "bundle"
10
+ ],
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "https://github.com/lynx-family/lynx-stack.git",
14
+ "directory": "packages/rspeedy/plugin-external-bundle"
15
+ },
6
16
  "license": "Apache-2.0",
17
+ "author": {
18
+ "name": "Hengchang Lu",
19
+ "email": "luhengchang228@gmail.com"
20
+ },
7
21
  "type": "module",
8
- "main": "index.js"
9
- }
22
+ "exports": {
23
+ ".": {
24
+ "types": "./lib/index.d.ts",
25
+ "default": "./lib/index.js"
26
+ },
27
+ "./package.json": "./package.json"
28
+ },
29
+ "types": "./lib/index.d.ts",
30
+ "files": [
31
+ "lib",
32
+ "!lib/**/*.js.map",
33
+ "CHANGELOG.md",
34
+ "README.md"
35
+ ],
36
+ "dependencies": {
37
+ "@lynx-js/externals-loading-webpack-plugin": "npm:@lynx-js/externals-loading-webpack-plugin-canary@0.0.1"
38
+ },
39
+ "devDependencies": {
40
+ "@microsoft/api-extractor": "7.55.2",
41
+ "@rsbuild/core": "1.6.13"
42
+ },
43
+ "engines": {
44
+ "node": ">=18"
45
+ },
46
+ "scripts": {
47
+ "api-extractor": "api-extractor run --verbose",
48
+ "test": "pnpm -w run test --project rspeedy/externals"
49
+ }
50
+ }
package/index.js DELETED
@@ -1 +0,0 @@
1
- export {}