@lynx-js/template-webpack-plugin-canary 0.9.0 → 0.9.1-canary-20251029-96545dd9
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/LynxTemplatePlugin.js +30 -32
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/template-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.9.1-canary-20251029071231-96545dd9f966c07aa64437aefc781a9f3e260861
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Remove `compiler.hooks.initialize` as [it's not called in child compilers](https://github.com/web-infra-dev/rspack/blob/aa4ad886b900770787ecddd625d3e24a51b6b99c/packages/rspack/src/rspack.ts#L78). ([#1898](https://github.com/lynx-family/lynx-stack/pull/1898))
|
|
8
|
+
|
|
3
9
|
## 0.9.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -76,16 +82,16 @@
|
|
|
76
82
|
type InlineChunkConfig =
|
|
77
83
|
| boolean
|
|
78
84
|
| InlineChunkTest
|
|
79
|
-
| { enable?: boolean |
|
|
85
|
+
| { enable?: boolean | "auto"; test: InlineChunkTest };
|
|
80
86
|
```
|
|
81
87
|
|
|
82
88
|
```ts
|
|
83
|
-
import { defineConfig } from
|
|
89
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
84
90
|
|
|
85
91
|
export default defineConfig({
|
|
86
92
|
output: {
|
|
87
93
|
inlineScripts: ({ name, size }) => {
|
|
88
|
-
return name.includes(
|
|
94
|
+
return name.includes("foo") && size < 1000;
|
|
89
95
|
},
|
|
90
96
|
},
|
|
91
97
|
});
|
|
@@ -135,7 +141,7 @@
|
|
|
135
141
|
example:
|
|
136
142
|
|
|
137
143
|
```js
|
|
138
|
-
import { defineConfig } from
|
|
144
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
139
145
|
|
|
140
146
|
export default defineConfig({
|
|
141
147
|
output: {
|
|
@@ -230,7 +236,7 @@
|
|
|
230
236
|
- Add `defaultOverflowVisible` option to `LynxTemplatePlugin`. ([#78](https://github.com/lynx-family/lynx-stack/pull/78))
|
|
231
237
|
|
|
232
238
|
```js
|
|
233
|
-
import { LynxTemplatePlugin } from
|
|
239
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
234
240
|
|
|
235
241
|
new LynxTemplatePlugin({
|
|
236
242
|
defaultOverflowVisible: false,
|
|
@@ -249,10 +255,10 @@
|
|
|
249
255
|
- 1abf8f0: Add `entryNames` parameter to `beforeEncode` hook.
|
|
250
256
|
|
|
251
257
|
```js
|
|
252
|
-
import { LynxTemplatePlugin } from
|
|
258
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
253
259
|
|
|
254
260
|
const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
|
|
255
|
-
hooks.beforeEncode.tap(
|
|
261
|
+
hooks.beforeEncode.tap("MyPlugin", ({ entryNames }) => {
|
|
256
262
|
console.log(entryNames);
|
|
257
263
|
});
|
|
258
264
|
```
|
|
@@ -126,38 +126,36 @@ class LynxTemplatePluginImpl {
|
|
|
126
126
|
this.#options = options;
|
|
127
127
|
const { createHash } = compiler.webpack.util;
|
|
128
128
|
this.hash = createHash(compiler.options.output.hashFunction ?? 'xxhash64');
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
return this.#generateTemplate(compiler, compilation, filename);
|
|
160
|
-
});
|
|
129
|
+
// entryName to fileName conversion function
|
|
130
|
+
const userOptionFilename = this.#options.filename;
|
|
131
|
+
const filenameFunction = typeof userOptionFilename === 'function'
|
|
132
|
+
? userOptionFilename
|
|
133
|
+
// Replace '[name]' with entry name
|
|
134
|
+
: (entryName) => userOptionFilename.replace(/\[name\]/g, entryName);
|
|
135
|
+
/** output filenames for the given entry names */
|
|
136
|
+
const entryNames = Object.keys(compiler.options.entry);
|
|
137
|
+
const outputFileNames = new Set((entryNames.length > 0 ? entryNames : ['main']).map((name) => filenameFunction(name)));
|
|
138
|
+
outputFileNames.forEach((outputFileName) => {
|
|
139
|
+
// convert absolute filename into relative so that webpack can
|
|
140
|
+
// generate it at correct location
|
|
141
|
+
let filename = outputFileName;
|
|
142
|
+
if (path.resolve(filename) === path.normalize(filename)) {
|
|
143
|
+
filename = path.relative(
|
|
144
|
+
/** Once initialized the path is always a string */
|
|
145
|
+
compiler.options.output.path, filename);
|
|
146
|
+
}
|
|
147
|
+
compiler.hooks.thisCompilation.tap(this.name, (compilation) => {
|
|
148
|
+
compilation.hooks.processAssets.tapPromise({
|
|
149
|
+
name: this.name,
|
|
150
|
+
stage:
|
|
151
|
+
/**
|
|
152
|
+
* Generate the html after minification and dev tooling is done
|
|
153
|
+
* and source-map is generated
|
|
154
|
+
*/
|
|
155
|
+
compiler.webpack.Compilation
|
|
156
|
+
.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,
|
|
157
|
+
}, () => {
|
|
158
|
+
return this.#generateTemplate(compiler, compilation, filename);
|
|
161
159
|
});
|
|
162
160
|
});
|
|
163
161
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/template-webpack-plugin-canary",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1-canary-20251029-96545dd9",
|
|
4
4
|
"description": "Simplifies creation of Lynx template files to serve your webpack bundles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"webpack",
|
|
@@ -40,12 +40,12 @@
|
|
|
40
40
|
"object.groupby": "^1.0.3"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
|
-
"@microsoft/api-extractor": "7.52.
|
|
44
|
-
"@types/css-tree": "^2.3.
|
|
43
|
+
"@microsoft/api-extractor": "7.52.15",
|
|
44
|
+
"@types/css-tree": "^2.3.11",
|
|
45
45
|
"@types/object.groupby": "^1.0.4",
|
|
46
|
-
"webpack": "^5.
|
|
47
|
-
"@lynx-js/
|
|
48
|
-
"@lynx-js/
|
|
46
|
+
"webpack": "^5.102.0",
|
|
47
|
+
"@lynx-js/test-tools": "0.0.0",
|
|
48
|
+
"@lynx-js/vitest-setup": "0.0.0"
|
|
49
49
|
},
|
|
50
50
|
"engines": {
|
|
51
51
|
"node": ">=18"
|