@lynx-js/template-webpack-plugin-canary 0.8.3 → 0.8.4-canary-20250815-51a0b190
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 +13 -7
- package/lib/LynxEncodePlugin.js +24 -5
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/template-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.8.4-canary-20250815073754-51a0b19078cb18c13f4f3e2ca4f471aa4ddeaa05
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fix invalid `module.exports=;` syntax in app-service.js. ([#1501](https://github.com/lynx-family/lynx-stack/pull/1501))
|
|
8
|
+
|
|
3
9
|
## 0.8.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -45,16 +51,16 @@
|
|
|
45
51
|
type InlineChunkConfig =
|
|
46
52
|
| boolean
|
|
47
53
|
| InlineChunkTest
|
|
48
|
-
| { enable?: boolean |
|
|
54
|
+
| { enable?: boolean | "auto"; test: InlineChunkTest };
|
|
49
55
|
```
|
|
50
56
|
|
|
51
57
|
```ts
|
|
52
|
-
import { defineConfig } from
|
|
58
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
53
59
|
|
|
54
60
|
export default defineConfig({
|
|
55
61
|
output: {
|
|
56
62
|
inlineScripts: ({ name, size }) => {
|
|
57
|
-
return name.includes(
|
|
63
|
+
return name.includes("foo") && size < 1000;
|
|
58
64
|
},
|
|
59
65
|
},
|
|
60
66
|
});
|
|
@@ -104,7 +110,7 @@
|
|
|
104
110
|
example:
|
|
105
111
|
|
|
106
112
|
```js
|
|
107
|
-
import { defineConfig } from
|
|
113
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
108
114
|
|
|
109
115
|
export default defineConfig({
|
|
110
116
|
output: {
|
|
@@ -199,7 +205,7 @@
|
|
|
199
205
|
- Add `defaultOverflowVisible` option to `LynxTemplatePlugin`. ([#78](https://github.com/lynx-family/lynx-stack/pull/78))
|
|
200
206
|
|
|
201
207
|
```js
|
|
202
|
-
import { LynxTemplatePlugin } from
|
|
208
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
203
209
|
|
|
204
210
|
new LynxTemplatePlugin({
|
|
205
211
|
defaultOverflowVisible: false,
|
|
@@ -218,10 +224,10 @@
|
|
|
218
224
|
- 1abf8f0: Add `entryNames` parameter to `beforeEncode` hook.
|
|
219
225
|
|
|
220
226
|
```js
|
|
221
|
-
import { LynxTemplatePlugin } from
|
|
227
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
222
228
|
|
|
223
229
|
const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
|
|
224
|
-
hooks.beforeEncode.tap(
|
|
230
|
+
hooks.beforeEncode.tap("MyPlugin", ({ entryNames }) => {
|
|
225
231
|
console.log(entryNames);
|
|
226
232
|
});
|
|
227
233
|
```
|
package/lib/LynxEncodePlugin.js
CHANGED
|
@@ -134,10 +134,7 @@ export class LynxEncodePluginImpl {
|
|
|
134
134
|
// ```
|
|
135
135
|
'/app-service.js': [
|
|
136
136
|
this.#appServiceBanner(),
|
|
137
|
-
|
|
138
|
-
';module.exports=',
|
|
139
|
-
Object.keys(inlinedManifest).map(name => `lynx.requireModule('${this.#formatJSName(name, '/')}',globDynamicComponentEntry?globDynamicComponentEntry:'__Card__')`).join(','),
|
|
140
|
-
';',
|
|
137
|
+
this.#appServiceContent(externalManifest, inlinedManifest, publicPath),
|
|
141
138
|
this.#appServiceFooter(),
|
|
142
139
|
].join(''),
|
|
143
140
|
...Object.fromEntries(Object.entries(inlinedManifest).map(([name, content]) => [
|
|
@@ -165,13 +162,35 @@ export class LynxEncodePluginImpl {
|
|
|
165
162
|
const amdBanner = `tt.define('${this.#APP_SERVICE_NAME}',function(e,module,_,i,l,u,a,c,s,f,p,d,h,v,g,y,lynx){`;
|
|
166
163
|
return loadScriptBanner + amdBanner;
|
|
167
164
|
}
|
|
165
|
+
#appServiceContent(externalManifest, inlinedManifest, publicPath) {
|
|
166
|
+
const parts = [];
|
|
167
|
+
const externalKeys = Object.keys(externalManifest);
|
|
168
|
+
if (externalKeys.length > 0) {
|
|
169
|
+
const externalRequires = externalKeys
|
|
170
|
+
.map(name => `lynx.requireModuleAsync(${JSON.stringify(this.#formatJSName(name, publicPath))})`)
|
|
171
|
+
.join(',');
|
|
172
|
+
parts.push(externalRequires, ';');
|
|
173
|
+
}
|
|
174
|
+
const inlinedKeys = Object.keys(inlinedManifest);
|
|
175
|
+
if (inlinedKeys.length > 0) {
|
|
176
|
+
parts.push('module.exports=');
|
|
177
|
+
const inlinedRequires = inlinedKeys
|
|
178
|
+
.map(name => `lynx.requireModule(${JSON.stringify(this.#formatJSName(name, '/'))},globDynamicComponentEntry?globDynamicComponentEntry:'__Card__')`)
|
|
179
|
+
.join(',');
|
|
180
|
+
parts.push(inlinedRequires, ';');
|
|
181
|
+
}
|
|
182
|
+
return parts.join('');
|
|
183
|
+
}
|
|
168
184
|
#appServiceFooter() {
|
|
169
185
|
const loadScriptFooter = `}return{init:n}})()`;
|
|
170
186
|
const amdFooter = `});return tt.require('${this.#APP_SERVICE_NAME}');`;
|
|
171
187
|
return amdFooter + loadScriptFooter;
|
|
172
188
|
}
|
|
173
189
|
#formatJSName(name, publicPath) {
|
|
174
|
-
|
|
190
|
+
const base = !publicPath || publicPath === 'auto' ? '/' : publicPath;
|
|
191
|
+
const prefixed = base.endsWith('/') ? base : `${base}/`;
|
|
192
|
+
const trimmed = name.startsWith('/') ? name.slice(1) : name;
|
|
193
|
+
return `${prefixed}${trimmed}`;
|
|
175
194
|
}
|
|
176
195
|
#shouldInlineScript(name, size) {
|
|
177
196
|
const inlineConfig = this.options.inlineScripts;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/template-webpack-plugin-canary",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.4-canary-20250815-51a0b190",
|
|
4
4
|
"description": "Simplifies creation of Lynx template files to serve your webpack bundles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"@microsoft/api-extractor": "7.52.10",
|
|
44
44
|
"@types/css-tree": "^2.3.10",
|
|
45
45
|
"@types/object.groupby": "^1.0.4",
|
|
46
|
-
"webpack": "^5.
|
|
46
|
+
"webpack": "^5.101.2",
|
|
47
47
|
"@lynx-js/test-tools": "0.0.0",
|
|
48
48
|
"@lynx-js/vitest-setup": "0.0.0"
|
|
49
49
|
},
|