@lynx-js/template-webpack-plugin-canary 0.7.2 → 0.8.0-canary-20250617-241fa2c2
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 +10 -4
- package/lib/LynxEncodePlugin.d.ts +0 -24
- package/lib/LynxEncodePlugin.js +0 -24
- package/lib/LynxTemplatePlugin.d.ts +6 -1
- package/lib/index.d.ts +2 -2
- package/package.json +1 -1
- package/lib/css/encode.d.ts +0 -27
- package/lib/css/encode.js +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/template-webpack-plugin
|
|
2
2
|
|
|
3
|
+
## 0.8.0-canary-20250617115045-241fa2c26be69a72f12fb42d17df3790a5350438
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
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
|
+
|
|
3
9
|
## 0.7.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -32,7 +38,7 @@
|
|
|
32
38
|
example:
|
|
33
39
|
|
|
34
40
|
```js
|
|
35
|
-
import { defineConfig } from
|
|
41
|
+
import { defineConfig } from "@lynx-js/rspeedy";
|
|
36
42
|
|
|
37
43
|
export default defineConfig({
|
|
38
44
|
output: {
|
|
@@ -127,7 +133,7 @@
|
|
|
127
133
|
- Add `defaultOverflowVisible` option to `LynxTemplatePlugin`. ([#78](https://github.com/lynx-family/lynx-stack/pull/78))
|
|
128
134
|
|
|
129
135
|
```js
|
|
130
|
-
import { LynxTemplatePlugin } from
|
|
136
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
131
137
|
|
|
132
138
|
new LynxTemplatePlugin({
|
|
133
139
|
defaultOverflowVisible: false,
|
|
@@ -146,10 +152,10 @@
|
|
|
146
152
|
- 1abf8f0: Add `entryNames` parameter to `beforeEncode` hook.
|
|
147
153
|
|
|
148
154
|
```js
|
|
149
|
-
import { LynxTemplatePlugin } from
|
|
155
|
+
import { LynxTemplatePlugin } from "@lynx-js/template-webpack-plugin";
|
|
150
156
|
|
|
151
157
|
const hooks = LynxTemplatePlugin.getLynxTemplatePluginHooks(compilation);
|
|
152
|
-
hooks.beforeEncode.tap(
|
|
158
|
+
hooks.beforeEncode.tap("MyPlugin", ({ entryNames }) => {
|
|
153
159
|
console.log(entryNames);
|
|
154
160
|
});
|
|
155
161
|
```
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { Compiler } from 'webpack';
|
|
2
|
-
import type { EncodeCSSOptions } from './css/encode.js';
|
|
3
|
-
import type { CSS } from './index.js';
|
|
4
2
|
/**
|
|
5
3
|
* The options for LynxEncodePluginOptions
|
|
6
4
|
*
|
|
@@ -29,27 +27,6 @@ export declare class LynxEncodePlugin {
|
|
|
29
27
|
*/
|
|
30
28
|
static BEFORE_EMIT_STAGE: number;
|
|
31
29
|
constructor(options?: LynxEncodePluginOptions | undefined);
|
|
32
|
-
/**
|
|
33
|
-
* Encode CSS chunks into a template.
|
|
34
|
-
*
|
|
35
|
-
* @param cssChunks - The CSS chunks' content.
|
|
36
|
-
* @param options - The encode options.
|
|
37
|
-
* @returns The buffer of the template.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```
|
|
41
|
-
* (await encodeCSS(
|
|
42
|
-
* '.red { color: red; }',
|
|
43
|
-
* {
|
|
44
|
-
* targetSdkVersion: '3.2',
|
|
45
|
-
* enableCSSSelector: true,
|
|
46
|
-
* },
|
|
47
|
-
* )).toString('base64'),
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
static encodeCSS(cssChunks: string[], options: EncodeCSSOptions, plugins?: CSS.Plugin[], encode?: (options: any) => Promise<{
|
|
51
|
-
buffer: Buffer;
|
|
52
|
-
}>): Promise<Buffer>;
|
|
53
30
|
/**
|
|
54
31
|
* `defaultOptions` is the default options that the {@link LynxEncodePlugin} uses.
|
|
55
32
|
*
|
|
@@ -86,4 +63,3 @@ export declare class LynxEncodePluginImpl {
|
|
|
86
63
|
}
|
|
87
64
|
export declare function isDebug(): boolean;
|
|
88
65
|
export declare function isRsdoctor(): boolean;
|
|
89
|
-
export type { EncodeCSSOptions } from './css/encode.js';
|
package/lib/LynxEncodePlugin.js
CHANGED
|
@@ -24,30 +24,6 @@ export class LynxEncodePlugin {
|
|
|
24
24
|
constructor(options) {
|
|
25
25
|
this.options = options;
|
|
26
26
|
}
|
|
27
|
-
/**
|
|
28
|
-
* Encode CSS chunks into a template.
|
|
29
|
-
*
|
|
30
|
-
* @param cssChunks - The CSS chunks' content.
|
|
31
|
-
* @param options - The encode options.
|
|
32
|
-
* @returns The buffer of the template.
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* ```
|
|
36
|
-
* (await encodeCSS(
|
|
37
|
-
* '.red { color: red; }',
|
|
38
|
-
* {
|
|
39
|
-
* targetSdkVersion: '3.2',
|
|
40
|
-
* enableCSSSelector: true,
|
|
41
|
-
* },
|
|
42
|
-
* )).toString('base64'),
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
static async encodeCSS(cssChunks, options, plugins,
|
|
46
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
47
|
-
encode) {
|
|
48
|
-
const { encodeCSS } = await import('./css/encode.js');
|
|
49
|
-
return encodeCSS(cssChunks, options, plugins, encode);
|
|
50
|
-
}
|
|
51
27
|
/**
|
|
52
28
|
* `defaultOptions` is the default options that the {@link LynxEncodePlugin} uses.
|
|
53
29
|
*
|
|
@@ -2,6 +2,11 @@ import { AsyncSeriesBailHook, AsyncSeriesWaterfallHook, SyncWaterfallHook } from
|
|
|
2
2
|
import type { Asset, Compilation, Compiler } from 'webpack';
|
|
3
3
|
import type * as CSS from '@lynx-js/css-serializer';
|
|
4
4
|
import { cssChunksToMap } from './css/cssChunksToMap.js';
|
|
5
|
+
/**
|
|
6
|
+
* The options for encoding a Lynx bundle.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*/
|
|
5
10
|
export interface EncodeOptions {
|
|
6
11
|
manifest: Record<string, string | undefined>;
|
|
7
12
|
compilerOptions: Record<string, string | boolean>;
|
|
@@ -66,7 +71,7 @@ export interface TemplateHooks {
|
|
|
66
71
|
*/
|
|
67
72
|
encode: AsyncSeriesBailHook<{
|
|
68
73
|
encodeOptions: EncodeOptions;
|
|
69
|
-
intermediate
|
|
74
|
+
intermediate?: string;
|
|
70
75
|
}, {
|
|
71
76
|
buffer: Buffer;
|
|
72
77
|
debugInfo: string;
|
package/lib/index.d.ts
CHANGED
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* A webpack plugin that simplifies creation of `template.js` files to serve your bundles.
|
|
5
5
|
*/
|
|
6
6
|
export { LynxTemplatePlugin } from './LynxTemplatePlugin.js';
|
|
7
|
-
export type { LynxTemplatePluginOptions, TemplateHooks, } from './LynxTemplatePlugin.js';
|
|
7
|
+
export type { LynxTemplatePluginOptions, TemplateHooks, EncodeOptions, } from './LynxTemplatePlugin.js';
|
|
8
8
|
export { LynxEncodePlugin } from './LynxEncodePlugin.js';
|
|
9
|
-
export type { LynxEncodePluginOptions
|
|
9
|
+
export type { LynxEncodePluginOptions } from './LynxEncodePlugin.js';
|
|
10
10
|
export { WebEncodePlugin } from './WebEncodePlugin.js';
|
|
11
11
|
export * as CSSPlugins from './css/plugins/index.js';
|
|
12
12
|
export * as CSS from './css/index.js';
|
package/package.json
CHANGED
package/lib/css/encode.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { CSS } from '../index.js';
|
|
2
|
-
/**
|
|
3
|
-
* The options for encoding CSS.
|
|
4
|
-
*
|
|
5
|
-
* @public
|
|
6
|
-
*/
|
|
7
|
-
export interface EncodeCSSOptions {
|
|
8
|
-
/**
|
|
9
|
-
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.enableCSSSelector}
|
|
10
|
-
*/
|
|
11
|
-
enableCSSSelector: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.enableRemoveCSSScope}
|
|
14
|
-
*/
|
|
15
|
-
enableRemoveCSSScope: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.enableCSSInvalidation}
|
|
18
|
-
*/
|
|
19
|
-
enableCSSInvalidation: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* {@inheritdoc @lynx-js/react-rsbuild-plugin#PluginReactLynxOptions.enableRemoveCSSScope}
|
|
22
|
-
*/
|
|
23
|
-
targetSdkVersion: string;
|
|
24
|
-
}
|
|
25
|
-
export declare function encodeCSS(cssChunks: string[], { enableCSSSelector, enableRemoveCSSScope, enableCSSInvalidation, targetSdkVersion, }: EncodeCSSOptions, plugins?: CSS.Plugin[], encode?: (options: any) => Promise<{
|
|
26
|
-
buffer: Buffer;
|
|
27
|
-
}>): Promise<Buffer>;
|
package/lib/css/encode.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
// Copyright 2024 The Lynx Authors. All rights reserved.
|
|
2
|
-
// Licensed under the Apache License Version 2.0 that can be found in the
|
|
3
|
-
// LICENSE file in the root directory of this source tree.
|
|
4
|
-
import { removeFunctionWhiteSpace } from '@lynx-js/css-serializer/dist/plugins/removeFunctionWhiteSpace.js';
|
|
5
|
-
import { cssChunksToMap } from './cssChunksToMap.js';
|
|
6
|
-
export async function encodeCSS(cssChunks, { enableCSSSelector, enableRemoveCSSScope, enableCSSInvalidation, targetSdkVersion, }, plugins = [removeFunctionWhiteSpace()],
|
|
7
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
8
|
-
encode = (options) => {
|
|
9
|
-
const buffer = Buffer.from(JSON.stringify(options));
|
|
10
|
-
return Promise.resolve({
|
|
11
|
-
buffer,
|
|
12
|
-
});
|
|
13
|
-
}) {
|
|
14
|
-
const css = cssChunksToMap(cssChunks, plugins, enableCSSSelector);
|
|
15
|
-
const encodeOptions = {
|
|
16
|
-
compilerOptions: {
|
|
17
|
-
// Do not remove this, it will crash :)
|
|
18
|
-
enableFiberArch: true,
|
|
19
|
-
useLepusNG: true,
|
|
20
|
-
bundleModuleMode: 'ReturnByFunction',
|
|
21
|
-
enableCSSSelector,
|
|
22
|
-
enableCSSInvalidation,
|
|
23
|
-
targetSdkVersion,
|
|
24
|
-
},
|
|
25
|
-
sourceContent: {
|
|
26
|
-
appType: 'card',
|
|
27
|
-
config: {
|
|
28
|
-
lepusStrict: true,
|
|
29
|
-
enableRemoveCSSScope,
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
css,
|
|
33
|
-
manifest: {},
|
|
34
|
-
lepusCode: {
|
|
35
|
-
root: undefined,
|
|
36
|
-
lepusChunk: {},
|
|
37
|
-
},
|
|
38
|
-
customSections: {},
|
|
39
|
-
};
|
|
40
|
-
const { buffer } = await encode(encodeOptions);
|
|
41
|
-
return buffer;
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=encode.js.map
|