@lynx-js/template-webpack-plugin-canary 0.6.10 → 0.6.11-canary-20250515-7053ab4d

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,5 +1,15 @@
1
1
  # @lynx-js/template-webpack-plugin
2
2
 
3
+ ## 0.6.11-canary-20250515090026-7053ab4d9d5d74ea889ab576bf60a19bd6039556
4
+
5
+ ### Patch Changes
6
+
7
+ - Be compatible with rspack-manifest-plugin. ([#812](https://github.com/lynx-family/lynx-stack/pull/812))
8
+
9
+ Now only the `[name].lynx.bundle` and `[name].web.bundle` would exist in `manifest.json`.
10
+
11
+ See [lynx-family/lynx-stack#763](https://github.com/lynx-family/lynx-stack/issues/763) for details.
12
+
3
13
  ## 0.6.10
4
14
 
5
15
  ### Patch Changes
@@ -61,7 +71,7 @@
61
71
  - Add `defaultOverflowVisible` option to `LynxTemplatePlugin`. ([#78](https://github.com/lynx-family/lynx-stack/pull/78))
62
72
 
63
73
  ```js
64
- import { LynxTemplatePlugin } from '@lynx-js/template-webpack-plugin';
74
+ import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
65
75
 
66
76
  new LynxTemplatePlugin({
67
77
  defaultOverflowVisible: false,
@@ -80,10 +90,10 @@
80
90
  - 1abf8f0: Add `entryNames` parameter to `beforeEncode` hook.
81
91
 
82
92
  ```js
83
- import { LynxTemplatePlugin } from '@lynx-js/template-webpack-plugin';
93
+ import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
84
94
 
85
95
  const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
86
- hooks.beforeEncode.tap('MyPlugin', ({ entryNames }) => {
96
+ hooks.beforeEncode.tap("MyPlugin", ({ entryNames }) => {
87
97
  console.log(entryNames);
88
98
  });
89
99
  ```
@@ -1,4 +1,4 @@
1
- import type { Compilation, Compiler } from 'webpack';
1
+ import type { Compiler } from 'webpack';
2
2
  import type { EncodeCSSOptions } from './css/encode.js';
3
3
  import type { CSS } from './index.js';
4
4
  /**
@@ -81,12 +81,6 @@ export declare class LynxEncodePluginImpl {
81
81
  #private;
82
82
  name: string;
83
83
  constructor(compiler: Compiler, options: Required<LynxEncodePluginOptions>);
84
- /**
85
- * The deleteDebuggingAssets delete all the assets that are inlined into the template.
86
- */
87
- deleteDebuggingAssets(compilation: Compilation, assets: ({
88
- name: string;
89
- } | undefined)[]): void;
90
84
  protected options: Required<LynxEncodePluginOptions>;
91
85
  }
92
86
  export declare function isDebug(): boolean;
@@ -89,6 +89,20 @@ export class LynxEncodePluginImpl {
89
89
  || compiler.options.mode === 'development';
90
90
  compiler.hooks.thisCompilation.tap(this.name, compilation => {
91
91
  const templateHooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
92
+ const inlinedAssets = new Set();
93
+ const { Compilation } = compiler.webpack;
94
+ compilation.hooks.processAssets.tap({
95
+ name: this.name,
96
+ // `PROCESS_ASSETS_STAGE_REPORT` is the last stage of the `processAssets` hook.
97
+ // We need to run our asset deletion after this stage to ensure all assets have been processed.
98
+ // E.g.: upload source-map to sentry.
99
+ stage: Compilation.PROCESS_ASSETS_STAGE_REPORT + 1,
100
+ }, () => {
101
+ inlinedAssets.forEach((name) => {
102
+ compilation.deleteAsset(name);
103
+ });
104
+ inlinedAssets.clear();
105
+ });
92
106
  templateHooks.beforeEncode.tapPromise({
93
107
  name: this.name,
94
108
  stage: LynxEncodePlugin.BEFORE_ENCODE_STAGE,
@@ -96,14 +110,14 @@ export class LynxEncodePluginImpl {
96
110
  const { encodeData } = args;
97
111
  const { manifest } = encodeData;
98
112
  if (!isDebug() && !isDev && !isRsdoctor()) {
99
- compiler.hooks.emit.tap(this.name, () => {
100
- this.deleteDebuggingAssets(compilation, [
101
- encodeData.lepusCode.root,
102
- ...encodeData.lepusCode.chunks,
103
- ...Object.keys(manifest).map(name => ({ name })),
104
- ...encodeData.css.chunks,
105
- ]);
106
- });
113
+ [
114
+ encodeData.lepusCode.root,
115
+ ...encodeData.lepusCode.chunks,
116
+ ...Object.keys(manifest).map(name => ({ name })),
117
+ ...encodeData.css.chunks,
118
+ ]
119
+ .filter(asset => asset !== undefined)
120
+ .forEach(asset => inlinedAssets.add(asset.name));
107
121
  }
108
122
  encodeData.manifest = {
109
123
  // `app-service.js` is the entry point of a template.
@@ -147,17 +161,6 @@ export class LynxEncodePluginImpl {
147
161
  });
148
162
  });
149
163
  }
150
- /**
151
- * The deleteDebuggingAssets delete all the assets that are inlined into the template.
152
- */
153
- deleteDebuggingAssets(compilation, assets) {
154
- assets
155
- .filter(asset => asset !== undefined)
156
- .forEach(asset => deleteAsset(asset));
157
- function deleteAsset({ name }) {
158
- return compilation.deleteAsset(name);
159
- }
160
- }
161
164
  #APP_SERVICE_NAME = '/app-service.js';
162
165
  #appServiceBanner() {
163
166
  const loadScriptBanner = `(function(){'use strict';function n({tt}){`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/template-webpack-plugin-canary",
3
- "version": "0.6.10",
3
+ "version": "0.6.11-canary-20250515-7053ab4d",
4
4
  "description": "Simplifies creation of Lynx template files to serve your webpack bundles",
5
5
  "keywords": [
6
6
  "webpack",
@@ -40,10 +40,10 @@
40
40
  "object.groupby": "^1.0.3"
41
41
  },
42
42
  "devDependencies": {
43
- "@microsoft/api-extractor": "7.52.5",
43
+ "@microsoft/api-extractor": "7.52.8",
44
44
  "@types/css-tree": "^2.3.10",
45
45
  "@types/object.groupby": "^1.0.4",
46
- "webpack": "^5.99.6",
46
+ "webpack": "^5.99.8",
47
47
  "@lynx-js/vitest-setup": "0.0.0",
48
48
  "@lynx-js/test-tools": "0.0.0"
49
49
  },