@unpackjs/plugin-react 1.5.0 → 1.5.1

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/dist/index.cjs CHANGED
@@ -41,12 +41,12 @@ const PLUGIN_NAME = "unpack:react";
41
41
  const pluginReact = (options = {}) => {
42
42
  return {
43
43
  name: PLUGIN_NAME,
44
- bundlerConfig: async (config, { unpackConfig, mergeConfig, bundler }) => {
45
- let next = config;
44
+ bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig, bundler }) => {
45
+ let config = originalConfig;
46
46
  if (options.clickToComponent) {
47
- next = await (0, import_click_to_component.addClickToComponentSupport)({ config, bundler });
47
+ config = await (0, import_click_to_component.addClickToComponentSupport)({ config, bundler });
48
48
  }
49
- next = (0, import_mpa.addMpaSupport)({ config, unpackConfig });
49
+ config = (0, import_mpa.addMpaSupport)({ config, unpackConfig });
50
50
  const jsExclude = [/node_modules[\\/](?!\.unpack)/];
51
51
  const swcLoader = unpackConfig.bundler === "rspack" ? "builtin:swc-loader" : require.resolve("swc-loader");
52
52
  const ReactRefreshPlugin = unpackConfig.bundler === "rspack" ? import_plugin_react_refresh.default : import_react_refresh_webpack_plugin.default;
@@ -72,7 +72,7 @@ const pluginReact = (options = {}) => {
72
72
  }
73
73
  };
74
74
  };
