@unpackjs/plugin-react 2.1.1 → 3.0.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.
package/dist/index.cjs CHANGED
@@ -25,8 +25,6 @@ __webpack_require__.r(__webpack_exports__), __webpack_require__.d(__webpack_expo
25
25
  });
26
26
  let external_node_path_namespaceObject = require("node:path");
27
27
  var external_node_path_default = __webpack_require__.n(external_node_path_namespaceObject);
28
- let react_refresh_webpack_plugin_namespaceObject = require("@pmmmwh/react-refresh-webpack-plugin");
29
- var react_refresh_webpack_plugin_default = __webpack_require__.n(react_refresh_webpack_plugin_namespaceObject);
30
28
  let plugin_react_refresh_namespaceObject = require("@rspack/plugin-react-refresh");
31
29
  var plugin_react_refresh_default = __webpack_require__.n(plugin_react_refresh_namespaceObject);
32
30
  let core_namespaceObject = require("@unpackjs/core"), external_node_fs_namespaceObject = require("node:fs");
@@ -77,9 +75,9 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
77
75
  };
78
76
  }
79
77
  return config;
80
- }, applyMpaConfig = ({ config, unpackConfig, mergeConfig, HtmlPlugin })=>{
78
+ }, applyMpaConfig = ({ config, unpackConfig })=>{
81
79
  if (!unpackConfig.mpa) return config;
82
- let isRspack = 'rspack' === unpackConfig.bundler, tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
80
+ let tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
83
81
  let start = performance.now(), entry = {}, html = [], pagesRoot = external_node_path_default().join(unpackConfig.root, 'src', 'pages');
84
82
  return external_node_fs_default().readdirSync(pagesRoot).forEach((filename)=>{
85
83
  if (filename.startsWith('.')) return;
@@ -104,8 +102,8 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
104
102
  indexFilePath
105
103
  ]
106
104
  }, pageConfig.template && (pageConfig.template = external_node_path_default().join(indexFilePath, '../', pageConfig.template)), html.push({
107
- template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
108
- templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? !!isRspack && void 0 : core_namespaceObject.TEMPLATE_CONTENT),
105
+ template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
106
+ templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : core_namespaceObject.TEMPLATE_CONTENT),
109
107
  minify: !1,
110
108
  filename: `${entryName}.html`,
111
109
  chunks: [
@@ -128,7 +126,7 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
128
126
  html
129
127
  };
130
128
  })();
131
- return config = mergeConfig(config, {
129
+ return config = (0, core_namespaceObject.mergeConfig)(config, {
132
130
  entry: ((entry)=>{
133
131
  var _userOptions_globalImport, _unpackConfig_html;
134
132
  let root = unpackConfig.root;
@@ -147,7 +145,7 @@ ${renderer}
147
145
  }), external_node_fs_default().writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
148
146
  }), entry;
149
147
  })(entry),
150
- plugins: html.map((h)=>new HtmlPlugin(h))
148
+ plugins: html.map((h)=>new core_namespaceObject.rspack.HtmlRspackPlugin(h))
151
149
  });
152
150
  }, applySplitChunksConfig = ({ config, unpackConfig })=>{
153
151
  if ('split-by-experience' !== unpackConfig.performance.chunkSplit.strategy) return config;
@@ -168,26 +166,21 @@ ${renderer}
168
166
  }
169
167
  }, config;
