@unpackjs/plugin-react 3.3.0 → 3.3.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/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  import __rslib_shim_module__ from 'module';
2
2
  let require = __rslib_shim_module__.createRequire(import.meta.url);
3
- import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
3
+ import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
4
4
  import plugin_react_refresh from "@rspack/plugin-react-refresh";
5
5
  import { TEMPLATE_CONTENT, addRestartCleaner, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, launchEditor, logger, mergeConfig as core_mergeConfig, removeDir, rspack } from "@unpackjs/core";
6
6
  import node_fs from "node:fs";
7
7
  import node_http from "node:http";
8
- var click_to_component_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
9
- let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
8
+ var click_to_component_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
9
+ let applyClickToComponentConfig = async ({ config, unpackConfig, cachePath })=>{
10
10
  let { port } = await new Promise((resolve)=>{
11
11
  let server = node_http.createServer((req, res)=>{
12
12
  let params = new URLSearchParams(req.url.slice(1)), file = decodeURIComponent(params.get('file')), line = Number(params.get('line')), column = Number(params.get('column'));
@@ -37,7 +37,7 @@ if (!document.querySelector('#__click-to-component__')) {
37
37
  node_fs.writeFileSync(filePath, `${scriptTpl}\n${content}`, 'utf-8');
38
38
  });
39
39
  else {
40
- let realEntryPath = node_path.resolve(config.context, unpackConfig._context.cachePath, 'entries', `index.${port}.jsx`), tpl = `
40
+ let realEntryPath = node_path.resolve(config.context, cachePath, 'entries', `index.${port}.jsx`), tpl = `
41
41
  ${scriptTpl}
42
42
  import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
43
43
  `, dir = node_path.dirname(realEntryPath);
@@ -52,10 +52,10 @@ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
52
52
  let { clickToComponent } = options;
53
53
  return {
54
54
  name: PLUGIN_NAME,
55
- bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
55
+ bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig, cachePath })=>{
56
56
  let config = originalConfig;
57
- unpackConfig.mpa && (config = (({ config, unpackConfig })=>{
58
- let start, entry, html, pagesRoot, tempDirectory = node_path.join(unpackConfig._context.cachePath, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages'), node_fs.readdirSync(pagesRoot).forEach((filename)=>{
57
+ unpackConfig.mpa && (config = (({ config, unpackConfig, cachePath })=>{
58
+ let start, entry, html, pagesRoot, tempDirectory = node_path.join(cachePath, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry: entry1, html: html1 } = (start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages'), node_fs.readdirSync(pagesRoot).forEach((filename)=>{
59
59
  if (filename.startsWith('.')) return;
60
60
  let indexFilePath = ((dir)=>{
61
61
  for (let extension of [
@@ -119,31 +119,12 @@ ${renderer}
119
119
  });
120
120
  })({
121
121
  config,
122
- unpackConfig
122
+ unpackConfig,
123
+ cachePath
123
124
  })), isDev() && clickToComponent && (config = await applyClickToComponentConfig({
124
125
  config,
125
- unpackConfig
126
- })), unpackConfig.performance?.chunkSplit?.strategy === 'split-by-experience' && (config = (({ config })=>{
127
- let currentSplitChunks = config.optimization?.splitChunks;
128
- if (!currentSplitChunks) return config;
129
- let extraGroups = {};
130
- return extraGroups.react = {
131
- name: 'lib-react',
132
- test: isDevServer() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
133
- priority: 0
134
- }, extraGroups.router = {
135
- name: 'lib-router',
136
- test: /node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
137
- priority: 0
138
- }, config.optimization.splitChunks = {
139
- ...currentSplitChunks,
140
- cacheGroups: {
141
- ...extraGroups,
142
- ...currentSplitChunks.cacheGroups ?? {}
143
- }
144
- }, config;
145
- })({
146
- config
126
+ unpackConfig,
127
+ cachePath
147
128
  }));
148
129
  let jsExclude = [
149
130
  /node_modules[\\/](?!\.unpack)/
@@ -227,5 +208,5 @@ ${renderer}
227
208
  }
228
209
  };
229
210
  };
230
- import node_path, { dirname as __webpack_dirname__ } from "node:path";
211
+ import node_path, { dirname as __rspack_dirname } from "node:path";
231
212
  export { PLUGIN_NAME, pluginReact };
@@ -60,12 +60,10 @@
60
60
  let el = (cover || ((cover = document.createElement('div')).id = '__click-to-component-cover__', applyStyles(cover, {
61
61
  position: 'fixed',
62
62
  zIndex: 2147483647,
63
- background: 'rgba(111, 168, 220, 0.3)',
63
+ background: 'rgba(111, 168, 220, 0.5)',
64
64
  boxSizing: 'border-box',
65
65
  display: 'none',
66
- pointerEvents: 'none',
67
- transition: 'all 0.2s cubic-bezier(0.25, 1, 0.5, 1)',
68
- boxShadow: 'inset 0 0 0 1px #4a90e2, 0 0 4px rgba(74, 144, 226, 0.5)'
66
+ pointerEvents: 'none'
69
67
  }), (nameTag = document.createElement('span')).id = '__click-to-component-name__', applyStyles(nameTag, {
70
68
  position: 'absolute',
71
69
  bottom: '0',
@@ -78,8 +76,7 @@
78
76
  padding: '4px 8px',
79
77
  pointerEvents: 'none',
80
78
  whiteSpace: 'nowrap',
81
- zIndex: 2147483648,
82
- boxShadow: '0 4px 6px rgba(0, 0, 0, 0.3)'
79
+ zIndex: 2147483648
83
80
  }), cover.appendChild(nameTag), document.documentElement.appendChild(cover)), cover);
84
81
  applyStyles(el, {
85
82
  top: rect.top + 'px',
@@ -1,6 +1,7 @@
1
1
  import { type BundlerConfiguration, type UnpackConfig } from '@unpackjs/core';
2
- export declare const applyClickToComponentConfig: ({ config, unpackConfig, }: {
2
+ export declare const applyClickToComponentConfig: ({ config, unpackConfig, cachePath, }: {
3
3
  config: BundlerConfiguration;
4
4
  unpackConfig: UnpackConfig;
5
+ cachePath: string;
5
6
  }) => Promise<BundlerConfiguration>;
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AA4BvB,eAAO,MAAM,2BAA2B,GAAU,2BAG/C;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,OAAO,CAAC,oBAAoB,CAoC/B,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/click-to-component/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,KAAK,oBAAoB,EAIzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AA4BvB,eAAO,MAAM,2BAA2B,GAAU,sCAI/C;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,OAAO,CAAC,oBAAoB,CA+B/B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+C,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAK/F,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,YA0F9D,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAA+C,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAI/F,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,YAuF9D,CAAA"}
@@ -1,6 +1,7 @@
1
1
  import { type BundlerConfiguration, type UnpackConfig } from '@unpackjs/core';
2
- export declare const applyMpaConfig: ({ config, unpackConfig, }: {
2
+ export declare const applyMpaConfig: ({ config, unpackConfig, cachePath, }: {
3
3
  config: BundlerConfiguration;
4
4
  unpackConfig: UnpackConfig;
5
+ cachePath: string;
5
6
  }) => BundlerConfiguration;
6
7
  //# 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,EAWzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAYvB,eAAO,MAAM,cAAc,GAAI,2BAG5B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;CAC3B,KAAG,oBA2GH,CAAA"}
1
+ {"version":3,"file":"mpa.d.ts","sourceRoot":"","sources":["../src/mpa.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,oBAAoB,EAWzB,KAAK,YAAY,EAClB,MAAM,gBAAgB,CAAA;AAYvB,eAAO,MAAM,cAAc,GAAI,sCAI5B;IACD,MAAM,EAAE,oBAAoB,CAAA;IAC5B,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;CAClB,KAAG,oBA2GH,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unpackjs/plugin-react",
3
- "version": "3.3.0",
3
+ "version": "3.3.2",
4
4
  "description": "React plugin for Unpack",
5
5
  "type": "module",
6
6
  "exports": {
@@ -29,7 +29,7 @@
29
29
  "react-refresh": "0.18.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@unpackjs/core": "3.6.0"
32
+ "@unpackjs/core": "3.7.3"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "@unpackjs/core": "3.x"
@@ -1,5 +0,0 @@
1
- import { type BundlerConfiguration } from '@unpackjs/core';
2
- export declare const applySplitChunksConfig: ({ config }: {
3
- config: BundlerConfiguration;
4
- }) => import("@rspack/core").RspackOptions;
5
- //# sourceMappingURL=splitChunks.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"splitChunks.d.ts","sourceRoot":"","sources":["../src/splitChunks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAiC,MAAM,gBAAgB,CAAA;AAEzF,eAAO,MAAM,sBAAsB,GAAI,YAAY;IAAE,MAAM,EAAE,oBAAoB,CAAA;CAAE,yCA4BlF,CAAA"}