75
- return mergeConfig(next, {
75
+ return mergeConfig(config, {
76
76
  module: {
77
77
  rules: [
78
78
  {
package/dist/index.js CHANGED
@@ -17,12 +17,12 @@ const PLUGIN_NAME = "unpack:react";
17
17
  const pluginReact = (options = {}) => {
18
18
  return {
19
19
  name: PLUGIN_NAME,
20
- bundlerConfig: async (config, { unpackConfig, mergeConfig, bundler }) => {
21
- let next = config;
20
+ bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig, bundler }) => {
21
+ let config = originalConfig;
22
22
  if (options.clickToComponent) {
23
- next = await addClickToComponentSupport({ config, bundler });
23
+ config = await addClickToComponentSupport({ config, bundler });
24
24
  }
25
- next = addMpaSupport({ config, unpackConfig });
25
+ config = addMpaSupport({ config, unpackConfig });
26
26
  const jsExclude = [/node_modules[\\/](?!\.unpack)/];
27
27
  const swcLoader = unpackConfig.bundler === "rspack" ? "builtin:swc-loader" : require.resolve("swc-loader");
28
28
  const ReactRefreshPlugin = unpackConfig.bundler === "rspack" ? RspackReactRefreshPlugin : WebpackReactRefreshPlugin;
@@ -48,7 +48,7 @@ const pluginReact = (options = {}) => {
48
48
  }
49
49
  };
50
50
  };
51
- return mergeConfig(next, {
51
+ return mergeConfig(config, {
52
52
  module: {
53
53
  rules: [
54
54
  {
package/dist/mpa.cjs CHANGED
@@ -44,11 +44,11 @@ const addMpaSupport = ({
44
44
  const userOptions = (0, import_shared.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {};
45
45
  const getPageConfig = (indexPath) => {
46
46
  const filePath = import_node_path.default.join(indexPath, "../config.json");
47
- let config2 = {};
47
+ let pageConfig = {};
48
48
  if (import_node_fs.default.existsSync(filePath)) {
49
- config2 = JSON.parse(import_node_fs.default.readFileSync(filePath, "utf-8"));
49
+ pageConfig = JSON.parse(import_node_fs.default.readFileSync(filePath, "utf-8"));
50
50
  }
51
- return config2;
51
+ return pageConfig;
52
52
  };
53
53
  const getPathInJs = (absPath) => {
54
54
  return JSON.stringify(absPath).slice(1, -1);
@@ -70,13 +70,13 @@ import '${getAbsPathForEntry(curr)}';`.trimStart();
70
70
  const rootElement = `document.getElementById('${unpackConfig.html?.mountId}')`;
71
71
  const reactDOMSource = "react-dom/client";
72
72
  const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX});`;
73
- Object.entries(entry2).forEach(([entryName, config2]) => {
73
+ Object.entries(entry2).forEach(([entryName, entryConfig]) => {
74
74
  const filePath = import_node_path.default.join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
75
75
  const tpl = `
76
76
  // DO NOT CHANGE IT MANUALLY!
77
77
  import React from 'react';
78
78
  import ReactDOM from '${reactDOMSource}';
79
- import App from '${getPathInJs(config2.import[0])}';${layoutImport && `
79
+ import App from '${getPathInJs(entryConfig.import[0])}';${layoutImport && `
80
80
  ${layoutImport}`}
81
81
  ${globalImport}
82
82
  ${renderer}
@@ -86,7 +86,7 @@ ${renderer}
86
86
  import_node_fs.default.mkdirSync(dir, { recursive: true });
87
87
  }
88
88
  import_node_fs.default.writeFileSync(filePath, tpl, "utf-8");
89
- config2.import[0] = filePath;
89
+ entryConfig.import[0] = filePath;
90
90
  });
91
91
  return entry2;
92
92
  };
package/dist/mpa.js CHANGED
@@ -29,11 +29,11 @@ const addMpaSupport = ({
29
29
  const userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {};
30
30
  const getPageConfig = (indexPath) => {
31
31
  const filePath = path2.join(indexPath, "../config.json");
32
- let config2 = {};
32
+ let pageConfig = {};
33
33
  if (fs.existsSync(filePath)) {
34
- config2 = JSON.parse(fs.readFileSync(filePath, "utf-8"));
34
+ pageConfig = JSON.parse(fs.readFileSync(filePath, "utf-8"));
35
35
  }
36
- return config2;
36
+ return pageConfig;
37
37
  };
38
38
  const getPathInJs = (absPath) => {
39
39
  return JSON.stringify(absPath).slice(1, -1);
@@ -55,13 +55,13 @@ import '${getAbsPathForEntry(curr)}';`.trimStart();
55
55
  const rootElement = `document.getElementById('${unpackConfig.html?.mountId}')`;
56
56
  const reactDOMSource = "react-dom/client";
57
57
  const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX});`;
58
- Object.entries(entry2).forEach(([entryName, config2]) => {
58
+ Object.entries(entry2).forEach(([entryName, entryConfig]) => {
59
59
  const filePath = path2.join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
60
60
  const tpl = `
61
61
  // DO NOT CHANGE IT MANUALLY!
62
62
  import React from 'react';
63
63
  import ReactDOM from '${reactDOMSource}';
64
- import App from '${getPathInJs(config2.import[0])}';${layoutImport && `
64
+ import App from '${getPathInJs(entryConfig.import[0])}';${layoutImport && `
65
65
  ${layoutImport}`}
66
66
  ${globalImport}
67
67
  ${renderer}
@@ -71,7 +71,7 @@ ${renderer}
71
71
  fs.mkdirSync(dir, { recursive: true });
72
72
  }
73
73
  fs.writeFileSync(filePath, tpl, "utf-8");
74
- config2.import[0] = filePath;
74
+ entryConfig.import[0] = filePath;
75
75
  });
76
76
  return entry2;
77
77
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/plugin-react",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -31,7 +31,7 @@
31
31
  "@swc/helpers": "0.5.13",
32
32
  "launch-editor": "2.9.1",
33
33
  "html-webpack-plugin": "5.6.0",
34
- "@unpackjs/shared": "^1.5.0"
34
+ "@unpackjs/shared": "^1.5.1"
35
35
  },
36
36
  "scripts": {
37
37
  "dev": "modern build --watch",