@lynx-js/react-webpack-plugin 0.7.0 → 0.7.2

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,19 @@
1
1
  # @lynx-js/react-webpack-plugin
2
2
 
3
+ ## 0.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Pass sourcemap generated by rspack to swc transformer. ([#1910](https://github.com/lynx-family/lynx-stack/pull/1910))
8
+
9
+ - When engineVersion is greater than or equal to 3.1, use `__SetAttribute` to set text attribute for text node instead of creating a raw text node. ([#1880](https://github.com/lynx-family/lynx-stack/pull/1880))
10
+
11
+ ## 0.7.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Supports `@lynx-js/template-webpack-plugin` 0.9.0. ([#1705](https://github.com/lynx-family/lynx-stack/pull/1705))
16
+
3
17
  ## 0.7.0
4
18
 
5
19
  ### Minor Changes
@@ -1,4 +1,4 @@
1
- import type { LoaderContext } from '@rspack/core';
1
+ import type { LoaderDefinitionFunction } from '@rspack/core';
2
2
  import type { ReactLoaderOptions } from './options.js';
3
- declare function backgroundLoader(this: LoaderContext<ReactLoaderOptions>, content: string): void;
3
+ declare const backgroundLoader: LoaderDefinitionFunction<ReactLoaderOptions>;
4
4
  export default backgroundLoader;
@@ -3,11 +3,20 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { createRequire } from 'node:module';
5
5
  import { getBackgroundTransformOptions } from './options.js';
6
- function backgroundLoader(content) {
6
+ const backgroundLoader = function (content, sourceMap) {
7
7
  const require = createRequire(import.meta.url);
8
8
  const { transformPath = '@lynx-js/react/transform' } = this.getOptions();
9
9
  const { transformReactLynxSync } = require(transformPath);
10
- const result = transformReactLynxSync(content, getBackgroundTransformOptions.call(this));
10
+ let swcInputSourceMap;
11
+ if (this.sourceMap && sourceMap) {
12
+ if (typeof sourceMap === 'string') {
13
+ swcInputSourceMap = sourceMap;
14
+ }
15
+ else {
16
+ swcInputSourceMap = JSON.stringify(sourceMap);
17
+ }
18
+ }
19
+ const result = transformReactLynxSync(content, getBackgroundTransformOptions.call(this, swcInputSourceMap));
11
20
  if (result.errors.length > 0) {
12
21
  for (const error of result.errors) {
13
22
  if (this.experiments?.emitDiagnostic) {
@@ -67,6 +76,6 @@ function backgroundLoader(content) {
67
76
  }
68
77
  }
69
78
  this.callback(null, result.code, result.map);
70
- }
79
+ };
71
80
  export default backgroundLoader;
72
81
  //# sourceMappingURL=background.js.map
@@ -1,4 +1,4 @@
1
- import type { LoaderContext } from '@rspack/core';
1
+ import type { LoaderDefinitionFunction } from '@rspack/core';
2
2
  import type { ReactLoaderOptions } from './options.js';
3
- declare function mainThreadLoader(this: LoaderContext<ReactLoaderOptions>, content: string): void;
3
+ declare const mainThreadLoader: LoaderDefinitionFunction<ReactLoaderOptions>;
4
4
  export default mainThreadLoader;
@@ -3,11 +3,20 @@
3
3
  // LICENSE file in the root directory of this source tree.
4
4
  import { createRequire } from 'node:module';
5
5
  import { getMainThreadTransformOptions } from './options.js';
6
- function mainThreadLoader(content) {
6
+ const mainThreadLoader = function (content, sourceMap) {
7
7
  const require = createRequire(import.meta.url);
8
8
  const { transformPath = '@lynx-js/react/transform' } = this.getOptions();
9
9
  const { transformReactLynxSync } = require(transformPath);
10
- const result = transformReactLynxSync(content, getMainThreadTransformOptions.call(this));
10
+ let swcInputSourceMap;
11
+ if (this.sourceMap && sourceMap) {
12
+ if (typeof sourceMap === 'string') {
13
+ swcInputSourceMap = sourceMap;
14
+ }
15
+ else {
16
+ swcInputSourceMap = JSON.stringify(sourceMap);
17
+ }
18
+ }
19
+ const result = transformReactLynxSync(content, getMainThreadTransformOptions.call(this, swcInputSourceMap));
11
20
  if (result.errors.length > 0) {
12
21
  for (const error of result.errors) {
13
22
  if (this.experiments?.emitDiagnostic) {
@@ -81,6 +90,6 @@ function mainThreadLoader(content) {
81
90
  }
82
91
  `
83
92
  : ''), result.map);
84
- }
93
+ };
85
94
  export default mainThreadLoader;
86
95
  //# sourceMappingURL=main-thread.js.map
@@ -33,6 +33,10 @@ export interface ReactLoaderOptions {
33
33
  * Generate inline source content in source-map.
34
34
  */
35
35
  inlineSourcesContent?: boolean | undefined;
36
+ /**
37
+ * The engine version.
38
+ */
39
+ engineVersion?: string | undefined;
36
40
  }
37
- export declare function getMainThreadTransformOptions(this: LoaderContext<ReactLoaderOptions>): TransformNodiffOptions;
38
- export declare function getBackgroundTransformOptions(this: LoaderContext<ReactLoaderOptions>): TransformNodiffOptions;
41
+ export declare function getMainThreadTransformOptions(this: LoaderContext<ReactLoaderOptions>, inputSourceMap: string | undefined): TransformNodiffOptions;
42
+ export declare function getBackgroundTransformOptions(this: LoaderContext<ReactLoaderOptions>, inputSourceMap: string | undefined): TransformNodiffOptions;
@@ -14,9 +14,9 @@ const COMPONENT_PKG = '@lynx-js/react-components';
14
14
  function normalizeSlashes(file) {
15
15
  return file.replaceAll(path.win32.sep, '/');
16
16
  }
17
- function getCommonOptions() {
17
+ function getCommonOptions(inputSourceMap) {
18
18
  const filename = normalizeSlashes(path.relative(this.rootContext, this.resourcePath));
19
- const { compat, enableRemoveCSSScope, inlineSourcesContent, isDynamicComponent, defineDCE = { define: {} }, } = this.getOptions();
19
+ const { compat, enableRemoveCSSScope, inlineSourcesContent, isDynamicComponent, engineVersion, defineDCE = { define: {} }, } = this.getOptions();
20
20
  const syntax = (/\.[mc]?tsx?$/.exec(this.resourcePath))
21
21
  ? 'typescript'
22
22
  : 'ecmascript';
@@ -58,6 +58,7 @@ function getCommonOptions() {
58
58
  // See: https://github.com/swc-project/pkgs/blob/d096fdc1ac372ac045894bdda3180ef99bbcbe33/packages/swc-loader/src/index.js#L42
59
59
  sourceFileName: this.resourcePath,
60
60
  sourcemap: this.sourceMap,
61
+ ...(inputSourceMap && { inputSourceMap }),
61
62
  sourceMapColumns: this.sourceMap && !this.hot,
62
63
  inlineSourcesContent: inlineSourcesContent ?? !this.hot,
63
64
  snapshot: {
@@ -73,6 +74,7 @@ function getCommonOptions() {
73
74
  filename,
74
75
  isDynamicComponent: isDynamicComponent ?? false,
75
76
  },
77
+ engineVersion: engineVersion ?? '',
76
78
  syntaxConfig: JSON.stringify({
77
79
  syntax,
78
80
  decorators: true,
@@ -94,8 +96,8 @@ function getCommonOptions() {
94
96
  };
95
97
  return commonOptions;
96
98
  }
97
- export function getMainThreadTransformOptions() {
98
- const commonOptions = getCommonOptions.call(this);
99
+ export function getMainThreadTransformOptions(inputSourceMap) {
100
+ const commonOptions = getCommonOptions.call(this, inputSourceMap);
99
101
  const { shake } = this.getOptions();
100
102
  return {
101
103
  ...commonOptions,
@@ -170,8 +172,8 @@ export function getMainThreadTransformOptions() {
170
172
  },
171
173
  };
172
174
  }
173
- export function getBackgroundTransformOptions() {
174
- const commonOptions = getCommonOptions.call(this);
175
+ export function getBackgroundTransformOptions(inputSourceMap) {
176
+ const commonOptions = getCommonOptions.call(this, inputSourceMap);
175
177
  return {
176
178
  ...commonOptions,
177
179
  compat: typeof commonOptions.compat === 'object'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynx-js/react-webpack-plugin",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "description": "A webpack plugin for ReactLynx",
5
5
  "keywords": [
6
6
  "webpack",
@@ -37,19 +37,19 @@
37
37
  "@lynx-js/webpack-runtime-globals": "0.0.6"
38
38
  },
39
39
  "devDependencies": {
40
- "@microsoft/api-extractor": "7.52.11",
41
- "@rspack/core": "1.5.2",
40
+ "@microsoft/api-extractor": "7.52.15",
41
+ "@rspack/core": "1.6.1",
42
42
  "css-loader": "^7.1.2",
43
43
  "swc-loader": "^0.2.6",
44
- "webpack": "^5.101.3",
45
- "@lynx-js/css-extract-webpack-plugin": "0.6.2",
46
- "@lynx-js/react": "0.113.0",
47
- "@lynx-js/template-webpack-plugin": "0.8.6",
44
+ "webpack": "^5.102.0",
45
+ "@lynx-js/react": "0.114.4",
46
+ "@lynx-js/template-webpack-plugin": "0.9.1",
48
47
  "@lynx-js/test-tools": "0.0.0",
49
- "@lynx-js/vitest-setup": "0.0.0"
48
+ "@lynx-js/vitest-setup": "0.0.0",
49
+ "@lynx-js/css-extract-webpack-plugin": "0.6.4"
50
50
  },
51
51
  "peerDependencies": {
52
- "@lynx-js/template-webpack-plugin": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0"
52
+ "@lynx-js/template-webpack-plugin": "^0.4.0 || ^0.5.0 || ^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0"
53
53
  },
54
54
  "peerDependenciesMeta": {
55
55
  "@lynx-js/react": {