@unpackjs/plugin-react 3.0.0 → 3.0.1
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
|
@@ -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)/
|
|
@@ -200,10 +201,7 @@ ${renderer}
|
|
|
200
201
|
targets: core_namespaceObject.DEFAULT_BROWSERSLIST
|
|
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
|
@@ -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)/
|
|
@@ -158,28 +177,7 @@ ${renderer}
|
|
|
158
177
|
targets: DEFAULT_BROWSERSLIST
|
|
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,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,
|
|
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,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.0.
|
|
3
|
+
"version": "3.0.1",
|
|
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.1.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@unpackjs/core": "3.x"
|