@unpackjs/plugin-react 2.0.0 → 2.1.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EAEzB,KAAK,YAAY,EAIlB,MAAM,gBAAgB,CAAA;AA6BvB,eAAO,MAAM,2BAA2B,8BAGrC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CAmC/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,KAAK,oBAAoB,EAKzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AA6BvB,eAAO,MAAM,2BAA2B,GAAU,2BAG/C;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
@@ -1,15 +1,15 @@
1
- import __rslib_shim_module__ from 'module';
1
+ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
3
  import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
4
4
  import { dirname as __webpack_dirname__ } from "node:path";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
6
- import * as __WEBPACK_EXTERNAL_MODULE_node_http_2dc67212__ from "node:http";
7
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
8
- import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
9
- import * as __WEBPACK_EXTERNAL_MODULE_launch_editor_c6c8c971__ from "launch-editor";
5
+ import node_fs from "node:fs";
6
+ import node_http from "node:http";
7
+ import node_path from "node:path";
8
+ import { TEMP_DIR, getPathInJs, getPort, restartCleaners } from "@unpackjs/core";
9
+ import launch_editor from "launch-editor";
10
10
  var click_to_component_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
11
11
  const createServer = ()=>new Promise((resolve)=>{
12
- const server = __WEBPACK_EXTERNAL_MODULE_node_http_2dc67212__["default"].createServer((req, res)=>{
12
+ const server = node_http.createServer((req, res)=>{
13
13
  const params = new URLSearchParams(req.url.slice(1));
14
14
  const file = decodeURIComponent(params.get('file'));
15
15
  const line = Number(params.get('line'));
@@ -21,20 +21,20 @@ const createServer = ()=>new Promise((resolve)=>{
21
21
  'Access-Control-Allow-Private-Network': 'true'
22
22
  });
23
23
  res.end('ok');
24
- (0, __WEBPACK_EXTERNAL_MODULE_launch_editor_c6c8c971__["default"])(`${file}:${line}:${column}`);
24
+ launch_editor(`${file}:${line}:${column}`);
25
25
  });
26
- (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPort)().then((port)=>{
26
+ getPort().then((port)=>{
27
27
  server.listen(port, ()=>{
28
28
  resolve({
29
29
  port
30
30
  });
31
31
  });
32
32
  });
33
- __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.restartCleaners.push(()=>new Promise((resolve)=>server.close(()=>resolve())));
33
+ restartCleaners.push(()=>new Promise((resolve)=>server.close(()=>resolve())));
34
34
  });
35
35
  const applyClickToComponentConfig = async ({ config, unpackConfig })=>{
36
36
  const { port } = await createServer();
37
- const injectScript = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(click_to_component_dirname, './injectScript.js'), 'utf-8');
37
+ const injectScript = node_fs.readFileSync(node_path.resolve(click_to_component_dirname, './injectScript.js'), 'utf-8');
38
38
  const scriptTpl = `
39
39
  if (!document.querySelector('#__click-to-component__')) {
40
40
  const script = document.createElement('script')
@@ -45,20 +45,20 @@ if (!document.querySelector('#__click-to-component__')) {
45
45
  }`;
46
46
  if (unpackConfig.mpa) Object.values(config.entry).forEach((entryConfig)=>{
47
47
  const filePath = entryConfig.import[0];
48
- const content = __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, 'utf-8');
49
- __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, `${scriptTpl}\n${content}`, 'utf-8');
48
+ const content = node_fs.readFileSync(filePath, 'utf-8');
49
+ node_fs.writeFileSync(filePath, `${scriptTpl}\n${content}`, 'utf-8');
50
50
  });
51
51
  else {
52
- const realEntryPath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(config.context, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMP_DIR, 'entries', `index.${port}.jsx`);
52
+ const realEntryPath = node_path.resolve(config.context, TEMP_DIR, 'entries', `index.${port}.jsx`);
53
53
  const tpl = `
54
54
  ${scriptTpl}
55
- import '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(Object.values(config.entry)[0]))}'
55
+ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
56
56
  `;
57
- const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(realEntryPath);
58
- if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
57
+ const dir = node_path.dirname(realEntryPath);
58
+ if (!node_fs.existsSync(dir)) node_fs.mkdirSync(dir, {
59
59
  recursive: true
60
60
  });
61
- __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(realEntryPath, tpl, 'utf-8');
61
+ node_fs.writeFileSync(realEntryPath, tpl, 'utf-8');
62
62
  config.entry = {
63
63
  main: realEntryPath
64
64
  };
package/dist/index.cjs CHANGED
@@ -33,8 +33,8 @@ var __webpack_require__ = {};
33
33
  var __webpack_exports__ = {};
34
34
  __webpack_require__.r(__webpack_exports__);
35
35
  __webpack_require__.d(__webpack_exports__, {
36
- PLUGIN_NAME: ()=>PLUGIN_NAME,
37
- pluginReact: ()=>pluginReact
36
+ pluginReact: ()=>pluginReact,
37
+ PLUGIN_NAME: ()=>PLUGIN_NAME
38
38
  });
39
39
  const external_node_path_namespaceObject = require("node:path");
40
40
  var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
@@ -130,6 +130,23 @@ const pluginReact = (options = {})=>{
130
130
  }
131
131
  }
132
132
  ].filter(Boolean)
133
+ },
134
+ {
135
+ test: /\.svg$/i,
136
+ type: 'asset',
137
+ resourceQuery: /url/
138
+ },
139
+ {
140
+ test: /\.svg$/i,
141
+ issuer: /\.[jt]sx?$/,
142
+ resourceQuery: {
143
+ not: [
144
+ /url/
145
+ ]
146
+ },
147
+ use: [
148
+ require.resolve('@svgr/webpack')
149
+ ]
133
150
  }