170
168
  }, PLUGIN_NAME = 'unpack:react', pluginReact = (options = {})=>{
171
- let { clickToComponent, reactCompiler } = options;
169
+ let { clickToComponent } = options;
172
170
  return {
173
171
  name: PLUGIN_NAME,
174
172
  bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
175
- let config = originalConfig, isRspack = 'rspack' === unpackConfig.bundler;
173
+ let config = originalConfig;
176
174
  config = applyMpaConfig({
177
- config,
178
- unpackConfig,
179
- mergeConfig,
180
- HtmlPlugin: isRspack ? core_namespaceObject.rspack.HtmlRspackPlugin : core_namespaceObject.HtmlWebpackPlugin
181
- }), (0, core_namespaceObject.isDev)() && clickToComponent && (config = await applyClickToComponentConfig({
182
175
  config,
183
176
  unpackConfig
184
- })), config = applySplitChunksConfig({
177
+ }), (0, core_namespaceObject.isDev)() && clickToComponent && (config = await applyClickToComponentConfig({
185
178
  config,
186
179
  unpackConfig
187
- }), reactCompiler && !(0, core_namespaceObject.getUserDepPath)(unpackConfig.root, 'react-compiler-runtime') && (core_namespaceObject.logger.error('dependency "react-compiler-runtime" not found, did you install it?'), process.exit(1));
180
+ }));
188
181
  let jsExclude = [
189
182
  /node_modules[\\/](?!\.unpack)/
190
- ], swcLoader = isRspack ? 'builtin:swc-loader' : require.resolve('swc-loader'), ReactRefreshPlugin = isRspack ? plugin_react_refresh_default() : react_refresh_webpack_plugin_default(), getSwcOptions = ({ tsx })=>({
183
+ ], getSwcOptions = ({ tsx })=>({
191
184
  jsc: {
192
185
  parser: {
193
186
  tsx,
@@ -207,7 +200,10 @@ ${renderer}
207
200
  targets: core_namespaceObject.DEFAULT_BROWSERSLIST
208
201
  }
209
202
  });
210
- return mergeConfig(config, {
203
+ return mergeConfig(config = applySplitChunksConfig({
204
+ config,
205
+ unpackConfig
206
+ }), {
211
207
  module: {
212
208
  rules: [
213
209
  {
@@ -215,7 +211,7 @@ ${renderer}
215
211
  exclude: jsExclude,
216
212
  use: [
217
213
  {
218
- loader: swcLoader,
214
+ loader: 'builtin:swc-loader',
219
215
  options: getSwcOptions({
220
216
  tsx: !1
221
217
  })
@@ -227,18 +223,12 @@ ${renderer}
227
223
  exclude: jsExclude,
228
224
  use: [
229
225
  {
230
- loader: swcLoader,
226
+ loader: 'builtin:swc-loader',
231
227
  options: getSwcOptions({
232
228
  tsx: !0
233
229
  })
234
- },
235
- reactCompiler && {
236
- loader: external_node_path_default().resolve(__dirname, './reactCompilerLoader.mjs'),
237
- options: {
238
- target: (0, core_namespaceObject.getUserDepVersion)(unpackConfig.root, 'react').split('.')[0]
239
- }
240
230
  }
241
- ].filter(Boolean)
231
+ ]
242
232
  },
243
233
  {
244
234
  test: /\.svg$/i,
@@ -260,7 +250,7 @@ ${renderer}
260
250
  ]
261
251
  },
262
252
  plugins: [
263
- (0, core_namespaceObject.isDevServer)() && new ReactRefreshPlugin({
253
+ (0, core_namespaceObject.isDevServer)() && new (plugin_react_refresh_default())({
264
254
  overlay: !1
265
255
  })
266
256
  ].filter(Boolean),
package/dist/index.js CHANGED
@@ -3,9 +3,8 @@ let require = __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
5
  import node_path from "node:path";
6
- import react_refresh_webpack_plugin from "@pmmmwh/react-refresh-webpack-plugin";
7
6
  import plugin_react_refresh from "@rspack/plugin-react-refresh";
8
- import { DEFAULT_BROWSERSLIST, HtmlWebpackPlugin, TEMPLATE_CONTENT, TEMP_DIR, colors, getPathInJs, getPort, getUserDepPath, getUserDepVersion, isDev, isDevServer, isFunction, isPlainObject, logger, removeDir, restartCleaners, rspack } from "@unpackjs/core";
7
+ import { DEFAULT_BROWSERSLIST, TEMPLATE_CONTENT, TEMP_DIR, colors, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, logger, mergeConfig as core_mergeConfig, removeDir, restartCleaners, rspack } from "@unpackjs/core";
9
8
  import node_fs from "node:fs";
10
9
  import node_http from "node:http";
11
10
  import launch_editor from "launch-editor";
@@ -52,17 +51,15 @@ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
52
51
  };
53
52
  }
54
53
  return config;
55
- };
56
- var src_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
57
- let PLUGIN_NAME = 'unpack:react', pluginReact = (options = {})=>{
58
- let { clickToComponent, reactCompiler } = options;
54
+ }, PLUGIN_NAME = 'unpack:react', pluginReact = (options = {})=>{
55
+ let { clickToComponent } = options;
59
56
  return {
60
57
  name: PLUGIN_NAME,
61
58
  bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
62
- let config = originalConfig, isRspack = 'rspack' === unpackConfig.bundler;
63
- config = (({ config, unpackConfig, mergeConfig, HtmlPlugin })=>{
59
+ let config = originalConfig;
60
+ config = (({ config, unpackConfig })=>{
64
61
  if (!unpackConfig.mpa) return config;
65
- let isRspack = 'rspack' === unpackConfig.bundler, tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
62
+ let tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
66
63
  let start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages');
67
64
  return node_fs.readdirSync(pagesRoot).forEach((filename)=>{
68
65
  if (filename.startsWith('.')) return;
@@ -87,8 +84,8 @@ let PLUGIN_NAME = 'unpack:react', pluginReact = (options = {})=>{
87
84
  indexFilePath
88
85
  ]
89
86
  }, pageConfig.template && (pageConfig.template = node_path.join(indexFilePath, '../', pageConfig.template)), html.push({
90
- template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
91
- templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? !!isRspack && void 0 : TEMPLATE_CONTENT),
87
+ template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
88
+ templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
92
89
  minify: !1,
93
90
  filename: `${entryName}.html`,
94
91
  chunks: [
@@ -111,7 +108,7 @@ let PLUGIN_NAME = 'unpack:react', pluginReact = (options = {})=>{
111
108
  html
112
109
  };
113
110
  })();
114
- return config = mergeConfig(config, {
111
+ return config = core_mergeConfig(config, {
115
112
  entry: ((entry)=>{
116
113
  var _userOptions_globalImport, _unpackConfig_html;
117
114
  let root = unpackConfig.root;
@@ -130,41 +127,18 @@ ${renderer}
130
127
  }), node_fs.writeFileSync(filePath, tpl, 'utf-8'), entryConfig.import[0] = filePath;
131
128
  }), entry;
132
129
  })(entry),
133
- plugins: html.map((h)=>new HtmlPlugin(h))
130
+ plugins: html.map((h)=>new rspack.HtmlRspackPlugin(h))
134
131
  });
135
132
  })({
136
- config,
137
- unpackConfig,
138
- mergeConfig,
139
- HtmlPlugin: isRspack ? rspack.HtmlRspackPlugin : HtmlWebpackPlugin
140
- }), isDev() && clickToComponent && (config = await applyClickToComponentConfig({
141
133
  config,
142
134
  unpackConfig
143
- })), config = (({ config, unpackConfig })=>{
144
- if ('split-by-experience' !== unpackConfig.performance.chunkSplit.strategy) return config;
145
- let currentConfig = config.optimization.splitChunks, extraGroups = {};
146
- return extraGroups.react = {
147
- name: 'lib-react',
148
- test: isDevServer() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
149
- priority: 0
150
- }, extraGroups.router = {
151
- name: 'lib-router',
152
- test: /node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
153
- priority: 0
154
- }, config.optimization.splitChunks = {
155
- ...currentConfig,
156
- cacheGroups: {
157
- ...extraGroups,
158
- ...currentConfig.cacheGroups
159
- }
160
- }, config;
161
- })({
135
+ }), isDev() && clickToComponent && (config = await applyClickToComponentConfig({
162
136
  config,
163
137
  unpackConfig
164
- }), reactCompiler && !getUserDepPath(unpackConfig.root, 'react-compiler-runtime') && (logger.error('dependency "react-compiler-runtime" not found, did you install it?'), process.exit(1));
138
+ }));
165
139
  let jsExclude = [
166
140
  /node_modules[\\/](?!\.unpack)/
167
- ], swcLoader = isRspack ? 'builtin:swc-loader' : require.resolve('swc-loader'), getSwcOptions = ({ tsx })=>({
141
+ ], getSwcOptions = ({ tsx })=>({
168
142
  jsc: {
169
143
  parser: {
170
144
  tsx,
@@ -184,7 +158,28 @@ ${renderer}
184
158
  targets: DEFAULT_BROWSERSLIST
185
159
  }
186
160
  });
187
- return mergeConfig(config, {
161
+ return mergeConfig(config = (({ config, unpackConfig })=>{
162
+ if ('split-by-experience' !== unpackConfig.performance.chunkSplit.strategy) return config;
163
+ let currentConfig = config.optimization.splitChunks, extraGroups = {};
164
+ return extraGroups.react = {
165
+ name: 'lib-react',
166
+ test: isDevServer() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
167
+ priority: 0
168
+ }, extraGroups.router = {
169
+ name: 'lib-router',
170
+ test: /node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
171
+ priority: 0
172
+ }, config.optimization.splitChunks = {
173
+ ...currentConfig,
174
+ cacheGroups: {
175
+ ...extraGroups,
176
+ ...currentConfig.cacheGroups
177
+ }
178
+ }, config;
179
+ })({
180
+ config,
181
+ unpackConfig
182
+ }), {
188
183
  module: {
189
184
  rules: [
190
185
  {
@@ -192,7 +187,7 @@ ${renderer}
192
187
  exclude: jsExclude,
193
188
  use: [
194
189
  {
195
- loader: swcLoader,
190
+ loader: 'builtin:swc-loader',
196
191
  options: getSwcOptions({
197
192
  tsx: !1
198
193
  })
@@ -204,18 +199,12 @@ ${renderer}
204
199
  exclude: jsExclude,
205
200
  use: [
206
201
  {
207
- loader: swcLoader,
202
+ loader: 'builtin:swc-loader',
208
203
  options: getSwcOptions({
209
204
  tsx: !0
210
205
  })
211
- },
212
- reactCompiler && {
213
- loader: node_path.resolve(src_dirname, './reactCompilerLoader.mjs'),
214
- options: {
215
- target: getUserDepVersion(unpackConfig.root, 'react').split('.')[0]
216
- }
217
206
  }
218
- ].filter(Boolean)
207
+ ]
219
208
  },
220
209
  {
221
210
  test: /\.svg$/i,
@@ -237,7 +226,7 @@ ${renderer}
237
226
  ]
238
227
  },
239
228
  plugins: [
240
- isDevServer() && new (isRspack ? plugin_react_refresh : react_refresh_webpack_plugin)({
229
+ isDevServer() && new plugin_react_refresh({
241
230
  overlay: !1
242
231
  })
243
232
  ].filter(Boolean),
@@ -53,16 +53,7 @@ function getClosestNodeFromFiber(fiber) {
53
53
  }
54
54
  function openEditor() {
55
55
  if (!currentDebugSource) return;
56
- let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = [
57
- 'http://localhost:',
58
- port,
59
- '/?file=',
60
- fileName,
61
- '&line=',
62
- lineNumber,
63
- '&column=',
64
- columnNumber
65
- ].join(''), xhr = new XMLHttpRequest();
56
+ let port = window.CLICK_TO_COMPONENT.port, { fileName, lineNumber, columnNumber } = currentDebugSource, url = "http://localhost:" + port + "/?file=" + fileName + "&line=" + lineNumber + "&column=" + columnNumber, xhr = new XMLHttpRequest();
66
57
  xhr.open('GET', url, !0), xhr.send(), xhr.addEventListener('error', ()=>{
67
58
  document.createElement('img').src = url;
68
59
  });
@@ -2,7 +2,6 @@ import { type UnpackPlugin } from '@unpackjs/core';
2
2
  export declare const PLUGIN_NAME = "unpack:react";
3
3
  export type PluginReactOptions = {
4
4
  clickToComponent?: boolean;
5
- reactCompiler?: boolean;
6
5
  };
7
6
  export declare const pluginReact: (options?: PluginReactOptions) => UnpackPlugin;
8
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
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,YAqG9D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA4C,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK5F,eAAO,MAAM,WAAW,iBAAiB,CAAA;AAEzC,MAAM,MAAM,kBAAkB,GAAG;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AACD,eAAO,MAAM,WAAW,GAAI,UAAS,kBAAuB,KAAG,YAsF9D,CAAA"}
@@ -1,8 +1,6 @@
1
1
  import { type BundlerConfiguration, type UnpackConfig } from '@unpackjs/core';
2
- export declare const applyMpaConfig: ({ config, unpackConfig, mergeConfig, HtmlPlugin, }: {
2
+ export declare const applyMpaConfig: ({ config, unpackConfig, }: {
3
3
  config: BundlerConfiguration;
4
4
  unpackConfig: UnpackConfig;
5
- mergeConfig: (...configs: BundlerConfiguration[]) => BundlerConfiguration;
6
- HtmlPlugin: any;
7
5
  }) => BundlerConfiguration;
8
6
  //# sourceMappingURL=mpa.d.ts.map
@@ -1 +1 @@
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,oBA8GH,CAAA"}
1
+ {"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAYzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAYvB,eAAO,MAAM,cAAc,GAAI,2BAG5B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBA6GH,CAAA"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unpackjs/plugin-react",
3
- "version": "2.1.1",
4
- "description": "",
3
+ "version": "3.0.0",
4
+ "description": "React plugin for Unpack",
5
5
  "type": "module",
6
6
  "exports": {
7
7
  ".": {
@@ -24,24 +24,17 @@
24
24
  "access": "public"
25
25
  },
26
26
  "dependencies": {
27
- "@babel/core": "7.28.0",
28
- "@babel/plugin-proposal-decorators": "7.28.0",
29
- "@babel/plugin-transform-class-properties": "7.27.1",
30
- "@pmmmwh/react-refresh-webpack-plugin": "0.6.1",
31
27
  "@rspack/plugin-react-refresh": "1.4.3",
32
28
  "@svgr/webpack": "8.1.0",
33
- "@swc/core": "1.12.9",
34
29
  "@swc/helpers": "0.5.17",
35
- "babel-plugin-react-compiler": "latest",
36
30
  "launch-editor": "2.10.0",
37
- "react-refresh": "0.17.0",
38
- "swc-loader": "0.2.6"
31
+ "react-refresh": "0.17.0"
39
32
  },
40
33
  "devDependencies": {
41
- "@unpackjs/core": "2.4.2"
34
+ "@unpackjs/core": "3.0.0"
42
35
  },
43
36
  "peerDependencies": {
44
- "@unpackjs/core": "2.x"
37
+ "@unpackjs/core": "3.x"
45
38
  },
46
39
  "scripts": {
47
40
  "dev": "rslib build --watch",
@@ -1,48 +0,0 @@
1
- import { transformAsync } from "@babel/core";
2
- import plugin_proposal_decorators from "@babel/plugin-proposal-decorators";
3
- import plugin_transform_class_properties from "@babel/plugin-transform-class-properties";
4
- import babel_plugin_react_compiler from "babel-plugin-react-compiler";
5
- let defaultBabelParsePlugins = [
6
- 'jsx',
7
- "typescript"
8
- ];
9
- async function reactCompilerLoader(input, _inputSourceMap) {
10
- let callback = this.async();
11
- try {
12
- let options = this.getOptions(), result = await transformAsync(input, {
13
- sourceFileName: this.resourcePath,
14
- filename: this.resourcePath,
15
- cloneInputAst: !1,
16
- plugins: [
17
- [
18
- babel_plugin_react_compiler,
19
- options
20
- ],
21
- [
22
- plugin_proposal_decorators,
23
- {
24
- legacy: !0
25
- }
26
- ],
27
- [
28
- plugin_transform_class_properties
29
- ]
30
- ],
31
- parserOpts: {
32
- plugins: [
33
- ...defaultBabelParsePlugins
34
- ]
35
- },
36
- ast: !1,
37
- sourceMaps: !0,
38
- configFile: !1,
39
- babelrc: !1
40
- });
41
- if (!result) throw TypeError('babel.transformAsync with react compiler plugin returns null');
42
- let { code, map } = result;
43
- callback(null, code ?? void 0, map ?? void 0);
44
- } catch (e) {
45
- callback(e);
46
- }
47
- }
48
- export { reactCompilerLoader as default };
@@ -1,5 +0,0 @@
1
- export type ReactCompilerLoaderOption = {
2
- target: '17' | '18' | '19';
3
- };
4
- export default function reactCompilerLoader(this: any, input: string, _inputSourceMap: any): Promise<void>;
5
- //# sourceMappingURL=reactCompilerLoader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reactCompilerLoader.d.ts","sourceRoot":"","sources":["../src/reactCompilerLoader.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,yBAAyB,GAAG;IACtC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAAA;CAC3B,CAAA;AAMD,wBAA8B,mBAAmB,CAAC,IAAI,KAAA,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe,EAAE,GAAG,iBAiC1F"}