@unpackjs/plugin-react 3.3.1 → 3.3.3

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
@@ -6,7 +6,7 @@ import { TEMPLATE_CONTENT, addRestartCleaner, colors, esVersionToBrowserslist, g
6
6
  import node_fs from "node:fs";
7
7
  import node_http from "node:http";
8
8
  var click_to_component_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
9
- let applyClickToComponentConfig = async ({ config, unpackConfig })=>{
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)/
@@ -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.1",
3
+ "version": "3.3.3",
4
4
  "description": "React plugin for Unpack",
5
5
  "type": "module",
6
6
  "exports": {
@@ -10,7 +10,6 @@
10
10
  },
11
11
  "./package.json": "./package.json"
12
12
  },
13
- "main": "./dist/index.js",
14
13
  "types": "./dist-types/index.d.ts",
15
14
  "keywords": [],
16
15
  "authors": [],
@@ -29,7 +28,7 @@
29
28
  "react-refresh": "0.18.0"
30
29
  },
31
30
  "devDependencies": {
32
- "@unpackjs/core": "3.7.0"
31
+ "@unpackjs/core": "3.7.4"
33
32
  },
34
33
  "peerDependencies": {
35
34
  "@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"}