@unpackjs/core 3.3.4 → 3.3.6
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/compiled/css-loader/index.js +339 -217
- package/compiled/launch-editor/index.js +21 -20
- package/compiled/launch-editor/package.json +1 -1
- package/compiled/less-loader/index.js +8 -8
- package/compiled/postcss-loader/index.js +194 -192
- package/compiled/sass-loader/index.js +142 -156
- package/compiled/sass-loader/package.json +1 -1
- package/compiled/semver/index.js +164 -164
- package/compiled/style-loader/index.js +10 -10
- package/compiled/webpack-bundle-analyzer/index.js +2 -2
- package/compiled/webpack-merge/index.js +29 -29
- package/dist/index.cjs +190 -249
- package/dist/index.js +135 -160
- package/dist-types/bundler-config/detectCircular.d.ts +6 -0
- package/dist-types/bundler-config/detectCircular.d.ts.map +1 -0
- package/dist-types/bundler-config/index.d.ts.map +1 -1
- package/dist-types/bundler-config/typeCheck.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
let lastTrackTime, lastFileInfo, logger;
|
|
2
2
|
import __rslib_shim_module__ from 'module';
|
|
3
3
|
let require = __rslib_shim_module__.createRequire(import.meta.url);
|
|
4
|
-
import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
|
|
5
|
-
import { dirname as __webpack_dirname__ } from "node:path";
|
|
6
4
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_launch_editor_index_js_29002383__ from "../compiled/launch-editor/index.js";
|
|
7
5
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
|
|
8
6
|
import { experiments, rspack } from "@rspack/core";
|
|
@@ -11,9 +9,7 @@ import node_readline from "node:readline";
|
|
|
11
9
|
import node_fs from "node:fs";
|
|
12
10
|
import node_net from "node:net";
|
|
13
11
|
import node_os, { platform } from "node:os";
|
|
14
|
-
import node_path, { join, sep } from "node:path";
|
|
15
12
|
import portfinder from "portfinder";
|
|
16
|
-
import { pathToFileURL } from "node:url";
|
|
17
13
|
import { expand } from "dotenv-expand";
|
|
18
14
|
import node_assert from "node:assert";
|
|
19
15
|
import { glob, globSync } from "tinyglobby";
|
|
@@ -66,7 +62,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
|
|
|
66
62
|
jsAsync: 'js/async/[name].[contenthash:8].js',
|
|
67
63
|
css: 'css/[name].[contenthash:8].css',
|
|
68
64
|
cssAsync: 'css/async/[name].[contenthash:8].css'
|
|
69
|
-
}, EXPORT_LOCALS_CONVENTION = 'camel-case-only', TEMP_DIR = 'node_modules/.unpack', NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/,
|
|
65
|
+
}, EXPORT_LOCALS_CONVENTION = 'camel-case-only', TEMP_DIR = 'node_modules/.unpack', NODE_MODULES_REGEX = /[\\/]node_modules[\\/]/, THREAD_OPTIONS = {
|
|
70
66
|
workers: 2
|
|
71
67
|
}, DEFAULT_DEV_HOST = '0.0.0.0', TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
|
|
72
68
|
<html lang="en">
|
|
@@ -319,8 +315,8 @@ async function setupCliShortcuts({ help = !0, openPage, closeServer, printUrls,
|
|
|
319
315
|
}
|
|
320
316
|
var config_filename = __webpack_fileURLToPath__(import.meta.url);
|
|
321
317
|
async function loadConfig({ cliOptions, command }) {
|
|
322
|
-
'build' === command ? setNodeEnv(
|
|
323
|
-
let root =
|
|
318
|
+
'build' === command ? setNodeEnv(cliOptions?.watch ? 'development' : 'production') : (setNodeEnv('development'), setDevServer(!0));
|
|
319
|
+
let root = cliOptions?.root ? node_path.resolve(cliOptions.root) : process.cwd(), configFilePath = resolveConfigPath(root, cliOptions?.config), configExport = {};
|
|
324
320
|
if (configFilePath) {
|
|
325
321
|
if (isNodeVersionAtLeast(22, 18) || /\.(?:js|mjs|cjs)$/.test(configFilePath)) {
|
|
326
322
|
logger_logger.debug('loading config file with native loader:', colors.dim(configFilePath));
|
|
@@ -356,18 +352,18 @@ async function loadConfig({ cliOptions, command }) {
|
|
|
356
352
|
if (void 0 === (configExport = await configExport(params))) throw Error('unpack config function must return a config object.');
|
|
357
353
|
}
|
|
358
354
|
}
|
|
359
|
-
return
|
|
355
|
+
return cliOptions?.port && setValueByPath(configExport, [
|
|
360
356
|
'server',
|
|
361
357
|
'port'
|
|
362
|
-
], cliOptions.port),
|
|
358
|
+
], cliOptions.port), cliOptions?.open && setValueByPath(configExport, [
|
|
363
359
|
'server',
|
|
364
360
|
'open'
|
|
365
|
-
], cliOptions.open),
|
|
361
|
+
], cliOptions.open), cliOptions?.analyze && setValueByPath(configExport, [
|
|
366
362
|
'performance',
|
|
367
363
|
'bundleAnalyze'
|
|
368
|
-
], cliOptions.analyze),
|
|
364
|
+
], cliOptions.analyze), cliOptions?.root && setValueByPath(configExport, [
|
|
369
365
|
'root'
|
|
370
|
-
], root),
|
|
366
|
+
], root), cliOptions?.host && setValueByPath(configExport, [
|
|
371
367
|
'server',
|
|
372
368
|
'host'
|
|
373
369
|
], cliOptions.host), configExport;
|
|
@@ -396,10 +392,9 @@ function resolveConfigPath(root, customConfig) {
|
|
|
396
392
|
}
|
|
397
393
|
let isFileSync = (filePath)=>{
|
|
398
394
|
try {
|
|
399
|
-
|
|
400
|
-
return null == (_fs_statSync = node_fs.statSync(filePath, {
|
|
395
|
+
return node_fs.statSync(filePath, {
|
|
401
396
|
throwIfNoEntry: !1
|
|
402
|
-
})
|
|
397
|
+
})?.isFile();
|
|
403
398
|
} catch {
|
|
404
399
|
return !1;
|
|
405
400
|
}
|
|
@@ -426,14 +421,13 @@ let removeDir = (dir)=>{
|
|
|
426
421
|
}, DOTENV_LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;
|
|
427
422
|
function getNormalizedPluginsByHook(hook, plugins) {
|
|
428
423
|
let pluginMap = new Map();
|
|
429
|
-
return
|
|
424
|
+
return plugins?.forEach((plugin)=>{
|
|
430
425
|
plugin[hook] && pluginMap.set(plugin.name, plugin);
|
|
431
426
|
}), Array.from(pluginMap.values());
|
|
432
427
|
}
|
|
433
428
|
async function applyBundleAnalyzeConfig({ config }) {
|
|
434
|
-
var _config_plugins;
|
|
435
429
|
let { default: { BundleAnalyzerPlugin } } = await import("../compiled/webpack-bundle-analyzer/index.js");
|
|
436
|
-
return
|
|
430
|
+
return config.plugins?.push(new BundleAnalyzerPlugin({
|
|
437
431
|
analyzerPort: 'auto'
|
|
438
432
|
})), config;
|
|
439
433
|
}
|
|
@@ -513,7 +507,7 @@ let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\
|
|
|
513
507
|
priority: -9,
|
|
514
508
|
test: NODE_MODULES_REGEX,
|
|
515
509
|
name: (module)=>module ? function(modulePath) {
|
|
516
|
-
let handleModuleContext =
|
|
510
|
+
let handleModuleContext = modulePath?.match(MODULE_PATH_REGEX);
|
|
517
511
|
if (!handleModuleContext) return;
|
|
518
512
|
let [, scope, name] = handleModuleContext;
|
|
519
513
|
return [
|
|
@@ -619,19 +613,16 @@ class TypedCssModulesPlugin {
|
|
|
619
613
|
});
|
|
620
614
|
}
|
|
621
615
|
async generateCssTypings(incremental) {
|
|
622
|
-
let cssModulesFiles = (await glob(this.globPattern)).filter((file)=>{
|
|
623
|
-
var _this_userOptions;
|
|
624
|
-
return isCSSModules({
|
|
616
|
+
let cssModulesFiles = (await glob(this.globPattern)).filter((file)=>isCSSModules({
|
|
625
617
|
resourcePath: file,
|
|
626
|
-
modules:
|
|
627
|
-
});
|
|
628
|
-
}), doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
618
|
+
modules: this.userOptions?.modules
|
|
619
|
+
})), doTask = incremental ? generateTypingIfNecessary : writeFile;
|
|
629
620
|
return Promise.all(cssModulesFiles.map((file)=>doTask(this.dtsCreator, file)));
|
|
630
621
|
}
|
|
631
622
|
constructor(options){
|
|
632
623
|
_define_property(this, "dtsCreator", void 0), _define_property(this, "useIncremental", !1), _define_property(this, "globPattern", 'src/**/*.{css,less,scss}'), _define_property(this, "userOptions", void 0), this.userOptions = options, this.dtsCreator = new DtsCreator({
|
|
633
624
|
camelCase: !0,
|
|
634
|
-
namedExports:
|
|
625
|
+
namedExports: !1
|
|
635
626
|
});
|
|
636
627
|
}
|
|
637
628
|
}
|
|
@@ -648,7 +639,7 @@ class JsMinifyPlugin {
|
|
|
648
639
|
apply(compiler) {
|
|
649
640
|
let meta = JSON.stringify({
|
|
650
641
|
name: jsMinify_PLUGIN_NAME,
|
|
651
|
-
version: "3.3.
|
|
642
|
+
version: "3.3.6",
|
|
652
643
|
options: this.minifyOptions
|
|
653
644
|
});
|
|
654
645
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
@@ -680,13 +671,12 @@ class JsMinifyPlugin {
|
|
|
680
671
|
constructor(options = {}){
|
|
681
672
|
jsMinify_define_property(this, "minifyOptions", void 0), jsMinify_define_property(this, "customMinify", void 0);
|
|
682
673
|
let { implementation, ...minifyOptions } = options;
|
|
683
|
-
this.customMinify =
|
|
674
|
+
this.customMinify = implementation?.minify, this.minifyOptions = minifyOptions;
|
|
684
675
|
}
|
|
685
676
|
}
|
|
686
677
|
var oxlint_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
687
678
|
class OxlintPlugin {
|
|
688
679
|
runOxlint(args) {
|
|
689
|
-
var _child_stdout, _child_stderr;
|
|
690
680
|
let child = spawn('npx', [
|
|
691
681
|
'--yes',
|
|
692
682
|
...args
|
|
@@ -699,12 +689,12 @@ class OxlintPlugin {
|
|
|
699
689
|
FORCE_COLOR: '1'
|
|
700
690
|
}
|
|
701
691
|
}), output = '';
|
|
702
|
-
|
|
692
|
+
child.stdout?.on('data', (data)=>{
|
|
703
693
|
output += data.toString();
|
|
704
694
|
}), child.on('exit', (code)=>{
|
|
705
695
|
let hasErrors = !output.includes('Found 0 warnings and 0 errors'), hasNoFiles = output.includes('on 0 files');
|
|
706
696
|
(hasErrors || 0 !== code) && !hasNoFiles && process.stdout.write(output);
|
|
707
|
-
}),
|
|
697
|
+
}), child.stderr?.on('data', (data)=>{
|
|
708
698
|
process.stderr.write(data);
|
|
709
699
|
});
|
|
710
700
|
}
|
|
@@ -879,12 +869,12 @@ async function compileDone(compiler, stats) {
|
|
|
879
869
|
}), logger_logger.ready(colors.green(`built in ${prettyTime(compileTime)}`));
|
|
880
870
|
else {
|
|
881
871
|
let fileInfo = function(changedFiles, removedFiles, root) {
|
|
882
|
-
if (!
|
|
883
|
-
if (
|
|
872
|
+
if (!changedFiles?.length && !removedFiles?.length) return null;
|
|
873
|
+
if (changedFiles?.length && removedFiles?.length) {
|
|
884
874
|
let changedInfo = formatFileList(changedFiles, root), removedInfo = formatFileList(removedFiles, root);
|
|
885
875
|
return `${changedInfo}, removed ${removedInfo}`;
|
|
886
876
|
}
|
|
887
|
-
return
|
|
877
|
+
return changedFiles?.length ? formatFileList(changedFiles, root) : removedFiles?.length ? `removed ${formatFileList(removedFiles, root)}` : null;
|
|
888
878
|
}(compiler.modifiedFiles ? Array.from(compiler.modifiedFiles) : null, compiler.removedFiles ? Array.from(compiler.removedFiles) : null, root);
|
|
889
879
|
if (!fileInfo) return;
|
|
890
880
|
if (fileInfo === lastFileInfo ? sameCount++ : (lastFileInfo = fileInfo, sameCount = 1), isDebug()) {
|
|
@@ -892,7 +882,7 @@ async function compileDone(compiler, stats) {
|
|
|
892
882
|
let nodeModulesStats, nodeModulesPath;
|
|
893
883
|
Object.entries((modules = stats.compilation.modules, nodeModulesStats = {}, nodeModulesPath = node_path.resolve(root, 'node_modules'), modules.forEach((module)=>{
|
|
894
884
|
let { resource } = module;
|
|
895
|
-
if (
|
|
885
|
+
if (resource?.includes(nodeModulesPath)) {
|
|
896
886
|
let packageName, pathParts = node_path.relative(nodeModulesPath, resource).split(sep);
|
|
897
887
|
(packageName = '.pnpm' === pathParts[0] && pathParts.length >= 4 ? pathParts[3].startsWith('@') ? `${pathParts[3]}/${pathParts[4]}` : pathParts[3] : pathParts[0].startsWith('@') ? `${pathParts[0]}/${pathParts[1]}` : pathParts[0]) && (nodeModulesStats[packageName] = (nodeModulesStats[packageName] || 0) + 1);
|
|
898
888
|
}
|
|
@@ -935,9 +925,8 @@ class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
|
935
925
|
}
|
|
936
926
|
}
|
|
937
927
|
async function applyTypeCheckConfig({ config, unpackConfig }) {
|
|
938
|
-
var _config_plugins;
|
|
939
928
|
let { TsCheckerRspackPlugin } = await import("ts-checker-rspack-plugin"), tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json');
|
|
940
|
-
return
|
|
929
|
+
return config.plugins?.push(new TsCheckerRspackPlugin({
|
|
941
930
|
typescript: {
|
|
942
931
|
mode: 'readonly',
|
|
943
932
|
memoryLimit: 8192,
|
|
@@ -955,7 +944,8 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
|
|
|
955
944
|
},
|
|
956
945
|
logger: {
|
|
957
946
|
log (message) {
|
|
958
|
-
|
|
947
|
+
let count = +(/(\d+) errors?/.exec(message)?.[1] || 0);
|
|
948
|
+
count > 0 && console.log(`Found ${colors.red(colors.bold(`${count} ${1 === count ? 'error' : 'errors'}`))}`);
|
|
959
949
|
},
|
|
960
950
|
error (message) {
|
|
961
951
|
message.includes('RpcExitError') || message.includes('out of memory') || console.log(message.replace(/ERROR/g, 'Type Error'));
|
|
@@ -964,8 +954,7 @@ async function applyTypeCheckConfig({ config, unpackConfig }) {
|
|
|
964
954
|
})), config;
|
|
965
955
|
}
|
|
966
956
|
async function getBundlerConfig(originalUnpackConfig) {
|
|
967
|
-
|
|
968
|
-
let circularCount, { plugins, bundlerConfig, ...rest } = originalUnpackConfig;
|
|
957
|
+
let { plugins, bundlerConfig, ...rest } = originalUnpackConfig;
|
|
969
958
|
for (let plugin of getNormalizedPluginsByHook('config', plugins))rest = await plugin.config(rest, {
|
|
970
959
|
...originalUnpackConfig._context,
|
|
971
960
|
mergeConfig: mergeConfig
|
|
@@ -974,7 +963,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
974
963
|
...rest,
|
|
975
964
|
plugins,
|
|
976
965
|
bundlerConfig
|
|
977
|
-
}, tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(
|
|
966
|
+
}, tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {}, ProgressPlugin = unpackConfig.build?.progressBar ? ProgressRspackPlugin : ProgressLiteRspackPlugin, { publicVars, filePaths: envFilePaths } = function({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
978
967
|
'PUBLIC_'
|
|
979
968
|
], processEnv = process.env } = {}) {
|
|
980
969
|
if ('local' === mode) throw Error(`${colors.yellow('local')} cannot be used as a value for env mode, because ${colors.yellow('.env.local')} represents a temporary local file. Please use another value.`);
|
|
@@ -1032,23 +1021,23 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1032
1021
|
path: node_path.resolve(unpackConfig.root, unpackConfig.build.outDir),
|
|
1033
1022
|
filename: getOutputFilename({
|
|
1034
1023
|
type: 'js',
|
|
1035
|
-
hash:
|
|
1024
|
+
hash: unpackConfig.build?.filenameHash
|
|
1036
1025
|
}),
|
|
1037
1026
|
chunkFilename: getOutputFilename({
|
|
1038
1027
|
type: 'js',
|
|
1039
|
-
hash:
|
|
1028
|
+
hash: unpackConfig.build?.filenameHash,
|
|
1040
1029
|
async: !0
|
|
1041
1030
|
}),
|
|
1042
1031
|
crossOriginLoading: 'anonymous',
|
|
1043
1032
|
pathinfo: !1,
|
|
1044
|
-
publicPath:
|
|
1033
|
+
publicPath: unpackConfig.build?.publicPath,
|
|
1045
1034
|
webassemblyModuleFilename: 'js/async/[hash].module.wasm',
|
|
1046
1035
|
assetModuleFilename: 'assets/[name].[contenthash:8][ext]'
|
|
1047
1036
|
},
|
|
1048
1037
|
infrastructureLogging: {
|
|
1049
1038
|
level: 'error'
|
|
1050
1039
|
},
|
|
1051
|
-
devtool:
|
|
1040
|
+
devtool: unpackConfig.build?.sourceMap,
|
|
1052
1041
|
module: {
|
|
1053
1042
|
rules: [
|
|
1054
1043
|
{
|
|
@@ -1079,73 +1068,37 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1079
1068
|
...unpackConfig.define
|
|
1080
1069
|
}),
|
|
1081
1070
|
!unpackConfig.mpa && new rspack.HtmlRspackPlugin({
|
|
1082
|
-
template:
|
|
1083
|
-
templateContent:
|
|
1071
|
+
template: unpackConfig.html?.template || void 0,
|
|
1072
|
+
templateContent: unpackConfig.html?.templateContent || (unpackConfig.html?.template ? void 0 : TEMPLATE_CONTENT),
|
|
1084
1073
|
templateParameters: {
|
|
1085
1074
|
mountId: unpackConfig.html.mountId,
|
|
1086
|
-
title: isFunction(
|
|
1075
|
+
title: isFunction(unpackConfig.html?.title) ? unpackConfig.html?.title({
|
|
1087
1076
|
entryName: 'index'
|
|
1088
|
-
}) :
|
|
1089
|
-
headTag:
|
|
1090
|
-
...
|
|
1077
|
+
}) : unpackConfig.html?.title || '',
|
|
1078
|
+
headTag: unpackConfig.html?.headTag || '',
|
|
1079
|
+
...unpackConfig.html?.templateParameters
|
|
1091
1080
|
},
|
|
1092
1081
|
minify: !1,
|
|
1093
1082
|
chunks: [
|
|
1094
1083
|
'main'
|
|
1095
1084
|
]
|
|
1096
1085
|
}),
|
|
1097
|
-
|
|
1086
|
+
unpackConfig.performance?.removeMomentLocale && new rspack.IgnorePlugin({
|
|
1098
1087
|
resourceRegExp: /^\.\/locale$/,
|
|
1099
1088
|
contextRegExp: /moment$/
|
|
1100
1089
|
}),
|
|
1101
|
-
|
|
1090
|
+
unpackConfig.build?.copy && new rspack.CopyRspackPlugin({
|
|
1102
1091
|
patterns: unpackConfig.build.copy
|
|
1103
1092
|
}),
|
|
1104
1093
|
new ProgressPlugin(),
|
|
1105
|
-
unpackConfig.lint && new OxlintPlugin()
|
|
1106
|
-
unpackConfig.detectCircular && (circularCount = 0, new rspack.CircularDependencyRspackPlugin({
|
|
1107
|
-
exclude: /node_modules/,
|
|
1108
|
-
onStart () {
|
|
1109
|
-
circularCount = 0;
|
|
1110
|
-
},
|
|
1111
|
-
onDetected (_, modules) {
|
|
1112
|
-
circularCount++, console.log(''), logger_logger.warn('circular dependency detected:');
|
|
1113
|
-
let uniquePaths = modules.map((module)=>{
|
|
1114
|
-
let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
|
|
1115
|
-
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
1116
|
-
}).slice(0, -1);
|
|
1117
|
-
if (2 + uniquePaths.join(' → ').length > (process.stdout.columns || 80)) {
|
|
1118
|
-
let arrow, lastIndex;
|
|
1119
|
-
console.log(''), arrow = '↳ ', lastIndex = uniquePaths.length - 1, uniquePaths.forEach((p, i)=>{
|
|
1120
|
-
switch(i){
|
|
1121
|
-
case 0:
|
|
1122
|
-
console.log(` ${p}`);
|
|
1123
|
-
break;
|
|
1124
|
-
case lastIndex:
|
|
1125
|
-
console.log(` ${arrow}${p} ${colors.dim('(cycle introduced)')}`);
|
|
1126
|
-
break;
|
|
1127
|
-
default:
|
|
1128
|
-
console.log(` ${arrow}${p}`);
|
|
1129
|
-
}
|
|
1130
|
-
}), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
|
|
1131
|
-
} else {
|
|
1132
|
-
let line1, downArrowPos, lineLength;
|
|
1133
|
-
line1 = ' ', downArrowPos = 0, uniquePaths.forEach((p, i)=>{
|
|
1134
|
-
line1 += p, i < uniquePaths.length - 1 ? line1 += ' → ' : downArrowPos = line1.length - 1;
|
|
1135
|
-
}), lineLength = downArrowPos - 2, console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + '↑' + ' '.repeat(downArrowPos - 2 - 1) + '↓'), console.log(' ' + ' '.repeat(0) + '└' + '─'.repeat(lineLength - 1) + '┘'), console.log('');
|
|
1136
|
-
}
|
|
1137
|
-
},
|
|
1138
|
-
onEnd () {
|
|
1139
|
-
circularCount > 0 && console.log(`Found ${circularCount} circular ${1 === circularCount ? 'dependency' : 'dependencies'}.`);
|
|
1140
|
-
}
|
|
1141
|
-
}))
|
|
1094
|
+
unpackConfig.lint && new OxlintPlugin()
|
|
1142
1095
|
].filter(Boolean),
|
|
1143
1096
|
externals: unpackConfig.externals,
|
|
1144
1097
|
resolve: {
|
|
1145
1098
|
tsConfig: isTs ? tsconfigPath : void 0,
|
|
1146
1099
|
alias: {
|
|
1147
1100
|
'@': node_path.resolve(unpackConfig.root, 'src'),
|
|
1148
|
-
...
|
|
1101
|
+
...unpackConfig.resolve?.alias
|
|
1149
1102
|
},
|
|
1150
1103
|
extensionAlias: {
|
|
1151
1104
|
'.js': [
|
|
@@ -1165,21 +1118,20 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1165
1118
|
'.js',
|
|
1166
1119
|
'.wasm',
|
|
1167
1120
|
'.json',
|
|
1168
|
-
...
|
|
1121
|
+
...unpackConfig.resolve?.extensions || []
|
|
1169
1122
|
]
|
|
1170
1123
|
},
|
|
1171
|
-
lazyCompilation:
|
|
1124
|
+
lazyCompilation: unpackConfig.dev?.lazyCompilation && utils_isDevServer() && {
|
|
1172
1125
|
imports: !0,
|
|
1173
1126
|
entries: !!unpackConfig.mpa
|
|
1174
1127
|
},
|
|
1175
1128
|
experiments: {
|
|
1176
1129
|
css: !1,
|
|
1177
|
-
asyncWebAssembly: !0
|
|
1178
|
-
lazyBarrel: !0
|
|
1130
|
+
asyncWebAssembly: !0
|
|
1179
1131
|
},
|
|
1180
1132
|
optimization: {
|
|
1181
1133
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
1182
|
-
minimize: !!
|
|
1134
|
+
minimize: !!unpackConfig.build?.minify,
|
|
1183
1135
|
minimizer: [
|
|
1184
1136
|
new JsMinifyPlugin(mergeConfig({
|
|
1185
1137
|
compress: {
|
|
@@ -1199,9 +1151,9 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1199
1151
|
};
|
|
1200
1152
|
for (let plugin of (config = (({ config, unpackConfig })=>{
|
|
1201
1153
|
let { chunkSplit } = unpackConfig.performance || {};
|
|
1202
|
-
if (
|
|
1154
|
+
if (chunkSplit?.strategy) {
|
|
1203
1155
|
let forceSplittingGroups = {};
|
|
1204
|
-
|
|
1156
|
+
chunkSplit?.forceSplitting && (forceSplittingGroups = function(forceSplitting, strategy) {
|
|
1205
1157
|
let cacheGroups = {};
|
|
1206
1158
|
for (let [key, regexp] of Array.isArray(forceSplitting) ? forceSplitting.map((regexp, index)=>[
|
|
1207
1159
|
`force-split-${index}`,
|
|
@@ -1227,26 +1179,25 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1227
1179
|
}
|
|
1228
1180
|
return config;
|
|
1229
1181
|
})({
|
|
1230
|
-
config: config =
|
|
1231
|
-
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_css, _unpackConfig_css1;
|
|
1182
|
+
config: config = unpackConfig.experiments?.css ? function({ config, unpackConfig }) {
|
|
1232
1183
|
config.output.cssFilename = getOutputFilename({
|
|
1233
1184
|
type: 'css',
|
|
1234
|
-
hash:
|
|
1185
|
+
hash: unpackConfig.build?.filenameHash
|
|
1235
1186
|
}), config.output.cssChunkFilename = getOutputFilename({
|
|
1236
1187
|
type: 'css',
|
|
1237
|
-
hash:
|
|
1188
|
+
hash: unpackConfig.build?.filenameHash,
|
|
1238
1189
|
async: !0
|
|
1239
1190
|
}), setValueByPath(config, [
|
|
1240
1191
|
'experiments',
|
|
1241
1192
|
'css'
|
|
1242
1193
|
], !0);
|
|
1243
|
-
let sourceMap =
|
|
1194
|
+
let sourceMap = unpackConfig.css?.sourceMap, modules = unpackConfig.css?.modules;
|
|
1244
1195
|
isPlainObject(modules) || !1 === modules || (modules = {}), !1 !== modules && !1 !== modules.auto && (setValueByPath(config, [
|
|
1245
1196
|
'module',
|
|
1246
1197
|
'parser',
|
|
1247
1198
|
'css/module'
|
|
1248
1199
|
], {
|
|
1249
|
-
namedExports:
|
|
1200
|
+
namedExports: !1
|
|
1250
1201
|
}), setValueByPath(config, [
|
|
1251
1202
|
'module',
|
|
1252
1203
|
'generator',
|
|
@@ -1263,42 +1214,31 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1263
1214
|
use,
|
|
1264
1215
|
type: 'css/module'
|
|
1265
1216
|
};
|
|
1266
|
-
}, getThreadLoader = ()=>{
|
|
1267
|
-
var _unpackConfig_build;
|
|
1268
|
-
return (null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.parallel) && isProd() && {
|
|
1217
|
+
}, getThreadLoader = ()=>unpackConfig.build?.parallel && isProd() && {
|
|
1269
1218
|
loader: require.resolve('thread-loader'),
|
|
1270
1219
|
options: THREAD_OPTIONS
|
|
1271
|
-
}
|
|
1272
|
-
}, getLessLoader = ()=>{
|
|
1273
|
-
var _unpackConfig_css;
|
|
1274
|
-
return {
|
|
1220
|
+
}, getLessLoader = ()=>({
|
|
1275
1221
|
loader: getCompiledPkgPath('less-loader'),
|
|
1276
1222
|
options: {
|
|
1277
1223
|
lessOptions: mergeConfig({
|
|
1278
1224
|
javascriptEnabled: !0
|
|
1279
|
-
},
|
|
1225
|
+
}, unpackConfig.css?.less || {}),
|
|
1280
1226
|
implementation: getUserDepPath(unpackConfig.root, 'less'),
|
|
1281
1227
|
sourceMap
|
|
1282
1228
|
}
|
|
1283
|
-
}
|
|
1284
|
-
}, getCssLoader = ()=>{
|
|
1285
|
-
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
|
|
1286
|
-
return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
|
|
1229
|
+
}), getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
|
|
1287
1230
|
loader: 'builtin:lightningcss-loader',
|
|
1288
1231
|
options: {
|
|
1289
1232
|
targets: esVersionToBrowserslist(unpackConfig.build.target),
|
|
1290
|
-
...
|
|
1233
|
+
...unpackConfig.css?.lightningcss
|
|
1291
1234
|
}
|
|
1292
1235
|
} : {
|
|
1293
1236
|
loader: getCompiledPkgPath('postcss-loader'),
|
|
1294
1237
|
options: {
|
|
1295
|
-
postcssOptions:
|
|
1238
|
+
postcssOptions: unpackConfig.css?.postcss,
|
|
1296
1239
|
sourceMap
|
|
1297
1240
|
}
|
|
1298
|
-
}
|
|
1299
|
-
}, getSassLoader = ()=>{
|
|
1300
|
-
var _unpackConfig_css;
|
|
1301
|
-
return {
|
|
1241
|
+
}, getSassLoader = ()=>({
|
|
1302
1242
|
loader: getCompiledPkgPath('sass-loader'),
|
|
1303
1243
|
options: {
|
|
1304
1244
|
api: 'modern-compiler',
|
|
@@ -1306,11 +1246,10 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1306
1246
|
'sass-embedded',
|
|
1307
1247
|
'sass'
|
|
1308
1248
|
]),
|
|
1309
|
-
sassOptions:
|
|
1249
|
+
sassOptions: unpackConfig.css?.sass,
|
|
1310
1250
|
sourceMap
|
|
1311
1251
|
}
|
|
1312
|
-
};
|
|
1313
|
-
};
|
|
1252
|
+
});
|
|
1314
1253
|
return config.module.rules.push({
|
|
1315
1254
|
test: /\.css$/i,
|
|
1316
1255
|
oneOf: [
|
|
@@ -1369,8 +1308,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1369
1308
|
config,
|
|
1370
1309
|
unpackConfig
|
|
1371
1310
|
}) : function({ config, unpackConfig }) {
|
|
1372
|
-
|
|
1373
|
-
let sourceMap = null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sourceMap, modules = null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.modules;
|
|
1311
|
+
let sourceMap = unpackConfig.css?.sourceMap, modules = unpackConfig.css?.modules;
|
|
1374
1312
|
isPlainObject(modules) || !1 === modules || (modules = {});
|
|
1375
1313
|
let getCommonRules = ({ importLoaders })=>[
|
|
1376
1314
|
utils_isDevServer() ? {
|
|
@@ -1399,7 +1337,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1399
1337
|
})(),
|
|
1400
1338
|
localIdentName: !1 !== modules && (modules.localIdentName || CSS_MODULES_LOCAL_IDENT_NAME),
|
|
1401
1339
|
exportLocalsConvention: EXPORT_LOCALS_CONVENTION,
|
|
1402
|
-
namedExport:
|
|
1340
|
+
namedExport: !1
|
|
1403
1341
|
},
|
|
1404
1342
|
sourceMap
|
|
1405
1343
|
}
|
|
@@ -1408,31 +1346,28 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1408
1346
|
utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
|
|
1409
1347
|
filename: getOutputFilename({
|
|
1410
1348
|
type: 'css',
|
|
1411
|
-
hash:
|
|
1349
|
+
hash: unpackConfig.build?.filenameHash
|
|
1412
1350
|
}),
|
|
1413
1351
|
chunkFilename: getOutputFilename({
|
|
1414
1352
|
type: 'css',
|
|
1415
|
-
hash:
|
|
1353
|
+
hash: unpackConfig.build?.filenameHash,
|
|
1416
1354
|
async: !0
|
|
1417
1355
|
}),
|
|
1418
1356
|
ignoreOrder: !0
|
|
1419
1357
|
}));
|
|
1420
|
-
let getCssLoader = ()=>{
|
|
1421
|
-
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
|
|
1422
|
-
return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
|
|
1358
|
+
let getCssLoader = ()=>unpackConfig.css?.transformer === 'lightningcss' ? {
|
|
1423
1359
|
loader: 'builtin:lightningcss-loader',
|
|
1424
1360
|
options: {
|
|
1425
1361
|
targets: esVersionToBrowserslist(unpackConfig.build.target),
|
|
1426
|
-
...
|
|
1362
|
+
...unpackConfig.css?.lightningcss
|
|
1427
1363
|
}
|
|
1428
1364
|
} : {
|
|
1429
1365
|
loader: getCompiledPkgPath('postcss-loader'),
|
|
1430
1366
|
options: {
|
|
1431
|
-
postcssOptions:
|
|
1367
|
+
postcssOptions: unpackConfig.css?.postcss,
|
|
1432
1368
|
sourceMap
|
|
1433
1369
|
}
|
|
1434
1370
|
};
|
|
1435
|
-
};
|
|
1436
1371
|
return config.module.rules.push({
|
|
1437
1372
|
test: /\.less$/i,
|
|
1438
1373
|
use: [
|
|
@@ -1440,7 +1375,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1440
1375
|
importLoaders: 2
|
|
1441
1376
|
}),
|
|
1442
1377
|
getCssLoader(),
|
|
1443
|
-
|
|
1378
|
+
unpackConfig.build?.parallel && isProd() && {
|
|
1444
1379
|
loader: require.resolve('thread-loader'),
|
|
1445
1380
|
options: THREAD_OPTIONS
|
|
1446
1381
|
},
|
|
@@ -1449,7 +1384,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1449
1384
|
options: {
|
|
1450
1385
|
lessOptions: mergeConfig({
|
|
1451
1386
|
javascriptEnabled: !0
|
|
1452
|
-
},
|
|
1387
|
+
}, unpackConfig.css?.less || {}),
|
|
1453
1388
|
implementation: getUserDepPath(unpackConfig.root, 'less'),
|
|
1454
1389
|
sourceMap
|
|
1455
1390
|
}
|
|
@@ -1478,7 +1413,7 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1478
1413
|
'sass-embedded',
|
|
1479
1414
|
'sass'
|
|
1480
1415
|
]),
|
|
1481
|
-
sassOptions:
|
|
1416
|
+
sassOptions: unpackConfig.css?.sass,
|
|
1482
1417
|
sourceMap
|
|
1483
1418
|
}
|
|
1484
1419
|
}
|
|
@@ -1489,15 +1424,56 @@ async function getBundlerConfig(originalUnpackConfig) {
|
|
|
1489
1424
|
unpackConfig
|
|
1490
1425
|
}),
|
|
1491
1426
|
unpackConfig
|
|
1492
|
-
}),
|
|
1427
|
+
}), unpackConfig.build?.cache && !(utils_isDevServer() && unpackConfig.dev?.lazyCompilation) && (config = await applyCacheConfig({
|
|
1493
1428
|
config,
|
|
1494
1429
|
unpackConfig,
|
|
1495
1430
|
envFilePaths
|
|
1496
|
-
})),
|
|
1431
|
+
})), unpackConfig.performance?.bundleAnalyze && isProd() && (config = await applyBundleAnalyzeConfig({
|
|
1497
1432
|
config
|
|
1498
1433
|
})), unpackConfig.typeCheck && isDev() && isTs && (config = await applyTypeCheckConfig({
|
|
1499
1434
|
config,
|
|
1500
1435
|
unpackConfig
|
|
1436
|
+
})), unpackConfig.detectCircular && (config = function({ config, unpackConfig }) {
|
|
1437
|
+
let circularCount = 0, circularDependencyPlugin = new rspack.CircularDependencyRspackPlugin({
|
|
1438
|
+
exclude: /node_modules/,
|
|
1439
|
+
onStart () {
|
|
1440
|
+
circularCount = 0;
|
|
1441
|
+
},
|
|
1442
|
+
onDetected (_, modules) {
|
|
1443
|
+
circularCount++, console.log(''), logger_logger.warn('circular dependency detected:');
|
|
1444
|
+
let uniquePaths = modules.map((module)=>{
|
|
1445
|
+
let filePath = module.replace(/^.*!/, ''), relativePath = node_path.relative(unpackConfig.root, filePath);
|
|
1446
|
+
return relativePath.startsWith('..') ? filePath : relativePath;
|
|
1447
|
+
}).slice(0, -1);
|
|
1448
|
+
if (2 + uniquePaths.join(' → ').length > (process.stdout.columns || 80)) {
|
|
1449
|
+
let arrow, lastIndex;
|
|
1450
|
+
console.log(''), arrow = '↳ ', lastIndex = uniquePaths.length - 1, uniquePaths.forEach((p, i)=>{
|
|
1451
|
+
switch(i){
|
|
1452
|
+
case 0:
|
|
1453
|
+
console.log(` ${p}`);
|
|
1454
|
+
break;
|
|
1455
|
+
case lastIndex:
|
|
1456
|
+
console.log(` ${arrow}${p} ${colors.dim('(cycle introduced)')}`);
|
|
1457
|
+
break;
|
|
1458
|
+
default:
|
|
1459
|
+
console.log(` ${arrow}${p}`);
|
|
1460
|
+
}
|
|
1461
|
+
}), console.log(` ${arrow}${uniquePaths[0]}`), console.log('');
|
|
1462
|
+
} else {
|
|
1463
|
+
let line1, downArrowPos, lineLength;
|
|
1464
|
+
line1 = ' ', downArrowPos = 0, uniquePaths.forEach((p, i)=>{
|
|
1465
|
+
line1 += p, i < uniquePaths.length - 1 ? line1 += ' → ' : downArrowPos = line1.length - 1;
|
|
1466
|
+
}), lineLength = downArrowPos - 2, console.log(''), console.log(line1), console.log(' ' + ' '.repeat(0) + '↑' + ' '.repeat(downArrowPos - 2 - 1) + '↓'), console.log(' ' + ' '.repeat(0) + '└' + '─'.repeat(lineLength - 1) + '┘'), console.log('');
|
|
1467
|
+
}
|
|
1468
|
+
},
|
|
1469
|
+
onEnd () {
|
|
1470
|
+
circularCount > 0 && console.log(`Found ${circularCount} circular ${1 === circularCount ? 'dependency' : 'dependencies'}`);
|
|
1471
|
+
}
|
|
1472
|
+
});
|
|
1473
|
+
return config.plugins?.push(circularDependencyPlugin), config;
|
|
1474
|
+
}({
|
|
1475
|
+
config,
|
|
1476
|
+
unpackConfig
|
|
1501
1477
|
})), getNormalizedPluginsByHook('bundlerConfig', unpackConfig.plugins)))config = await plugin.bundlerConfig(config, {
|
|
1502
1478
|
...unpackConfig._context,
|
|
1503
1479
|
unpackConfig,
|
|
@@ -1513,7 +1489,7 @@ async function unpackBuild(unpackConfig) {
|
|
|
1513
1489
|
console.error(err.stack || err), err.details && console.error(err.details);
|
|
1514
1490
|
return;
|
|
1515
1491
|
}
|
|
1516
|
-
|
|
1492
|
+
stats?.hasErrors() && console.log(stats.toString({
|
|
1517
1493
|
colors: !0,
|
|
1518
1494
|
preset: 'errors-only'
|
|
1519
1495
|
})), isWatch() || compiler.close(()=>{});
|
|
@@ -1588,13 +1564,13 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1588
1564
|
'react-dom': 'ReactDOM',
|
|
1589
1565
|
'react-router-dom': 'ReactRouterDOM'
|
|
1590
1566
|
})[pkgName] || pkgName, getExternalValue = (pkgName)=>`window ${getExternalLibraryName(pkgName)}`, prebundleDeps = async ({ unpackConfig })=>{
|
|
1591
|
-
var
|
|
1567
|
+
var externals;
|
|
1592
1568
|
let existExternals, cacheDir, count = {
|
|
1593
1569
|
total: 0,
|
|
1594
1570
|
bundled: 0
|
|
1595
1571
|
}, failedDeps = [], root = unpackConfig.root, failedDepsCachePath = node_path.resolve(root, TEMP_DIR, 'failed-deps.json'), failedCache = node_fs.existsSync(failedDepsCachePath) ? JSON.parse(node_fs.readFileSync(failedDepsCachePath, 'utf-8')) : {}, updateProgress = ()=>{
|
|
1596
1572
|
logUpdate(`${colors.magenta('»')} optimizing dependencies (${count.bundled}/${count.total})`), count.total === count.bundled + failedDeps.length && console.log();
|
|
1597
|
-
}, userOptions = isPlainObject(
|
|
1573
|
+
}, userOptions = isPlainObject(unpackConfig.dev?.prebundle) ? unpackConfig.dev.prebundle : {}, ignoreCSSDeps = userOptions.ignoreCSS || [], packageJson = JSON.parse(node_fs.readFileSync(node_path.resolve(root, 'package.json'), 'utf-8')), excludeDeps = [
|
|
1598
1574
|
...(externals = unpackConfig.externals, existExternals = new Set(), Array.isArray(externals) ? externals.forEach((item)=>{
|
|
1599
1575
|
isPlainObject(item) && Object.keys(item).forEach((key)=>{
|
|
1600
1576
|
existExternals.add(key);
|
|
@@ -1743,7 +1719,7 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1743
1719
|
});
|
|
1744
1720
|
compiler.run((_, stats)=>{
|
|
1745
1721
|
let isFailed = !1;
|
|
1746
|
-
|
|
1722
|
+
stats?.hasErrors() ? (isFailed = !0, failedDeps.push(name), failedCache[name] = version, removeDir(outDir)) : count.bundled++, updateProgress(), compiler.close(()=>{
|
|
1747
1723
|
resolve(isFailed ? void 0 : getResult());
|
|
1748
1724
|
});
|
|
1749
1725
|
});
|
|
@@ -1786,8 +1762,7 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1786
1762
|
}, unpackConfig.plugins.push({
|
|
1787
1763
|
name: 'unpack:prebundle',
|
|
1788
1764
|
config: (config)=>{
|
|
1789
|
-
|
|
1790
|
-
let originalHeadTag = (null == (_config_html = config.html) ? void 0 : _config_html.headTag) || '', sortedPreTags = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path).map((item)=>`<script defer src="${item}"></script>`);
|
|
1765
|
+
let originalHeadTag = config.html?.headTag || '', sortedPreTags = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path).map((item)=>`<script defer src="${item}"></script>`);
|
|
1791
1766
|
return setValueByPath(config, [
|
|
1792
1767
|
'html',
|
|
1793
1768
|
'headTag'
|
|
@@ -1806,12 +1781,11 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1806
1781
|
}), unpackConfig;
|
|
1807
1782
|
};
|
|
1808
1783
|
async function unpackDev(originalUnpackConfig) {
|
|
1809
|
-
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2, _unpackConfig_server3;
|
|
1810
1784
|
let unpackConfig = originalUnpackConfig;
|
|
1811
|
-
|
|
1785
|
+
unpackConfig.dev?.prebundle && (unpackConfig = await prebundleDeps({
|
|
1812
1786
|
unpackConfig
|
|
1813
1787
|
}));
|
|
1814
|
-
let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(
|
|
1788
|
+
let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(unpackConfig.server?.port), proxyConfig = unpackConfig.server?.proxy;
|
|
1815
1789
|
isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>{
|
|
1816
1790
|
let baseConfig = {
|
|
1817
1791
|
context: contextStr.split(','),
|
|
@@ -1834,16 +1808,15 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1834
1808
|
},
|
|
1835
1809
|
proxy: proxyConfig,
|
|
1836
1810
|
devMiddleware: {
|
|
1837
|
-
writeToDisk:
|
|
1811
|
+
writeToDisk: unpackConfig.dev?.writeToDisk
|
|
1838
1812
|
}
|
|
1839
1813
|
};
|
|
1840
1814
|
devServerOptions.setupMiddlewares = (middlewares)=>(middlewares.unshift((req, _, next)=>{
|
|
1841
|
-
|
|
1842
|
-
(null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
|
|
1815
|
+
req.headers.accept?.includes('html') && (req.url = '/index.html'), next();
|
|
1843
1816
|
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1844
1817
|
let server = new RspackDevServer(devServerOptions, compiler);
|
|
1845
|
-
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.3.
|
|
1846
|
-
let open =
|
|
1818
|
+
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.3.6`)} ${colors.dim('ready in')} ${colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))} ms\n`), printAddressUrls(port, unpackConfig.server?.host), addRestartCleaner(()=>server.stop(), ()=>new Promise((resolve)=>compiler.close(()=>resolve())));
|
|
1819
|
+
let open = unpackConfig.server?.open, url = isString(open) ? open : `http://localhost:${port}`;
|
|
1847
1820
|
open && openBrowser(url), setupCliShortcuts({
|
|
1848
1821
|
openPage: async ()=>{
|
|
1849
1822
|
await openBrowser(url);
|
|
@@ -1852,8 +1825,7 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1852
1825
|
await cleanUpBeforeRestart(), process.exit(0);
|
|
1853
1826
|
},
|
|
1854
1827
|
printUrls: ()=>{
|
|
1855
|
-
|
|
1856
|
-
printAddressUrls(port, null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.host);
|
|
1828
|
+
printAddressUrls(port, unpackConfig.server?.host);
|
|
1857
1829
|
},
|
|
1858
1830
|
restartServer: async ()=>{
|
|
1859
1831
|
logger_logger.clear(), await cleanUpBeforeRestart(), createUnpack({
|
|
@@ -1916,7 +1888,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1916
1888
|
...mergeConfig(defaultConfig, config),
|
|
1917
1889
|
_context: {
|
|
1918
1890
|
callerName,
|
|
1919
|
-
version: "3.3.
|
|
1891
|
+
version: "3.3.6"
|
|
1920
1892
|
}
|
|
1921
1893
|
};
|
|
1922
1894
|
};
|
|
@@ -1924,7 +1896,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1924
1896
|
build: async ({ watch } = {})=>{
|
|
1925
1897
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1926
1898
|
let config = resolveConfig();
|
|
1927
|
-
console.log(colors.rainbow(`${callerName} v3.3.
|
|
1899
|
+
console.log(colors.rainbow(`${callerName} v3.3.6`), colors.green(`building for ${getNodeEnv()}...`)), await unpackBuild(config);
|
|
1928
1900
|
},
|
|
1929
1901
|
dev: async ()=>{
|
|
1930
1902
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0);
|
|
@@ -1946,4 +1918,7 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1946
1918
|
...options
|
|
1947
1919
|
});
|
|
1948
1920
|
}
|
|
1949
|
-
|
|
1921
|
+
var __webpack_exports__CSS_NAMED_EXPORT = !1;
|
|
1922
|
+
import { fileURLToPath as __webpack_fileURLToPath__, pathToFileURL } from "node:url";
|
|
1923
|
+
import node_path, { dirname as __webpack_dirname__, join, sep } from "node:path";
|
|
1924
|
+
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, DEFAULT_DEV_HOST, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, addRestartCleaner, cleanUpBeforeRestart, clearLine, colors, createChokidar, createUnpack, currentDevUnpackConfig, debounce, defineConfig, esVersionToBrowserslist, findExists, getAddressUrls, getCompiledPkgPath, getIpv4Interfaces, getNodeEnv, getPathInJs, getPort, getTime, getUserDepPath, getUserDepVersion, getValueByPath, isBoolean, isCI, isCSSModules, isDebug, isDev, utils_isDevServer as isDevServer, isEmptyDir, isFileExists, isFileSync, isFunction, isNodeVersionAtLeast, isObject, isPlainObject, isProd, isRegExp, isString, isUndefined, isWatch, isWin, launchEditor, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, rspack, setCurrentDevUnpackConfig, setDevServer, setNodeEnv, setValueByPath, setupCliShortcuts, trackPerformance, __webpack_exports__CSS_NAMED_EXPORT as CSS_NAMED_EXPORT };
|