@unpackjs/plugin-react 3.0.0 → 3.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.
- package/dist/index.cjs +8 -10
- package/dist/index.js +25 -27
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/mpa.d.ts.map +1 -1
- package/dist-types/splitChunks.d.ts +2 -3
- package/dist-types/splitChunks.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -76,7 +76,6 @@ import '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().res
|
|
|
76
76
|
}
|
|
77
77
|
return config;
|
|
78
78
|
}, applyMpaConfig = ({ config, unpackConfig })=>{
|
|
79
|
-
if (!unpackConfig.mpa) return config;
|
|
80
79
|
let tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa'), userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
81
80
|
let start = performance.now(), entry = {}, html = [], pagesRoot = external_node_path_default().join(unpackConfig.root, 'src', 'pages');
|
|
82
81
|
return external_node_fs_default().readdirSync(pagesRoot).forEach((filename)=>{
|
|
@@ -147,8 +146,7 @@ ${renderer}
|
|
|
147
146
|
})(entry),
|
|
148
147
|
plugins: html.map((h)=>new core_namespaceObject.rspack.HtmlRspackPlugin(h))
|
|
149
148
|
});
|
|
150
|
-
}, applySplitChunksConfig = ({ config
|
|
151
|
-
if ('split-by-experience' !== unpackConfig.performance.chunkSplit.strategy) return config;
|
|
149
|
+
}, applySplitChunksConfig = ({ config })=>{
|
|
152
150
|
let currentConfig = config.optimization.splitChunks, extraGroups = {};
|
|
153
151
|
return extraGroups.react = {
|
|
154
152
|
name: 'lib-react',
|
|
@@ -170,13 +168,16 @@ ${renderer}
|
|
|
170
168
|
return {
|
|
171
169
|
name: PLUGIN_NAME,
|
|
172
170
|
bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
|
|
171
|
+
var _unpackConfig_performance_chunkSplit, _unpackConfig_performance;
|
|
173
172
|
let config = originalConfig;
|
|
174
|
-
config = applyMpaConfig({
|
|
173
|
+
unpackConfig.mpa && (config = applyMpaConfig({
|
|
175
174
|
config,
|
|
176
175
|
unpackConfig
|
|
177
|
-
}), (0, core_namespaceObject.isDev)() && clickToComponent && (config = await applyClickToComponentConfig({
|
|
176
|
+
})), (0, core_namespaceObject.isDev)() && clickToComponent && (config = await applyClickToComponentConfig({
|
|
178
177
|
config,
|
|
179
178
|
unpackConfig
|
|
179
|
+
})), (null == (_unpackConfig_performance = unpackConfig.performance) || null == (_unpackConfig_performance_chunkSplit = _unpackConfig_performance.chunkSplit) ? void 0 : _unpackConfig_performance_chunkSplit.strategy) === 'split-by-experience' && (config = applySplitChunksConfig({
|
|
180
|
+
config
|
|
180
181
|
}));
|
|
181
182
|
let jsExclude = [
|
|
182
183
|
/node_modules[\\/](?!\.unpack)/
|
|
@@ -197,13 +198,10 @@ ${renderer}
|
|
|
197
198
|
}
|
|
198
199
|
},
|
|
199
200
|
env: {
|
|
200
|
-
targets: core_namespaceObject.
|
|
201
|
+
targets: (0, core_namespaceObject.esVersionToBrowserslist)(unpackConfig.build.target)
|
|
201
202
|
}
|
|
202
203
|
});
|
|
203
|
-
return mergeConfig(config
|
|
204
|
-
config,
|
|
205
|
-
unpackConfig
|
|
206
|
-
}), {
|
|
204
|
+
return mergeConfig(config, {
|
|
207
205
|
module: {
|
|
208
206
|
rules: [
|
|
209
207
|
{
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ 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
6
|
import plugin_react_refresh from "@rspack/plugin-react-refresh";
|
|
7
|
-
import {
|
|
7
|
+
import { TEMPLATE_CONTENT, TEMP_DIR, colors, esVersionToBrowserslist, getPathInJs, getPort, isDev, isDevServer, isFunction, isPlainObject, logger, mergeConfig as core_mergeConfig, removeDir, restartCleaners, rspack } from "@unpackjs/core";
|
|
8
8
|
import node_fs from "node:fs";
|
|
9
9
|
import node_http from "node:http";
|
|
10
10
|
import launch_editor from "launch-editor";
|
|
@@ -56,9 +56,9 @@ import '${getPathInJs(node_path.resolve(Object.values(config.entry)[0]))}'
|
|
|
56
56
|
return {
|
|
57
57
|
name: PLUGIN_NAME,
|
|
58
58
|
bundlerConfig: async (originalConfig, { unpackConfig, mergeConfig })=>{
|
|
59
|
+
var _unpackConfig_performance_chunkSplit, _unpackConfig_performance;
|
|
59
60
|
let config = originalConfig;
|
|
60
|
-
config = (({ config, unpackConfig })=>{
|
|
61
|
-
if (!unpackConfig.mpa) return config;
|
|
61
|
+
unpackConfig.mpa && (config = (({ config, unpackConfig })=>{
|
|
62
62
|
let tempDirectory = node_path.join(TEMP_DIR, 'mpa'), userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {}, { entry, html } = (()=>{
|
|
63
63
|
let start = performance.now(), entry = {}, html = [], pagesRoot = node_path.join(unpackConfig.root, 'src', 'pages');
|
|
64
64
|
return node_fs.readdirSync(pagesRoot).forEach((filename)=>{
|
|
@@ -132,9 +132,28 @@ ${renderer}
|
|
|
132
132
|
})({
|
|
133
133
|
config,
|
|
134
134
|
unpackConfig
|
|
135
|
-
}), isDev() && clickToComponent && (config = await applyClickToComponentConfig({
|
|
135
|
+
})), isDev() && clickToComponent && (config = await applyClickToComponentConfig({
|
|
136
136
|
config,
|
|
137
137
|
unpackConfig
|
|
138
|
+
})), (null == (_unpackConfig_performance = unpackConfig.performance) || null == (_unpackConfig_performance_chunkSplit = _unpackConfig_performance.chunkSplit) ? void 0 : _unpackConfig_performance_chunkSplit.strategy) === 'split-by-experience' && (config = (({ config })=>{
|
|
139
|
+
let currentConfig = config.optimization.splitChunks, extraGroups = {};
|
|
140
|
+
return extraGroups.react = {
|
|
141
|
+
name: 'lib-react',
|
|
142
|
+
test: isDevServer() ? /node_modules[\\/](?:react|react-dom|scheduler|react-refresh|@rspack[\\/]plugin-react-refresh)[\\/]/ : /node_modules[\\/](?:react|react-dom|scheduler)[\\/]/,
|
|
143
|
+
priority: 0
|
|
144
|
+
}, extraGroups.router = {
|
|
145
|
+
name: 'lib-router',
|
|
146
|
+
test: /node_modules[\\/](?:react-router|react-router-dom|history|@remix-run[\\/]router)[\\/]/,
|
|
147
|
+
priority: 0
|
|
148
|
+
}, config.optimization.splitChunks = {
|
|
149
|
+
...currentConfig,
|
|
150
|
+
cacheGroups: {
|
|
151
|
+
...extraGroups,
|
|
152
|
+
...currentConfig.cacheGroups
|
|
153
|
+
}
|
|
154
|
+
}, config;
|
|
155
|
+
})({
|
|
156
|
+
config
|
|
138
157
|
}));
|
|
139
158
|
let jsExclude = [
|
|
140
159
|
/node_modules[\\/](?!\.unpack)/
|
|
@@ -155,31 +174,10 @@ ${renderer}
|
|
|
155
174
|
}
|
|
156
175
|
},
|
|
157
176
|
env: {
|
|
158
|
-
targets:
|
|
177
|
+
targets: esVersionToBrowserslist(unpackConfig.build.target)
|
|
159
178
|
}
|
|
160
179
|
});
|
|
161
|
-
return mergeConfig(config
|
|
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
|
-
}), {
|
|
180
|
+
return mergeConfig(config, {
|
|
183
181
|
module: {
|
|
184
182
|
rules: [
|
|
185
183
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
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"}
|
package/dist-types/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,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,
|
|
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,oBA4GH,CAAA"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { type BundlerConfiguration
|
|
2
|
-
export declare const applySplitChunksConfig: ({ config
|
|
1
|
+
import { type BundlerConfiguration } from '@unpackjs/core';
|
|
2
|
+
export declare const applySplitChunksConfig: ({ config }: {
|
|
3
3
|
config: BundlerConfiguration;
|
|
4
|
-
unpackConfig: UnpackConfig;
|
|
5
4
|
}) => import("@rspack/core").RspackOptions;
|
|
6
5
|
//# sourceMappingURL=splitChunks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"splitChunks.d.ts","sourceRoot":"","sources":["../src/splitChunks.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,yCAwBlF,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/plugin-react",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.1.0",
|
|
4
4
|
"description": "React plugin for Unpack",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"react-refresh": "0.17.0"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@unpackjs/core": "3.
|
|
34
|
+
"@unpackjs/core": "3.2.0"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@unpackjs/core": "3.x"
|