@lynx-js/externals-loading-webpack-plugin-canary 0.0.1 → 0.0.2-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.
Files changed (3) hide show
  1. package/CHANGELOG.md +12 -6
  2. package/lib/index.d.ts +112 -106
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @lynx-js/externals-loading-webpack-plugin
2
2
 
3
+ ## 0.0.2-canary-20251225040646-6bccf69cc42fa754d2e8e58d1911b1c4d844a3a0
4
+
5
+ ### Patch Changes
6
+
7
+ - Export `ExternalValue` ts type. ([#2037](https://github.com/lynx-family/lynx-stack/pull/2037))
8
+
3
9
  ## 0.0.1
4
10
 
5
11
  ### Patch Changes
@@ -8,18 +14,18 @@
8
14
 
9
15
  ```js
10
16
  // webpack.config.js
11
- import { ExternalsLoadingPlugin } from '@lynx-js/externals-loading-webpack-plugin';
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: 'main-thread',
17
- backgroundLayer: 'background',
22
+ mainThreadLayer: "main-thread",
23
+ backgroundLayer: "background",
18
24
  externals: {
19
25
  lodash: {
20
- url: 'http://lodash.lynx.bundle',
21
- background: { sectionPath: 'background' },
22
- mainThread: { sectionPath: 'main-thread' },
26
+ url: "http://lodash.lynx.bundle",
27
+ background: { sectionPath: "background" },
28
+ mainThread: { sectionPath: "main-thread" },
23
29
  },
24
30
  },
25
31
  }),
package/lib/index.d.ts CHANGED
@@ -63,112 +63,118 @@ export interface ExternalsLoadingPluginOptions {
63
63
  * };
64
64
  * ```
65
65
  */
66
- externals: Record<string, {
67
- /**
68
- * The bundle(lynx.bundle) url of the library. The library source should be placed in `customSections`.
69
- */
70
- url: string;
71
- /**
72
- * The name of the library. Same as https://webpack.js.org/configuration/externals/#string.
73
- *
74
- * By default, the library name is the same as the externals key. For example:
75
- *
76
- * The config
77
- *
78
- * ```js
79
- * ExternalsLoadingPlugin({
80
- * externals: {
81
- * lodash: {
82
- * url: '……',
83
- * }
84
- * }
85
- * })
86
- * ```
87
- *
88
- * Will generate the following webpack externals config:
89
- *
90
- * ```js
91
- * externals: {
92
- * lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].lodash',
93
- * }
94
- * ```
95
- *
96
- * If one external bundle contains multiple modules, should set the same library name to ensure it's loaded only once. For example:
97
- *
98
- * ```js
99
- * ExternalsLoadingPlugin({
100
- * externals: {
101
- * lodash: {
102
- * libraryName: 'Lodash',
103
- * url: '……',
104
- * },
105
- * 'lodash-es': {
106
- * libraryName: 'Lodash',
107
- * url: '……',
108
- * }
109
- * }
110
- * })
111
- * ```
112
- * Will generate the following webpack externals config:
113
- *
114
- * ```js
115
- * externals: {
116
- * lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
117
- * 'lodash-es': 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
118
- * }
119
- * ```
120
- *
121
- * You can pass an array to specify subpath of the external. Same as https://webpack.js.org/configuration/externals/#string-1. For example:
122
- *
123
- * ```js
124
- * ExternalsLoadingPlugin({
125
- * externals: {
126
- * preact: {
127
- * libraryName: ['ReactLynx', 'Preact'],
128
- * url: '……',
129
- * },
130
- * }
131
- * })
132
- * ```
133
- *
134
- * Will generate the following webpack externals config:
135
- *
136
- * ```js
137
- * externals: {
138
- * preact: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].ReactLynx.Preact',
139
- * }
140
- * ```
141
- *
142
- * @defaultValue `undefined`
143
- *
144
- * @example `Lodash`
145
- */
146
- libraryName?: string | string[];
147
- /**
148
- * Whether the source should be loaded asynchronously or not.
149
- *
150
- * @defaultValue `true`
151
- */
152
- async?: boolean;
153
- /**
154
- * The options of the background layer.
155
- *
156
- * @defaultValue `undefined`
157
- */
158
- background?: LayerOptions;
159
- /**
160
- * The options of the main-thread layer.
161
- *
162
- * @defaultValue `undefined`
163
- */
164
- mainThread?: LayerOptions;
165
- /**
166
- * The wait time in milliseconds.
167
- *
168
- * @defaultValue `2000`
169
- */
170
- timeout?: number;
171
- }>;
66
+ externals: Record<string, ExternalValue>;
67
+ }
68
+ /**
69
+ * The value item of the externals.
70
+ *
71
+ * @public
72
+ */
73
+ export interface ExternalValue {
74
+ /**
75
+ * The bundle url of the library. The library source should be placed in `customSections`.
76
+ */
77
+ url: string;
78
+ /**
79
+ * The name of the library. Same as https://webpack.js.org/configuration/externals/#string.
80
+ *
81
+ * By default, the library name is the same as the externals key. For example:
82
+ *
83
+ * The config
84
+ *
85
+ * ```js
86
+ * ExternalsLoadingPlugin({
87
+ * externals: {
88
+ * lodash: {
89
+ * url: '……',
90
+ * }
91
+ * }
92
+ * })
93
+ * ```
94
+ *
95
+ * Will generate the following webpack externals config:
96
+ *
97
+ * ```js
98
+ * externals: {
99
+ * lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].lodash',
100
+ * }
101
+ * ```
102
+ *
103
+ * If one external bundle contains multiple modules, should set the same library name to ensure it's loaded only once. For example:
104
+ *
105
+ * ```js
106
+ * ExternalsLoadingPlugin({
107
+ * externals: {
108
+ * lodash: {
109
+ * libraryName: 'Lodash',
110
+ * url: '……',
111
+ * },
112
+ * 'lodash-es': {
113
+ * libraryName: 'Lodash',
114
+ * url: '……',
115
+ * }
116
+ * }
117
+ * })
118
+ * ```
119
+ * Will generate the following webpack externals config:
120
+ *
121
+ * ```js
122
+ * externals: {
123
+ * lodash: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
124
+ * 'lodash-es': 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].Lodash',
125
+ * }
126
+ * ```
127
+ *
128
+ * You can pass an array to specify subpath of the external. Same as https://webpack.js.org/configuration/externals/#string-1. For example:
129
+ *
130
+ * ```js
131
+ * ExternalsLoadingPlugin({
132
+ * externals: {
133
+ * preact: {
134
+ * libraryName: ['ReactLynx', 'Preact'],
135
+ * url: '……',
136
+ * },
137
+ * }
138
+ * })
139
+ * ```
140
+ *
141
+ * Will generate the following webpack externals config:
142
+ *
143
+ * ```js
144
+ * externals: {
145
+ * preact: 'lynx[Symbol.for("__LYNX_EXTERNAL_GLOBAL__")].ReactLynx.Preact',
146
+ * }
147
+ * ```
148
+ *
149
+ * @defaultValue `undefined`
150
+ *
151
+ * @example `Lodash`
152
+ */
153
+ libraryName?: string | string[];
154
+ /**
155
+ * Whether the source should be loaded asynchronously or not.
156
+ *
157
+ * @defaultValue `true`
158
+ */
159
+ async?: boolean;
160
+ /**
161
+ * The options of the background layer.
162
+ *
163
+ * @defaultValue `undefined`
164
+ */
165
+ background?: LayerOptions;
166
+ /**
167
+ * The options of the main-thread layer.
168
+ *
169
+ * @defaultValue `undefined`
170
+ */
171
+ mainThread?: LayerOptions;
172
+ /**
173
+ * The wait time in milliseconds.
174
+ *
175
+ * @defaultValue `2000`
176
+ */
177
+ timeout?: number;
172
178
  }
173
179
  /**
174
180
  * The options of the background or main-thread layer.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/externals-loading-webpack-plugin-canary",
3
- "version": "0.0.1",
3
+ "version": "0.0.2-canary-20251225-6bccf69c",
4
4
  "description": "A webpack plugin to load lynx external bundles.",
5
5
  "keywords": [
6
6
  "webpack",