134
151
  ]
135
152
  },
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,YAAY,EAOlB,MAAM,gBAAgB,CAAA;AAKvB,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AACD,eAAO,MAAM,WAAW,aAAa,kBAAkB,KAAQ,YAuF9D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EASL,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAKvB,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB,CAAA;AACD,eAAO,MAAM,WAAW,GAAI,UAAS,kBAAuB,KAAG,YAoG9D,CAAA"}
package/dist/index.js CHANGED
@@ -2,13 +2,13 @@ import __rslib_shim_module__ from 'module';
2
2
  const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
3
3
  import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
4
4
  import { dirname as __webpack_dirname__ } from "node:path";
5
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
6
- import * as __WEBPACK_EXTERNAL_MODULE__pmmmwh_react_refresh_webpack_plugin_143c1848__ from "@pmmmwh/react-refresh-webpack-plugin";
7
- import * as __WEBPACK_EXTERNAL_MODULE__rspack_plugin_react_refresh_db0cf031__ from "@rspack/plugin-react-refresh";
8
- import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
9
- import * as __WEBPACK_EXTERNAL_MODULE__click_to_component_index_js_1f068bff__ from "./click-to-component/index.js";
10
- import * as __WEBPACK_EXTERNAL_MODULE__mpa_js_c5cf22d9__ from "./mpa.js";
11
- import * as __WEBPACK_EXTERNAL_MODULE__splitChunks_js_b23140d8__ from "./splitChunks.js";
5
+ import node_path from "node:path";
6
+ import react_refresh_webpack_plugin from "@pmmmwh/react-refresh-webpack-plugin";
7
+ import plugin_react_refresh from "@rspack/plugin-react-refresh";
8
+ import { DEFAULT_BROWSERSLIST, HtmlWebpackPlugin, getUserDepPath, getUserDepVersion, isDev, isDevServer, logger, rspack } from "@unpackjs/core";
9
+ import { applyClickToComponentConfig } from "./click-to-component/index.js";
10
+ import { applyMpaConfig } from "./mpa.js";
11
+ import { applySplitChunksConfig } from "./splitChunks.js";
12
12
  var src_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
13
13
  const PLUGIN_NAME = 'unpack:react';
