@lynx-js/template-webpack-plugin-canary 0.8.0-canary-20250620-533c0a1a → 0.8.0-canary-20250620-a43ae054

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 CHANGED
@@ -1,11 +1,17 @@
1
1
  # @lynx-js/template-webpack-plugin
2
2
 
3
- ## 0.8.0-canary-20250620090634-533c0a1acf3fadbd5d81da6762f978701a51e0ad
3
+ ## 0.8.0-canary-20250620112849-a43ae054bbe60250b0faf7a15d23b0445bb3c594
4
4
 
5
5
  ### Minor Changes
6
6
 
7
7
  - Remove `EncodeCSSOptions` and `encodeCSS` to ensure consistent encoding options are used across CSS HMR updates and the main template. ([#1033](https://github.com/lynx-family/lynx-stack/pull/1033))
8
8
 
9
+ ### Patch Changes
10
+
11
+ - Avoid generating lazy bundles when there are no chunk name. ([#1090](https://github.com/lynx-family/lynx-stack/pull/1090))
12
+
13
+ E.g.: using `import.meta.webpackContext`.
14
+
9
15
  ## 0.7.2
10
16
 
11
17
  ### Patch Changes
@@ -1,4 +1,4 @@
1
1
  import type { RuntimeModule } from 'webpack';
2
- type LynxAsyncChunksRuntimeModule = new (getChunkName: (chunkName: string | null | undefined) => string) => RuntimeModule;
2
+ type LynxAsyncChunksRuntimeModule = new (getChunkName: (chunkName: string) => string) => RuntimeModule;
3
3
  export declare function createLynxAsyncChunksRuntimeModule(webpack: typeof import('webpack')): LynxAsyncChunksRuntimeModule;
4
4
  export {};
@@ -13,7 +13,9 @@ export function createLynxAsyncChunksRuntimeModule(webpack) {
13
13
  const chunk = this.chunk;
14
14
  const compilation = this.compilation;
15
15
  return `// lynx async chunks ids
16
- ${RuntimeGlobals.lynxAsyncChunkIds} = {${Array.from(chunk.getAllAsyncChunks()).map(c => {
16
+ ${RuntimeGlobals.lynxAsyncChunkIds} = {${Array.from(chunk.getAllAsyncChunks())
17
+ .filter(c => c.name !== null && c.name !== undefined)
18
+ .map(c => {
17
19
  const filename = this.getChunkName(c.name);
18
20
  // Modified from https://github.com/webpack/webpack/blob/11449f02175f055a4540d76aa4478958c4cb297e/lib/runtime/GetChunkFilenameRuntimeModule.js#L154-L157
19
21
  const chunkPath = compilation.getPath(filename, {
@@ -23,7 +25,9 @@ ${RuntimeGlobals.lynxAsyncChunkIds} = {${Array.from(chunk.getAllAsyncChunks()).m
23
25
  // TODO: support [contenthash]
24
26
  });
25
27
  return [c.id, chunkPath];
26
- }).map(([id, path]) => `${JSON.stringify(id)}: "${path}"`).join(',\n')}}`;
28
+ })
29
+ // Do not use `JSON.stringify` on `chunkPath`, it may contains `+` which will be treated as string concatenation.
30
+ .map(([id, path]) => `${JSON.stringify(id)}: "${path}"`).join(',\n')}}`;
27
31
  }
28
32
  };
29
33
  }
@@ -53,7 +53,7 @@ export interface TemplateHooks {
53
53
  *
54
54
  * @alpha
55
55
  */
56
- asyncChunkName: SyncWaterfallHook<string | undefined | null>;
56
+ asyncChunkName: SyncWaterfallHook<string>;
57
57
  /**
58
58
  * Called before the encode process. Can be used to modify the encode options.
59
59
  *
@@ -226,7 +226,8 @@ class LynxTemplatePluginImpl {
226
226
  }
227
227
  const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
228
228
  asyncChunkGroups = groupBy(compilation.chunkGroups
229
- .filter(cg => !cg.isInitial()), cg => hooks.asyncChunkName.call(cg.name));
229
+ .filter(cg => !cg.isInitial())
230
+ .filter(cg => cg.name !== null && cg.name !== undefined), cg => hooks.asyncChunkName.call(cg.name));
230
231
  _a.#asyncChunkGroups.set(compilation, asyncChunkGroups);
231
232
  return asyncChunkGroups;
232
233
  }
@@ -247,8 +248,8 @@ class LynxTemplatePluginImpl {
247
248
  const chunkNames =
248
249
  // We use the chunk name(provided by `webpackChunkName`) as filename
249
250
  chunkGroups
250
- .map(cg => hooks.asyncChunkName.call(cg.name))
251
- .filter(chunkName => chunkName !== undefined);
251
+ .filter(cg => cg.name !== null && cg.name !== undefined)
252
+ .map(cg => hooks.asyncChunkName.call(cg.name));
252
253
  const filename = Array.from(new Set(chunkNames)).join('_');
253
254
  // If no filename is found, avoid generating async template
254
255
  if (!filename) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/template-webpack-plugin-canary",
3
- "version": "0.8.0-canary-20250620-533c0a1a",
3
+ "version": "0.8.0-canary-20250620-a43ae054",
4
4
  "description": "Simplifies creation of Lynx template files to serve your webpack bundles",
5
5
  "keywords": [
6
6
  "webpack",