14
14
  const pluginReact = (options = {})=>{
@@ -18,30 +18,30 @@ const pluginReact = (options = {})=>{
18
18
  bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
19
19
  let config = originalConfig;
20
20
  const isRspack = 'rspack' === unpackConfig.bundler;
21
- const HtmlPlugin = isRspack ? __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.rspack.HtmlRspackPlugin : __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.HtmlWebpackPlugin;
22
- config = (0, __WEBPACK_EXTERNAL_MODULE__mpa_js_c5cf22d9__.applyMpaConfig)({
21
+ const HtmlPlugin = isRspack ? rspack.HtmlRspackPlugin : HtmlWebpackPlugin;
22
+ config = applyMpaConfig({
23
23
  config,
24
24
  unpackConfig,
25
25
  mergeConfig,
26
26
  HtmlPlugin
27
27
  });
28
- if ((0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDev)() && clickToComponent) config = await (0, __WEBPACK_EXTERNAL_MODULE__click_to_component_index_js_1f068bff__.applyClickToComponentConfig)({
28
+ if (isDev() && clickToComponent) config = await applyClickToComponentConfig({
29
29
  config,
30
30
  unpackConfig
31
31
  });
32
- config = (0, __WEBPACK_EXTERNAL_MODULE__splitChunks_js_b23140d8__.applySplitChunksConfig)({
32
+ config = applySplitChunksConfig({
33
33
  config,
34
34
  unpackConfig
35
35
  });
36
- if (reactCompiler && !(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getUserDepPath)(unpackConfig.root, 'react-compiler-runtime')) {
37
- __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.logger.error('dependency "react-compiler-runtime" not found, did you install it?');
36
+ if (reactCompiler && !getUserDepPath(unpackConfig.root, 'react-compiler-runtime')) {
37
+ logger.error('dependency "react-compiler-runtime" not found, did you install it?');
38
38
  process.exit(1);
39
39
  }
40
40
  const jsExclude = [
41
41
  /node_modules[\\/](?!\.unpack)/
42
42
  ];
43
43
  const swcLoader = isRspack ? 'builtin:swc-loader' : require.resolve('swc-loader');
44
- const ReactRefreshPlugin = isRspack ? __WEBPACK_EXTERNAL_MODULE__rspack_plugin_react_refresh_db0cf031__["default"] : __WEBPACK_EXTERNAL_MODULE__pmmmwh_react_refresh_webpack_plugin_143c1848__["default"];
44
+ const ReactRefreshPlugin = isRspack ? plugin_react_refresh : react_refresh_webpack_plugin;
45
45
  const getSwcOptions = ({ tsx })=>({
46
46
  jsc: {
47
47
  parser: {
@@ -54,12 +54,12 @@ const pluginReact = (options = {})=>{
54
54
  transform: {
55
55
  react: {
56
56
  runtime: 'automatic',
57
- refresh: (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDevServer)()
57
+ refresh: isDevServer()
58
58
  }
59
59
  }
60
60
  },
61
61
  env: {
62
- targets: __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.DEFAULT_BROWSERSLIST
62
+ targets: DEFAULT_BROWSERSLIST
63
63
  }
64
64
  });
65
65
  return mergeConfig(config, {
@@ -88,23 +88,40 @@ const pluginReact = (options = {})=>{
88
88
  })
89
89
  },
90
90
  reactCompiler && {
91
- loader: __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(src_dirname, './react-compiler-loader/index.cjs'),
91
+ loader: node_path.resolve(src_dirname, './react-compiler-loader/index.cjs'),
92
92
  options: {
93
- target: (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getUserDepVersion)(unpackConfig.root, 'react').split('.')[0]
93
+ target: getUserDepVersion(unpackConfig.root, 'react').split('.')[0]
94
94
  }
95
95
  }
96
96
  ].filter(Boolean)
97
+ },
98
+ {
99
+ test: /\.svg$/i,
100
+ type: 'asset',
101
+ resourceQuery: /url/
102
+ },
103
+ {
104
+ test: /\.svg$/i,
105
+ issuer: /\.[jt]sx?$/,
106
+ resourceQuery: {
107
+ not: [
108
+ /url/
109
+ ]
110
+ },
111
+ use: [
112
+ require.resolve('@svgr/webpack')
113
+ ]
97
114
  }
98
115
  ]
99
116
  },
100
117
  plugins: [
101
- (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDevServer)() && new ReactRefreshPlugin({
118
+ isDevServer() && new ReactRefreshPlugin({
102
119
  overlay: false
103
120
  })
104
121
  ].filter(Boolean),
105
122
  resolve: {
106
123
  alias: {
107
- '@swc/helpers': __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(require.resolve('@swc/helpers/package.json'))
124
+ '@swc/helpers': node_path.dirname(require.resolve('@swc/helpers/package.json'))
108
125
  }
109
126
  }
110
127
  });
package/dist/mpa.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EAQlB,MAAM,gBAAgB,CAAA;AAYvB,eAAO,MAAM,cAAc,uDAKxB;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,CAAC,GAAG,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,CAAA;IACzE,UAAU,EAAE,GAAG,CAAA;CAChB,KAAG,oBA6GH,CAAA"}
1
+ {"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAUzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAYvB,eAAO,MAAM,cAAc,GAAI,oDAK5B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,CAAC,GAAG,OAAO,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,CAAA;IACzE,UAAU,EAAE,GAAG,CAAA;CAChB,KAAG,oBA6GH,CAAA"}
package/dist/mpa.js CHANGED
@@ -1,43 +1,43 @@
1
- import __rslib_shim_module__ from 'module';
1
+ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
4
- import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
5
- import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
3
+ import node_fs from "node:fs";
4
+ import node_path from "node:path";
5
+ import { TEMPLATE_CONTENT, TEMP_DIR, colors, getPathInJs, isDevServer, isFunction, isPlainObject, logger, removeDir } from "@unpackjs/core";
6
6
  const applyMpaConfig = ({ config, unpackConfig, mergeConfig, HtmlPlugin })=>{
7
7
  if (!unpackConfig.mpa) return config;
8
8
  const isRspack = 'rspack' === unpackConfig.bundler;
9
- const tempDirectory = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(__WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMP_DIR, 'mpa');
10
- const userOptions = (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {};
9
+ const tempDirectory = node_path.join(TEMP_DIR, 'mpa');
10
+ const userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {};
11
11
  const getPageConfig = (indexPath)=>{
12
- const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(indexPath, '../config.json');
12
+ const filePath = node_path.join(indexPath, '../config.json');
13
13
  let pageConfig = {};
14
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(filePath)) pageConfig = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, 'utf-8'));
14
+ if (node_fs.existsSync(filePath)) pageConfig = JSON.parse(node_fs.readFileSync(filePath, 'utf-8'));
15
15
  return pageConfig;
16
16
  };
17
17
  const createTempFile = (entry)=>{
18
18
  var _userOptions_globalImport, _unpackConfig_html;
19
- (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.removeDir)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, tempDirectory));
20
- const globalImport = (null == (_userOptions_globalImport = userOptions.globalImport) ? void 0 : _userOptions_globalImport.reduce((acc, curr)=>`${acc}\nimport '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(unpackConfig.root, curr))}'`, '')) || '';
19
+ removeDir(node_path.join(unpackConfig.root, tempDirectory));
20
+ const globalImport = (null == (_userOptions_globalImport = userOptions.globalImport) ? void 0 : _userOptions_globalImport.reduce((acc, curr)=>`${acc}\nimport '${getPathInJs(node_path.resolve(unpackConfig.root, curr))}'`, '')) || '';
21
21
  const { layout } = userOptions;
22
- const layoutImport = layout ? `import Layout from '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(unpackConfig.root, layout))}'` : '';
22
+ const layoutImport = layout ? `import Layout from '${getPathInJs(node_path.resolve(unpackConfig.root, layout))}'` : '';
23
23
  const layoutJSX = layout ? '<Layout><App /></Layout>' : '<App />';
24
24
  const rootElement = `document.getElementById('${null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.mountId}')`;
25
25
  const reactDOMSource = 'react-dom/client';
26
26
  const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX})`;
27
27
  Object.entries(entry).forEach(([entryName, entryConfig])=>{
28
- const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
28
+ const filePath = node_path.join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
29
29
  const tpl = `
30
30
  import React from 'react'
31
31
  import ReactDOM from '${reactDOMSource}'
32
- import App from '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(entryConfig.import[0])}'${layoutImport && `\n${layoutImport}`}
32
+ import App from '${getPathInJs(entryConfig.import[0])}'${layoutImport && `\n${layoutImport}`}
33
33
  ${globalImport}
34
34
  ${renderer}
35
35
  `;
36
- const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filePath);
37
- if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
36
+ const dir = node_path.dirname(filePath);
37
+ if (!node_fs.existsSync(dir)) node_fs.mkdirSync(dir, {
38
38
  recursive: true
39
39
  });
40
- __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, tpl, 'utf-8');
40
+ node_fs.writeFileSync(filePath, tpl, 'utf-8');
41
41
  entryConfig.import[0] = filePath;
42
42
  });
43
43
  return entry;
@@ -52,15 +52,15 @@ ${renderer}
52
52
  '.jsx'
53
53
  ];
54
54
  for (const extension of extensions){
55
- const indexFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, `index${extension}`);
56
- if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(indexFilePath)) return indexFilePath;
55
+ const indexFilePath = node_path.join(dir, `index${extension}`);
56
+ if (node_fs.existsSync(indexFilePath)) return indexFilePath;
57
57
  }
58
58
  return null;
59
59
  };
60
- const pagesRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, 'src', 'pages');
61
- __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readdirSync(pagesRoot).forEach((filename)=>{
60
+ const pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages');
61
+ node_fs.readdirSync(pagesRoot).forEach((filename)=>{
62
62
  if (filename.startsWith('.')) return;
63
- const indexFilePath = getIndexFilePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(pagesRoot, filename));
63
+ const indexFilePath = getIndexFilePath(node_path.join(pagesRoot, filename));
64
64
  if (indexFilePath) {
65
65
  var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
66
66
  const pageConfig = getPageConfig(indexFilePath);
@@ -71,10 +71,10 @@ ${renderer}
71
71
  indexFilePath
72
72
  ]
73
73
  };
74
- if (pageConfig.template) pageConfig.template = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(indexFilePath, '../', pageConfig.template);
74
+ if (pageConfig.template) pageConfig.template = node_path.join(indexFilePath, '../', pageConfig.template);
75
75
  html.push({
76
76
  template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
77
- templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? isRspack ? void 0 : false : __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMPLATE_CONTENT),
77
+ templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? isRspack ? void 0 : false : TEMPLATE_CONTENT),
78
78
  minify: false,
79
79
  filename: `${entryName}.html`,
80
80
  chunks: [
@@ -83,7 +83,7 @@ ${renderer}
83
83
  ...pageConfig,
84
84
  templateParameters: {
85
85
  mountId: null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.mountId,
86
- title: (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isFunction)(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
86
+ title: isFunction(null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title) ? null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title({
87
87
  entryName
88
88
  }) : (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.title) || '',
89
89
  headTag: (null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.headTag) || '',
@@ -93,7 +93,7 @@ ${renderer}
93
93
  });
94
94
  }
95
95
  });
96
- (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDevServer)() || __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${__WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.colors.dim('[MPA]')}`);
96
+ isDevServer() || logger.info(`collect entries in ${(performance.now() - start).toFixed(2)}ms ${colors.dim('[MPA]')}`);
97
97
  return {
98
98
  entry,
99
99
  html
@@ -1,9 +1,9 @@
1
- import __rslib_shim_module__ from 'module';
1
+ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE__babel_core_1832d21b__ from "@babel/core";
4
- import * as __WEBPACK_EXTERNAL_MODULE__babel_plugin_proposal_decorators_ac6ac103__ from "@babel/plugin-proposal-decorators";
5
- import * as __WEBPACK_EXTERNAL_MODULE__babel_plugin_transform_class_properties_a153ae05__ from "@babel/plugin-transform-class-properties";
6
- import * as __WEBPACK_EXTERNAL_MODULE_babel_plugin_react_compiler_4f9bef75__ from "babel-plugin-react-compiler";
3
+ import { transformAsync } from "@babel/core";
4
+ import plugin_proposal_decorators from "@babel/plugin-proposal-decorators";
5
+ import plugin_transform_class_properties from "@babel/plugin-transform-class-properties";
6
+ import babel_plugin_react_compiler from "babel-plugin-react-compiler";
7
7
  const defaultBabelParsePlugins = [
8
8
  'jsx',
9
9
  "typescript"
@@ -12,23 +12,23 @@ async function reactCompilerLoader(input, _inputSourceMap) {
12
12
  const callback = this.async();
13
13
  try {
14
14
  const options = this.getOptions();
15
- const result = await __WEBPACK_EXTERNAL_MODULE__babel_core_1832d21b__.transformAsync(input, {
15
+ const result = await transformAsync(input, {
16
16
  sourceFileName: this.resourcePath,
17
17
  filename: this.resourcePath,
18
18
  cloneInputAst: false,
19
19
  plugins: [
20
20
  [
21
- __WEBPACK_EXTERNAL_MODULE_babel_plugin_react_compiler_4f9bef75__["default"],
21
+ babel_plugin_react_compiler,
22
22
  options
23
23
  ],
24
24
  [
25
- __WEBPACK_EXTERNAL_MODULE__babel_plugin_proposal_decorators_ac6ac103__["default"],
25
+ plugin_proposal_decorators,
26
26
  {
27
27
  legacy: true
28
28
  }
29
29
  ],
30
30
  [
31
- __WEBPACK_EXTERNAL_MODULE__babel_plugin_transform_class_properties_a153ae05__["default"]
31
+ plugin_transform_class_properties
32
32
  ]
33
33
  ],
34
34
  parserOpts: {
@@ -1 +1 @@
1
- {"version":3,"file":"splitChunks.d.ts","sourceRoot":"","sources":["../src/splitChunks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAEzB,KAAK,YAAY,EAElB,MAAM,gBAAgB,CAAA;AAEvB,eAAO,MAAM,sBAAsB,8BAGhC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,yCA2BA,CAAA"}
1
+ {"version":3,"file":"splitChunks.d.ts","sourceRoot":"","sources":["../src/splitChunks.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,oBAAoB,EAGzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAEvB,eAAO,MAAM,sBAAsB,GAAI,2BAGpC;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,yCA2BA,CAAA"}
@@ -1,13 +1,13 @@
1
- import __rslib_shim_module__ from 'module';
1
+ import 'module';
2
2
  /*#__PURE__*/ import.meta.url;
3
- import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
3
+ import { isDevServer } from "@unpackjs/core";
4
4
  const applySplitChunksConfig = ({ config, unpackConfig })=>{
5
5
  if ('split-by-experience' !== unpackConfig.performance.chunkSplit.strategy) return config;
6
6
  const currentConfig = config.optimization.splitChunks;
7
7
  const extraGroups = {};
8
8
  extraGroups.react = {
9
9
  name: 'lib-react',
10
- test: (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDevServer)() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
10
+ test: isDevServer() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
11
11
  priority: 0
12
12
  };
13
13
  extraGroups.router = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/plugin-react",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,12 +23,13 @@
23
23
  "access": "public"
24
24
  },
25
25
  "dependencies": {
26
- "@babel/core": "7.27.1",
26
+ "@babel/core": "7.27.4",
27
27
  "@babel/plugin-proposal-decorators": "7.27.1",
28
28
  "@babel/plugin-transform-class-properties": "7.27.1",
29
- "@pmmmwh/react-refresh-webpack-plugin": "0.6.0",
29
+ "@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
30
30
  "@rspack/plugin-react-refresh": "1.4.3",
31
- "@swc/core": "1.11.29",
31
+ "@svgr/webpack": "8.1.0",
32
+ "@swc/core": "1.12.7",
32
33
  "@swc/helpers": "0.5.17",
33
34
  "babel-plugin-react-compiler": "latest",
34
35
  "launch-editor": "2.10.0",
@@ -36,10 +37,10 @@
36
37
  "swc-loader": "0.2.6"
37
38
  },
38
39
  "devDependencies": {
39
- "@unpackjs/core": "2.0.0"
40
+ "@unpackjs/core": "2.3.0"
40
41
  },
41
42
  "peerDependencies": {
42
- "@unpackjs/core": "2.0.0"
43
+ "@unpackjs/core": "2.x"
43
44
  },
44
45
  "scripts": {
45
46
  "dev": "rslib build --watch",