@unpackjs/core 2.4.5 → 3.0.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 +167 -235
- package/dist/index.js +162 -223
- package/dist/typedCssModulesLoader.mjs +4 -62
- package/dist-types/bundler-config/cache.d.ts.map +1 -1
- package/dist-types/bundler-config/css.d.ts.map +1 -1
- package/dist-types/bundler-config/experimentCss.d.ts.map +1 -1
- package/dist-types/bundler-config/index.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/jsMinify.d.ts +2 -2
- package/dist-types/bundler-config/plugins/jsMinify.d.ts.map +1 -1
- package/dist-types/bundler-config/plugins/progress/{rspack.d.ts → index.d.ts} +1 -1
- package/dist-types/bundler-config/plugins/progress/index.d.ts.map +1 -0
- package/dist-types/bundler-config/plugins/typedCssModules.d.ts +1 -1
- package/dist-types/bundler-config/plugins/typedCssModules.d.ts.map +1 -1
- package/dist-types/constants.d.ts +0 -1
- package/dist-types/constants.d.ts.map +1 -1
- package/dist-types/createUnpack.d.ts.map +1 -1
- package/dist-types/index.d.ts +0 -2
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/logger.d.ts.map +1 -1
- package/dist-types/openBrowser.d.ts.map +1 -1
- package/dist-types/prebundleDeps.d.ts.map +1 -1
- package/dist-types/progressBar.d.ts +0 -1
- package/dist-types/progressBar.d.ts.map +1 -1
- package/dist-types/reporter.d.ts +1 -2
- package/dist-types/reporter.d.ts.map +1 -1
- package/dist-types/run/build.d.ts.map +1 -1
- package/dist-types/run/dev.d.ts.map +1 -1
- package/dist-types/types/config.d.ts +4 -9
- package/dist-types/types/config.d.ts.map +1 -1
- package/dist-types/types/index.d.ts +0 -1
- package/dist-types/types/index.d.ts.map +1 -1
- package/dist-types/utils.d.ts.map +1 -1
- package/package.json +3 -9
- package/dist/lightningcssLoader.mjs +0 -18
- package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts +0 -5
- package/dist-types/bundler-config/loaders/lightningcssLoader.d.ts.map +0 -1
- package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts +0 -10
- package/dist-types/bundler-config/plugins/lightningcssMinify.d.ts.map +0 -1
- package/dist-types/bundler-config/plugins/progress/rspack.d.ts.map +0 -1
- package/dist-types/bundler-config/plugins/progress/webpack.d.ts +0 -9
- package/dist-types/bundler-config/plugins/progress/webpack.d.ts.map +0 -1
- package/dist-types/types/lightningcss.d.ts +0 -11
- package/dist-types/types/lightningcss.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,6 @@ import { dirname as __webpack_dirname__ } from "node:path";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_bundle_analyzer_index_js_1177eada__ from "../compiled/webpack-bundle-analyzer/index.js";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__compiled_webpack_merge_index_js_efd91626__ from "../compiled/webpack-merge/index.js";
|
|
7
7
|
import { experiments, rspack } from "@rspack/core";
|
|
8
|
-
import html_webpack_plugin from "html-webpack-plugin";
|
|
9
|
-
import webpack from "webpack";
|
|
10
8
|
import picocolors from "picocolors";
|
|
11
9
|
import node_fs from "node:fs";
|
|
12
10
|
import node_path, { join, sep } from "node:path";
|
|
@@ -14,23 +12,18 @@ import { pathToFileURL } from "node:url";
|
|
|
14
12
|
import { createJiti } from "jiti";
|
|
15
13
|
import node_readline from "node:readline";
|
|
16
14
|
import node_net from "node:net";
|
|
17
|
-
import node_os from "node:os";
|
|
15
|
+
import node_os, { platform } from "node:os";
|
|
18
16
|
import portfinder from "portfinder";
|
|
19
|
-
import { browserslistToTargets, transform } from "lightningcss";
|
|
20
|
-
import copy_webpack_plugin from "copy-webpack-plugin";
|
|
21
17
|
import json5 from "json5";
|
|
22
18
|
import { expand } from "dotenv-expand";
|
|
23
19
|
import { TsCheckerRspackPlugin } from "ts-checker-rspack-plugin";
|
|
24
20
|
import node_assert from "node:assert";
|
|
25
|
-
import mini_css_extract_plugin from "mini-css-extract-plugin";
|
|
26
21
|
import { glob, globSync } from "tinyglobby";
|
|
27
22
|
import typed_css_modules from "typed-css-modules";
|
|
28
23
|
import { minify } from "oxc-minify";
|
|
29
|
-
import { Buffer as external_node_buffer_Buffer } from "node:buffer";
|
|
30
24
|
import { exec, spawn } from "node:child_process";
|
|
31
25
|
import { promisify } from "node:util";
|
|
32
26
|
import node_zlib from "node:zlib";
|
|
33
|
-
import open_0 from "open";
|
|
34
27
|
import cors from "cors";
|
|
35
28
|
import express from "express";
|
|
36
29
|
import webpack_dev_server from "webpack-dev-server";
|
|
@@ -79,7 +72,7 @@ let CSS_MODULES_LOCAL_IDENT_NAME = '[path][name]__[local]--[hash:5]', CSS_MODULE
|
|
|
79
72
|
'edge >= 107',
|
|
80
73
|
'firefox >= 104',
|
|
81
74
|
'safari >= 16'
|
|
82
|
-
], DEFAULT_ES_TARGET = 'es2022',
|
|
75
|
+
], DEFAULT_ES_TARGET = 'es2022', TEMPLATE_CONTENT = ({ title = '', headTag = '', mountId = '' })=>`<!DOCTYPE html>
|
|
83
76
|
<html lang="en">
|
|
84
77
|
|
|
85
78
|
<head>
|
|
@@ -196,7 +189,7 @@ let debounce = (fn, delay)=>{
|
|
|
196
189
|
global[k] = performance.now();
|
|
197
190
|
return;
|
|
198
191
|
}
|
|
199
|
-
msg &&
|
|
192
|
+
msg && console.log(` ${msg} ${colors.dim('in')} ${colors.yellow(`${(performance.now() - global[k]).toFixed(2)}ms`)}`), global[k] = performance.now();
|
|
200
193
|
}, getPathInJs = (absPath)=>JSON.stringify(absPath).slice(1, -1), mergeConfig = merge, getUserDepVersion = (root, dep)=>{
|
|
201
194
|
let depPath = getUserDepPath(root, dep);
|
|
202
195
|
if (depPath) return JSON.parse(node_fs.readFileSync(node_path.resolve(depPath, 'package.json'), 'utf-8')).version;
|
|
@@ -249,10 +242,7 @@ let isCSSModules = ({ resourcePath, modules })=>{
|
|
|
249
242
|
text = colors.yellow(message);
|
|
250
243
|
break;
|
|
251
244
|
case 'debug':
|
|
252
|
-
text = `${colors.dim((()
|
|
253
|
-
let now = new Date(), hours = now.getHours().toString().padStart(2, '0'), minutes = now.getMinutes().toString().padStart(2, '0'), seconds = now.getSeconds().toString().padStart(2, '0');
|
|
254
|
-
return `${hours}:${minutes}:${seconds}`;
|
|
255
|
-
})())} ${colors.magenta('debug')} ${message}`;
|
|
245
|
+
text = `${colors.dim(getTime())} ${colors.magenta('debug')} ${message}`;
|
|
256
246
|
break;
|
|
257
247
|
default:
|
|
258
248
|
text = message;
|
|
@@ -348,7 +338,7 @@ let isFileSync = (filePath)=>{
|
|
|
348
338
|
return null == (_fs_statSync = node_fs.statSync(filePath, {
|
|
349
339
|
throwIfNoEntry: !1
|
|
350
340
|
})) ? void 0 : _fs_statSync.isFile();
|
|
351
|
-
} catch
|
|
341
|
+
} catch {
|
|
352
342
|
return !1;
|
|
353
343
|
}
|
|
354
344
|
};
|
|
@@ -399,8 +389,8 @@ async function getBuildDependencies(root, userBuildDependencies, envFilePaths) {
|
|
|
399
389
|
async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
|
|
400
390
|
var _unpackConfig_build, _unpackConfig_dev;
|
|
401
391
|
if (!(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.cache) || utils_isDevServer() && (null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.lazyCompilation)) return config;
|
|
402
|
-
let cacheConfig = isPlainObject(unpackConfig.build.cache) ? unpackConfig.build.cache : {},
|
|
403
|
-
return cacheDirectory && (cacheDirectory = node_path.resolve(unpackConfig.root, cacheDirectory)), logger_logger.info('persistent cache enabled'), config =
|
|
392
|
+
let cacheConfig = isPlainObject(unpackConfig.build.cache) ? unpackConfig.build.cache : {}, buildDependencies = await getBuildDependencies(unpackConfig.root, cacheConfig.buildDependencies || [], envFilePaths), cacheDirectory = cacheConfig.cacheDirectory;
|
|
393
|
+
return cacheDirectory && (cacheDirectory = node_path.resolve(unpackConfig.root, cacheDirectory)), logger_logger.info('persistent cache enabled'), config = mergeConfig(config, {
|
|
404
394
|
cache: !0,
|
|
405
395
|
experiments: {
|
|
406
396
|
cache: {
|
|
@@ -412,12 +402,6 @@ async function applyCacheConfig({ config, unpackConfig, envFilePaths }) {
|
|
|
412
402
|
}
|
|
413
403
|
}
|
|
414
404
|
}
|
|
415
|
-
}) : mergeConfig(config, {
|
|
416
|
-
cache: {
|
|
417
|
-
type: 'filesystem',
|
|
418
|
-
buildDependencies,
|
|
419
|
-
cacheDirectory
|
|
420
|
-
}
|
|
421
405
|
});
|
|
422
406
|
}
|
|
423
407
|
let MODULE_PATH_REGEX = /.*[\\/]node_modules[\\/](?!\.pnpm[\\/])(?:(@[^\\/]+)[\\/])?([^\\/]+)/, SPLIT_STRATEGY_DISPATCHER = {
|
|
@@ -578,7 +562,6 @@ class TypedCssModulesPlugin {
|
|
|
578
562
|
});
|
|
579
563
|
}
|
|
580
564
|
}
|
|
581
|
-
var experimentCss_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
582
565
|
function jsMinify_define_property(obj, key, value) {
|
|
583
566
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
584
567
|
value: value,
|
|
@@ -587,19 +570,18 @@ function jsMinify_define_property(obj, key, value) {
|
|
|
587
570
|
writable: !0
|
|
588
571
|
}) : obj[key] = value, obj;
|
|
589
572
|
}
|
|
590
|
-
let { RawSource
|
|
573
|
+
let { RawSource, SourceMapSource } = rspack.sources, isJsFile = /\.[cm]?js(\?.*)?$/i, jsMinify_PLUGIN_NAME = 'JsMinifyPlugin';
|
|
591
574
|
class JsMinifyPlugin {
|
|
592
575
|
apply(compiler) {
|
|
593
576
|
let meta = JSON.stringify({
|
|
594
577
|
name: jsMinify_PLUGIN_NAME,
|
|
595
|
-
version: "
|
|
578
|
+
version: "3.0.0",
|
|
596
579
|
options: this.minifyOptions
|
|
597
580
|
});
|
|
598
581
|
compiler.hooks.compilation.tap(jsMinify_PLUGIN_NAME, (compilation)=>{
|
|
599
|
-
compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(meta)), compilation.hooks.processAssets.tap({
|
|
582
|
+
compilation.hooks.chunkHash.tap(jsMinify_PLUGIN_NAME, (_, hash)=>hash.update(Buffer.from(meta))), compilation.hooks.processAssets.tap({
|
|
600
583
|
name: jsMinify_PLUGIN_NAME,
|
|
601
|
-
stage: compiler.
|
|
602
|
-
additionalAssets: !0
|
|
584
|
+
stage: compiler.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
603
585
|
}, ()=>this.transformAssets(compilation)), compilation.hooks.statsPrinter.tap(jsMinify_PLUGIN_NAME, (stats)=>{
|
|
604
586
|
stats.hooks.print.for('asset.info.minimized').tap(jsMinify_PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
|
|
605
587
|
});
|
|
@@ -615,7 +597,7 @@ class JsMinifyPlugin {
|
|
|
615
597
|
output.map && ((newMap = 'string' == typeof output.map ? JSON.parse(output.map) : output.map).sources = [
|
|
616
598
|
asset.name
|
|
617
599
|
]);
|
|
618
|
-
let newSource = sourceMap && newMap ? new
|
|
600
|
+
let newSource = sourceMap && newMap ? new SourceMapSource(output.code, asset.name, newMap, source, map, !0) : new RawSource(output.code), newInfo = {
|
|
619
601
|
...asset.info,
|
|
620
602
|
minimized: !0
|
|
621
603
|
};
|
|
@@ -628,48 +610,6 @@ class JsMinifyPlugin {
|
|
|
628
610
|
this.minify = (null == implementation ? void 0 : implementation.minify) ?? minify, this.minifyOptions = minifyOptions;
|
|
629
611
|
}
|
|
630
612
|
}
|
|
631
|
-
function lightningcssMinify_define_property(obj, key, value) {
|
|
632
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
633
|
-
value: value,
|
|
634
|
-
enumerable: !0,
|
|
635
|
-
configurable: !0,
|
|
636
|
-
writable: !0
|
|
637
|
-
}) : obj[key] = value, obj;
|
|
638
|
-
}
|
|
639
|
-
let lightningcssMinify_PLUGIN_NAME = 'LightningcssMinifyPlugin';
|
|
640
|
-
class LightningcssMinifyPlugin {
|
|
641
|
-
apply(compiler) {
|
|
642
|
-
compiler.hooks.compilation.tap(lightningcssMinify_PLUGIN_NAME, (compilation)=>{
|
|
643
|
-
compilation.hooks.processAssets.tap({
|
|
644
|
-
name: lightningcssMinify_PLUGIN_NAME,
|
|
645
|
-
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_SIZE
|
|
646
|
-
}, ()=>this.transformAssets(compilation)), compilation.hooks.statsPrinter.tap(lightningcssMinify_PLUGIN_NAME, (statsPrinter)=>{
|
|
647
|
-
statsPrinter.hooks.print.for('asset.info.minimized').tap(lightningcssMinify_PLUGIN_NAME, (minimized, { green, formatFlag })=>minimized && green && formatFlag ? green(formatFlag('minimized')) : '');
|
|
648
|
-
});
|
|
649
|
-
});
|
|
650
|
-
}
|
|
651
|
-
transformAssets(compilation) {
|
|
652
|
-
let { options: { devtool }, webpack: { sources: { SourceMapSource, RawSource } } } = compilation.compiler, sourceMap = 'string' == typeof devtool && devtool.includes('source-map');
|
|
653
|
-
compilation.getAssets().filter((asset)=>!asset.info.minimized && /\.css$/.test(asset.name)).map((asset)=>{
|
|
654
|
-
let { source, map } = asset.source.sourceAndMap(), sourceAsString = source.toString(), code = 'string' == typeof source ? external_node_buffer_Buffer.from(source) : source, result = this.transform({
|
|
655
|
-
filename: asset.name,
|
|
656
|
-
code,
|
|
657
|
-
minify: !0,
|
|
658
|
-
sourceMap,
|
|
659
|
-
...this.transformOptions
|
|
660
|
-
}), codeString = result.code.toString();
|
|
661
|
-
compilation.updateAsset(asset.name, sourceMap ? new SourceMapSource(codeString, asset.name, JSON.parse(result.map.toString()), sourceAsString, map, !0) : new RawSource(codeString), {
|
|
662
|
-
...asset.info,
|
|
663
|
-
minimized: !0
|
|
664
|
-
});
|
|
665
|
-
});
|
|
666
|
-
}
|
|
667
|
-
constructor(options = {}){
|
|
668
|
-
lightningcssMinify_define_property(this, "transform", void 0), lightningcssMinify_define_property(this, "transformOptions", void 0);
|
|
669
|
-
let { implementation, ...transformOptions } = options;
|
|
670
|
-
this.transform = (null == implementation ? void 0 : implementation.transform) ?? transform, this.transformOptions = transformOptions;
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
613
|
var oxlint_dirname = __webpack_dirname__(__webpack_fileURLToPath__(import.meta.url));
|
|
674
614
|
function oxlint_define_property(obj, key, value) {
|
|
675
615
|
return key in obj ? Object.defineProperty(obj, key, {
|
|
@@ -792,10 +732,7 @@ class ProgressBar {
|
|
|
792
732
|
let { columns: terminalWidth } = process.stdout, current = originalCurrent;
|
|
793
733
|
originalCurrent >= 0.98 && (current = 1);
|
|
794
734
|
let loadingChar = this.loadingAnimation.getCurrentChar(), messageWidth = terminalWidth - this.prefix.length - (1 === current ? 10 : 9);
|
|
795
|
-
logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`);
|
|
796
|
-
}
|
|
797
|
-
done() {
|
|
798
|
-
console.log();
|
|
735
|
+
logUpdate(`${loadingChar} ${this.prefix} (${Math.floor(100 * current)}%) ${colors.dim(message.slice(0, messageWidth).padEnd(messageWidth, ' '))}`), 1 === current && clearLine();
|
|
799
736
|
}
|
|
800
737
|
constructor(){
|
|
801
738
|
progressBar_define_property(this, "prefix", 'transforming'), progressBar_define_property(this, "loadingAnimation", new LoadingAnimation());
|
|
@@ -931,23 +868,23 @@ async function compileDone(compiler, stats) {
|
|
|
931
868
|
logger_logger.ready(`built in ${prettyTime(compileTime)}${isDebug() ? ` (${stats.compilation.modules.size} modules)` : ''}`);
|
|
932
869
|
}
|
|
933
870
|
}
|
|
934
|
-
let
|
|
871
|
+
let progress_PLUGIN_NAME = 'ProgressPlugin';
|
|
935
872
|
class ProgressLiteRspackPlugin {
|
|
936
873
|
apply(compiler) {
|
|
937
|
-
compiler.hooks.watchRun.tap(
|
|
874
|
+
compiler.hooks.watchRun.tap(progress_PLUGIN_NAME, ()=>{
|
|
938
875
|
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
939
|
-
}), compiler.hooks.run.tap(
|
|
876
|
+
}), compiler.hooks.run.tap(progress_PLUGIN_NAME, ()=>{
|
|
940
877
|
logger_logger.info('build started...');
|
|
941
|
-
}), compiler.hooks.afterDone.tap(
|
|
878
|
+
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
942
879
|
await compileDone(compiler, stats);
|
|
943
880
|
});
|
|
944
881
|
}
|
|
945
882
|
}
|
|
946
883
|
class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
947
884
|
apply(compiler) {
|
|
948
|
-
super.apply(compiler), compiler.hooks.watchRun.tap(
|
|
885
|
+
super.apply(compiler), compiler.hooks.watchRun.tap(progress_PLUGIN_NAME, ()=>{
|
|
949
886
|
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
950
|
-
}), compiler.hooks.afterDone.tap(
|
|
887
|
+
}), compiler.hooks.afterDone.tap(progress_PLUGIN_NAME, async (stats)=>{
|
|
951
888
|
await compileDone(compiler, stats);
|
|
952
889
|
});
|
|
953
890
|
}
|
|
@@ -966,41 +903,10 @@ class ProgressRspackPlugin extends rspack.ProgressPlugin {
|
|
|
966
903
|
}) : this[key] = value;
|
|
967
904
|
}
|
|
968
905
|
}
|
|
969
|
-
function webpack_define_property(obj, key, value) {
|
|
970
|
-
return key in obj ? Object.defineProperty(obj, key, {
|
|
971
|
-
value: value,
|
|
972
|
-
enumerable: !0,
|
|
973
|
-
configurable: !0,
|
|
974
|
-
writable: !0
|
|
975
|
-
}) : obj[key] = value, obj;
|
|
976
|
-
}
|
|
977
|
-
let webpack_PLUGIN_NAME = 'ProgressPlugin';
|
|
978
|
-
class ProgressWebpackPlugin extends webpack.ProgressPlugin {
|
|
979
|
-
apply(compiler) {
|
|
980
|
-
super.apply(compiler), compiler.hooks.watchRun.tap(webpack_PLUGIN_NAME, ()=>{
|
|
981
|
-
(!utils_isDevServer() || global.__unpack_dev_server_started) && printDevLog(compiler, compiler.options.context);
|
|
982
|
-
}), compiler.hooks.afterDone.tap(webpack_PLUGIN_NAME, async (stats)=>{
|
|
983
|
-
this.isCompleted = !0, await compileDone(compiler, stats);
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
constructor(){
|
|
987
|
-
super({
|
|
988
|
-
entries: !1,
|
|
989
|
-
dependencies: !1,
|
|
990
|
-
activeModules: !0,
|
|
991
|
-
handler: isProd() ? (percentage, msg, ...args)=>{
|
|
992
|
-
this.isCompleted || this.progressBar.update({
|
|
993
|
-
current: percentage,
|
|
994
|
-
message: `${msg} ${args.join(' ').replace(/(\d+) active /, '')}`
|
|
995
|
-
});
|
|
996
|
-
} : void 0
|
|
997
|
-
}), webpack_define_property(this, "progressBar", new ProgressBar()), webpack_define_property(this, "isCompleted", !1);
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
906
|
let BundleAnalyzerPlugin = __webpack_require__("compiled/webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
|
1001
907
|
async function getBundlerConfig(unpackConfig) {
|
|
1002
|
-
var _unpackConfig_build, _unpackConfig_build1,
|
|
1003
|
-
let
|
|
908
|
+
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_build2, _unpackConfig_build3, _unpackConfig_build4, _unpackConfig_build5, _unpackConfig_build6, _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_performance, _unpackConfig_performance1, _unpackConfig_build7, _unpackConfig_resolve, _unpackConfig_resolve1, _unpackConfig_dev, _unpackConfig_build8, _unpackConfig_experiments;
|
|
909
|
+
let tsconfigPath = node_path.resolve(unpackConfig.root, 'tsconfig.json'), isTs = node_fs.existsSync(tsconfigPath), minifyOptions = isPlainObject(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.minify) ? null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.minify : {}, ProgressPlugin = (null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.progressBar) ? ProgressRspackPlugin : ProgressLiteRspackPlugin, wasmFilename = 'js/[hash].module.wasm', { publicVars, filePaths: envFilePaths } = function({ cwd = process.cwd(), mode = getNodeEnv(), prefixes = [
|
|
1004
910
|
'PUBLIC_'
|
|
1005
911
|
], processEnv = process.env } = {}) {
|
|
1006
912
|
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.`);
|
|
@@ -1055,26 +961,26 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1055
961
|
stats: 'errors-only',
|
|
1056
962
|
output: {
|
|
1057
963
|
clean: !0,
|
|
1058
|
-
path: node_path.resolve(unpackConfig.root,
|
|
964
|
+
path: node_path.resolve(unpackConfig.root, unpackConfig.build.outDir),
|
|
1059
965
|
filename: getOutputFilename({
|
|
1060
966
|
type: 'js',
|
|
1061
|
-
hash: null == (
|
|
967
|
+
hash: null == (_unpackConfig_build3 = unpackConfig.build) ? void 0 : _unpackConfig_build3.filenameHash
|
|
1062
968
|
}),
|
|
1063
969
|
chunkFilename: getOutputFilename({
|
|
1064
970
|
type: 'js',
|
|
1065
|
-
hash: null == (
|
|
971
|
+
hash: null == (_unpackConfig_build4 = unpackConfig.build) ? void 0 : _unpackConfig_build4.filenameHash,
|
|
1066
972
|
async: !0
|
|
1067
973
|
}),
|
|
1068
974
|
crossOriginLoading: 'anonymous',
|
|
1069
975
|
pathinfo: !1,
|
|
1070
|
-
publicPath: null == (
|
|
976
|
+
publicPath: null == (_unpackConfig_build5 = unpackConfig.build) ? void 0 : _unpackConfig_build5.publicPath,
|
|
1071
977
|
webassemblyModuleFilename: wasmFilename,
|
|
1072
978
|
assetModuleFilename: 'assets/[name].[contenthash:8][ext]'
|
|
1073
979
|
},
|
|
1074
980
|
infrastructureLogging: {
|
|
1075
981
|
level: 'error'
|
|
1076
982
|
},
|
|
1077
|
-
devtool: null == (
|
|
983
|
+
devtool: null == (_unpackConfig_build6 = unpackConfig.build) ? void 0 : _unpackConfig_build6.sourceMap,
|
|
1078
984
|
module: {
|
|
1079
985
|
rules: [
|
|
1080
986
|
{
|
|
@@ -1096,23 +1002,23 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1096
1002
|
]
|
|
1097
1003
|
},
|
|
1098
1004
|
plugins: [
|
|
1099
|
-
(
|
|
1005
|
+
new rspack.DefinePlugin({
|
|
1100
1006
|
'import.meta.env.MODE': JSON.stringify(getNodeEnv()),
|
|
1101
1007
|
'import.meta.env.DEV': isDev(),
|
|
1102
1008
|
'import.meta.env.PROD': isProd(),
|
|
1103
1009
|
...publicVars,
|
|
1104
1010
|
...unpackConfig.define
|
|
1105
|
-
}
|
|
1106
|
-
!unpackConfig.mpa && new
|
|
1107
|
-
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) ||
|
|
1108
|
-
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ?
|
|
1011
|
+
}),
|
|
1012
|
+
!unpackConfig.mpa && new rspack.HtmlRspackPlugin({
|
|
1013
|
+
template: (null == (_unpackConfig_html = unpackConfig.html) ? void 0 : _unpackConfig_html.template) || void 0,
|
|
1014
|
+
templateContent: (null == (_unpackConfig_html1 = unpackConfig.html) ? void 0 : _unpackConfig_html1.templateContent) || ((null == (_unpackConfig_html2 = unpackConfig.html) ? void 0 : _unpackConfig_html2.template) ? void 0 : TEMPLATE_CONTENT),
|
|
1109
1015
|
templateParameters: {
|
|
1110
|
-
mountId:
|
|
1111
|
-
title: isFunction(null == (
|
|
1016
|
+
mountId: unpackConfig.html.mountId,
|
|
1017
|
+
title: isFunction(null == (_unpackConfig_html3 = unpackConfig.html) ? void 0 : _unpackConfig_html3.title) ? null == (_unpackConfig_html4 = unpackConfig.html) ? void 0 : _unpackConfig_html4.title({
|
|
1112
1018
|
entryName: 'index'
|
|
1113
|
-
}) : (null == (
|
|
1114
|
-
headTag: (null == (
|
|
1115
|
-
...null == (
|
|
1019
|
+
}) : (null == (_unpackConfig_html5 = unpackConfig.html) ? void 0 : _unpackConfig_html5.title) || '',
|
|
1020
|
+
headTag: (null == (_unpackConfig_html6 = unpackConfig.html) ? void 0 : _unpackConfig_html6.headTag) || '',
|
|
1021
|
+
...null == (_unpackConfig_html7 = unpackConfig.html) ? void 0 : _unpackConfig_html7.templateParameters
|
|
1116
1022
|
},
|
|
1117
1023
|
minify: !1,
|
|
1118
1024
|
chunks: [
|
|
@@ -1122,11 +1028,11 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1122
1028
|
(null == (_unpackConfig_performance = unpackConfig.performance) ? void 0 : _unpackConfig_performance.bundleAnalyze) && isProd() && new BundleAnalyzerPlugin({
|
|
1123
1029
|
analyzerPort: 'auto'
|
|
1124
1030
|
}),
|
|
1125
|
-
(null == (_unpackConfig_performance1 = unpackConfig.performance) ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new IgnorePlugin({
|
|
1031
|
+
(null == (_unpackConfig_performance1 = unpackConfig.performance) ? void 0 : _unpackConfig_performance1.removeMomentLocale) && new rspack.IgnorePlugin({
|
|
1126
1032
|
resourceRegExp: /^\.\/locale$/,
|
|
1127
1033
|
contextRegExp: /moment$/
|
|
1128
1034
|
}),
|
|
1129
|
-
(null == (
|
|
1035
|
+
(null == (_unpackConfig_build7 = unpackConfig.build) ? void 0 : _unpackConfig_build7.copy) && new rspack.CopyRspackPlugin({
|
|
1130
1036
|
patterns: unpackConfig.build.copy
|
|
1131
1037
|
}),
|
|
1132
1038
|
unpackConfig.typeCheck && isDev() && isTs && new TsCheckerRspackPlugin({
|
|
@@ -1199,19 +1105,18 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1199
1105
|
},
|
|
1200
1106
|
optimization: {
|
|
1201
1107
|
moduleIds: isDev() ? 'named' : 'deterministic',
|
|
1202
|
-
minimize: !!(null == (
|
|
1108
|
+
minimize: !!(null == (_unpackConfig_build8 = unpackConfig.build) ? void 0 : _unpackConfig_build8.minify),
|
|
1203
1109
|
minimizer: [
|
|
1204
|
-
new JsMinifyPlugin({
|
|
1205
|
-
...minifyOptions.oxc,
|
|
1110
|
+
new JsMinifyPlugin(mergeConfig({
|
|
1206
1111
|
compress: {
|
|
1207
|
-
target: DEFAULT_ES_TARGET
|
|
1208
|
-
...oxcMinifyCompress
|
|
1112
|
+
target: DEFAULT_ES_TARGET
|
|
1209
1113
|
}
|
|
1210
|
-
}),
|
|
1211
|
-
new
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1114
|
+
}, minifyOptions.oxc || {})),
|
|
1115
|
+
new rspack.LightningCssMinimizerRspackPlugin(mergeConfig({
|
|
1116
|
+
minimizerOptions: {
|
|
1117
|
+
targets: DEFAULT_BROWSERSLIST
|
|
1118
|
+
}
|
|
1119
|
+
}, minifyOptions.lightningcss || {}))
|
|
1215
1120
|
]
|
|
1216
1121
|
},
|
|
1217
1122
|
watchOptions: {
|
|
@@ -1249,7 +1154,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1249
1154
|
return config;
|
|
1250
1155
|
})({
|
|
1251
1156
|
config: config = (null == (_unpackConfig_experiments = unpackConfig.experiments) ? void 0 : _unpackConfig_experiments.css) ? function({ config, unpackConfig }) {
|
|
1252
|
-
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_css, _unpackConfig_css1
|
|
1157
|
+
var _unpackConfig_build, _unpackConfig_build1, _unpackConfig_css, _unpackConfig_css1;
|
|
1253
1158
|
config.output.cssFilename = getOutputFilename({
|
|
1254
1159
|
type: 'css',
|
|
1255
1160
|
hash: null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.filenameHash
|
|
@@ -1302,33 +1207,14 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1302
1207
|
sourceMap
|
|
1303
1208
|
}
|
|
1304
1209
|
};
|
|
1305
|
-
}
|
|
1306
|
-
null == (_config_module = config.module) || null == (_config_module_rules = _config_module.rules) || _config_module_rules.push({
|
|
1307
|
-
test: /\.less$/i,
|
|
1308
|
-
oneOf: [
|
|
1309
|
-
withCssModules({
|
|
1310
|
-
use: [
|
|
1311
|
-
getThreadLoader(),
|
|
1312
|
-
getLessLoader()
|
|
1313
|
-
].filter(Boolean)
|
|
1314
|
-
}),
|
|
1315
|
-
{
|
|
1316
|
-
use: [
|
|
1317
|
-
getThreadLoader(),
|
|
1318
|
-
getLessLoader()
|
|
1319
|
-
].filter(Boolean),
|
|
1320
|
-
type: 'css'
|
|
1321
|
-
}
|
|
1322
|
-
].filter(Boolean)
|
|
1323
|
-
});
|
|
1324
|
-
let getCssLoader = ()=>{
|
|
1210
|
+
}, getCssLoader = ()=>{
|
|
1325
1211
|
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
|
|
1326
1212
|
return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
|
|
1327
|
-
loader:
|
|
1328
|
-
options:
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
}
|
|
1213
|
+
loader: 'builtin:lightningcss-loader',
|
|
1214
|
+
options: {
|
|
1215
|
+
targets: DEFAULT_BROWSERSLIST,
|
|
1216
|
+
...null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.lightningcss
|
|
1217
|
+
}
|
|
1332
1218
|
} : {
|
|
1333
1219
|
loader: getCompiledPkgPath('postcss-loader'),
|
|
1334
1220
|
options: {
|
|
@@ -1336,8 +1222,22 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1336
1222
|
sourceMap
|
|
1337
1223
|
}
|
|
1338
1224
|
};
|
|
1225
|
+
}, getSassLoader = ()=>{
|
|
1226
|
+
var _unpackConfig_css;
|
|
1227
|
+
return {
|
|
1228
|
+
loader: getCompiledPkgPath('sass-loader'),
|
|
1229
|
+
options: {
|
|
1230
|
+
api: 'modern-compiler',
|
|
1231
|
+
implementation: getUserDepPath(unpackConfig.root, [
|
|
1232
|
+
'sass-embedded',
|
|
1233
|
+
'sass'
|
|
1234
|
+
]),
|
|
1235
|
+
sassOptions: null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sass,
|
|
1236
|
+
sourceMap
|
|
1237
|
+
}
|
|
1238
|
+
};
|
|
1339
1239
|
};
|
|
1340
|
-
|
|
1240
|
+
return config.module.rules.push({
|
|
1341
1241
|
test: /\.css$/i,
|
|
1342
1242
|
oneOf: [
|
|
1343
1243
|
withCssModules({
|
|
@@ -1352,32 +1252,37 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1352
1252
|
type: 'css'
|
|
1353
1253
|
}
|
|
1354
1254
|
].filter(Boolean)
|
|
1355
|
-
})
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1255
|
+
}), config.module.rules.push({
|
|
1256
|
+
test: /\.less$/i,
|
|
1257
|
+
oneOf: [
|
|
1258
|
+
withCssModules({
|
|
1259
|
+
use: [
|
|
1260
|
+
getCssLoader(),
|
|
1261
|
+
getThreadLoader(),
|
|
1262
|
+
getLessLoader()
|
|
1263
|
+
].filter(Boolean)
|
|
1264
|
+
}),
|
|
1265
|
+
{
|
|
1266
|
+
use: [
|
|
1267
|
+
getCssLoader(),
|
|
1268
|
+
getThreadLoader(),
|
|
1269
|
+
getLessLoader()
|
|
1270
|
+
].filter(Boolean),
|
|
1271
|
+
type: 'css'
|
|
1368
1272
|
}
|
|
1369
|
-
|
|
1370
|
-
}
|
|
1371
|
-
return null == (_config_module2 = config.module) || null == (_config_module_rules2 = _config_module2.rules) || _config_module_rules2.push({
|
|
1273
|
+
].filter(Boolean)
|
|
1274
|
+
}), config.module.rules.push({
|
|
1372
1275
|
test: /\.s[ac]ss$/i,
|
|
1373
1276
|
oneOf: [
|
|
1374
1277
|
withCssModules({
|
|
1375
1278
|
use: [
|
|
1279
|
+
getCssLoader(),
|
|
1376
1280
|
getSassLoader()
|
|
1377
1281
|
]
|
|
1378
1282
|
}),
|
|
1379
1283
|
{
|
|
1380
1284
|
use: [
|
|
1285
|
+
getCssLoader(),
|
|
1381
1286
|
getSassLoader()
|
|
1382
1287
|
],
|
|
1383
1288
|
type: 'css'
|
|
@@ -1390,14 +1295,14 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1390
1295
|
config,
|
|
1391
1296
|
unpackConfig
|
|
1392
1297
|
}) : function({ config, unpackConfig }) {
|
|
1393
|
-
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_build, _unpackConfig_css2,
|
|
1394
|
-
let
|
|
1298
|
+
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_build, _unpackConfig_css2, _unpackConfig_css3, _unpackConfig_build1, _unpackConfig_build2;
|
|
1299
|
+
let sourceMap = null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.sourceMap, modules = null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.modules;
|
|
1395
1300
|
isPlainObject(modules) || !1 === modules || (modules = {});
|
|
1396
1301
|
let getCommonRules = ({ importLoaders })=>[
|
|
1397
1302
|
utils_isDevServer() ? {
|
|
1398
1303
|
loader: getCompiledPkgPath('style-loader')
|
|
1399
1304
|
} : {
|
|
1400
|
-
loader:
|
|
1305
|
+
loader: rspack.CssExtractRspackPlugin.loader,
|
|
1401
1306
|
options: {
|
|
1402
1307
|
defaultExport: !0
|
|
1403
1308
|
}
|
|
@@ -1426,7 +1331,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1426
1331
|
}
|
|
1427
1332
|
}
|
|
1428
1333
|
].filter(Boolean);
|
|
1429
|
-
|
|
1334
|
+
utils_isDevServer() || config.plugins.push(new rspack.CssExtractRspackPlugin({
|
|
1430
1335
|
filename: getOutputFilename({
|
|
1431
1336
|
type: 'css',
|
|
1432
1337
|
hash: null == (_unpackConfig_build1 = unpackConfig.build) ? void 0 : _unpackConfig_build1.filenameHash
|
|
@@ -1436,12 +1341,30 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1436
1341
|
hash: null == (_unpackConfig_build2 = unpackConfig.build) ? void 0 : _unpackConfig_build2.filenameHash,
|
|
1437
1342
|
async: !0
|
|
1438
1343
|
})
|
|
1439
|
-
}))
|
|
1344
|
+
}));
|
|
1345
|
+
let getCssLoader = ()=>{
|
|
1346
|
+
var _unpackConfig_css, _unpackConfig_css1, _unpackConfig_css2;
|
|
1347
|
+
return (null == (_unpackConfig_css = unpackConfig.css) ? void 0 : _unpackConfig_css.transformer) === 'lightningcss' ? {
|
|
1348
|
+
loader: 'builtin:lightningcss-loader',
|
|
1349
|
+
options: {
|
|
1350
|
+
targets: DEFAULT_BROWSERSLIST,
|
|
1351
|
+
...null == (_unpackConfig_css1 = unpackConfig.css) ? void 0 : _unpackConfig_css1.lightningcss
|
|
1352
|
+
}
|
|
1353
|
+
} : {
|
|
1354
|
+
loader: getCompiledPkgPath('postcss-loader'),
|
|
1355
|
+
options: {
|
|
1356
|
+
postcssOptions: null == (_unpackConfig_css2 = unpackConfig.css) ? void 0 : _unpackConfig_css2.postcss,
|
|
1357
|
+
sourceMap
|
|
1358
|
+
}
|
|
1359
|
+
};
|
|
1360
|
+
};
|
|
1361
|
+
return config.module.rules.push({
|
|
1440
1362
|
test: /\.less$/i,
|
|
1441
1363
|
use: [
|
|
1442
1364
|
...getCommonRules({
|
|
1443
|
-
importLoaders:
|
|
1365
|
+
importLoaders: 2
|
|
1444
1366
|
}),
|
|
1367
|
+
getCssLoader(),
|
|
1445
1368
|
(null == (_unpackConfig_build = unpackConfig.build) ? void 0 : _unpackConfig_build.parallel) && isProd() && {
|
|
1446
1369
|
loader: require.resolve('thread-loader'),
|
|
1447
1370
|
options: THREAD_OPTIONS
|
|
@@ -1457,32 +1380,21 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1457
1380
|
}
|
|
1458
1381
|
}
|
|
1459
1382
|
].filter(Boolean)
|
|
1460
|
-
}),
|
|
1383
|
+
}), config.module.rules.push({
|
|
1461
1384
|
test: /\.css$/i,
|
|
1462
1385
|
use: [
|
|
1463
1386
|
...getCommonRules({
|
|
1464
1387
|
importLoaders: 1
|
|
1465
1388
|
}),
|
|
1466
|
-
(
|
|
1467
|
-
loader: node_path.resolve(css_dirname, './lightningcssLoader.mjs'),
|
|
1468
|
-
options: mergeConfig((null == (_unpackConfig_css5 = unpackConfig.css) ? void 0 : _unpackConfig_css5.lightningcss) || {}, {
|
|
1469
|
-
sourceMap,
|
|
1470
|
-
targets: DEFAULT_LIGHTNINGCSS_TARGET
|
|
1471
|
-
})
|
|
1472
|
-
} : {
|
|
1473
|
-
loader: getCompiledPkgPath('postcss-loader'),
|
|
1474
|
-
options: {
|
|
1475
|
-
postcssOptions: null == (_unpackConfig_css6 = unpackConfig.css) ? void 0 : _unpackConfig_css6.postcss,
|
|
1476
|
-
sourceMap
|
|
1477
|
-
}
|
|
1478
|
-
}
|
|
1389
|
+
getCssLoader()
|
|
1479
1390
|
]
|
|
1480
|
-
}),
|
|
1391
|
+
}), config.module.rules.push({
|
|
1481
1392
|
test: /\.s[ac]ss$/i,
|
|
1482
1393
|
use: [
|
|
1483
1394
|
...getCommonRules({
|
|
1484
|
-
importLoaders:
|
|
1395
|
+
importLoaders: 2
|
|
1485
1396
|
}),
|
|
1397
|
+
getCssLoader(),
|
|
1486
1398
|
{
|
|
1487
1399
|
loader: getCompiledPkgPath('sass-loader'),
|
|
1488
1400
|
options: {
|
|
@@ -1516,7 +1428,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
1516
1428
|
}) : mergeConfig(config, unpackConfig.bundlerConfig)), config;
|
|
1517
1429
|
}
|
|
1518
1430
|
async function unpackBuild(unpackConfig) {
|
|
1519
|
-
let compiler =
|
|
1431
|
+
let compiler = rspack(await getBundlerConfig(unpackConfig)), handler = (err, stats)=>{
|
|
1520
1432
|
if (err) {
|
|
1521
1433
|
console.error(err.stack || err), err.details && console.error(err.details);
|
|
1522
1434
|
return;
|
|
@@ -1549,7 +1461,38 @@ async function openBrowser(url) {
|
|
|
1549
1461
|
logger_logger.error(err);
|
|
1550
1462
|
}
|
|
1551
1463
|
try {
|
|
1552
|
-
return
|
|
1464
|
+
return new Promise((resolve, reject)=>{
|
|
1465
|
+
let command, args = [];
|
|
1466
|
+
switch(platform()){
|
|
1467
|
+
case 'darwin':
|
|
1468
|
+
command = 'open', args = [
|
|
1469
|
+
url
|
|
1470
|
+
];
|
|
1471
|
+
break;
|
|
1472
|
+
case 'win32':
|
|
1473
|
+
command = 'cmd', args = [
|
|
1474
|
+
'/c',
|
|
1475
|
+
'start',
|
|
1476
|
+
'',
|
|
1477
|
+
url
|
|
1478
|
+
];
|
|
1479
|
+
break;
|
|
1480
|
+
default:
|
|
1481
|
+
command = 'xdg-open', args = [
|
|
1482
|
+
url
|
|
1483
|
+
];
|
|
1484
|
+
}
|
|
1485
|
+
let child = spawn(command, args, {
|
|
1486
|
+
stdio: 'ignore',
|
|
1487
|
+
detached: !0,
|
|
1488
|
+
windowsHide: !0
|
|
1489
|
+
});
|
|
1490
|
+
child.on('error', (error)=>{
|
|
1491
|
+
reject(Error(`Failed to open URL: ${error.message}`));
|
|
1492
|
+
}), child.on('spawn', ()=>{
|
|
1493
|
+
resolve();
|
|
1494
|
+
}), child.unref();
|
|
1495
|
+
}).catch(()=>{}), !0;
|
|
1553
1496
|
} catch (err) {
|
|
1554
1497
|
return logger_logger.error(err), !1;
|
|
1555
1498
|
}
|
|
@@ -1733,7 +1676,7 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1733
1676
|
let port = await getPort(), staticServer = app.listen(port, ()=>{});
|
|
1734
1677
|
restartCleaners.push(()=>new Promise((resolve)=>staticServer.close(()=>resolve())));
|
|
1735
1678
|
let externals = {}, jsAssets = [], cssAssets = [], preJsAssets = [];
|
|
1736
|
-
bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
1679
|
+
return bundledDeps.filter(Boolean).forEach((dep)=>{
|
|
1737
1680
|
dep && (externals[dep.name] = getExternalValue(dep.name), dep.assets.forEach((absPath)=>{
|
|
1738
1681
|
let relativePath = node_path.relative(cachePath, absPath), preDeps = [
|
|
1739
1682
|
'react',
|
|
@@ -1757,16 +1700,14 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1757
1700
|
] : {
|
|
1758
1701
|
...externals,
|
|
1759
1702
|
...unpackConfig.externals
|
|
1760
|
-
}
|
|
1761
|
-
let HtmlPlugin = 'rspack' === unpackConfig.bundler ? rspack.HtmlRspackPlugin : html_webpack_plugin;
|
|
1762
|
-
return unpackConfig.plugins.push({
|
|
1703
|
+
}, unpackConfig.plugins.push({
|
|
1763
1704
|
name: 'unpack:prebundle',
|
|
1764
1705
|
bundlerConfig: (config)=>{
|
|
1765
1706
|
let PLUGIN_NAME = 'PluginInjectAssets';
|
|
1766
1707
|
return config.plugins.push({
|
|
1767
1708
|
apply: (compiler)=>{
|
|
1768
1709
|
compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation)=>{
|
|
1769
|
-
|
|
1710
|
+
rspack.HtmlRspackPlugin.getCompilationHooks(compilation).beforeAssetTagGeneration.tapPromise(PLUGIN_NAME, async (args)=>{
|
|
1770
1711
|
let sortedPreJsAssets = preJsAssets.sort((a, b)=>a.order - b.order).map((item)=>item.path);
|
|
1771
1712
|
return args.assets.js.unshift(...sortedPreJsAssets, ...jsAssets), args.assets.css.unshift(...cssAssets), args;
|
|
1772
1713
|
});
|
|
@@ -1778,11 +1719,11 @@ let getExternalLibraryName = (pkgName)=>({
|
|
|
1778
1719
|
};
|
|
1779
1720
|
async function unpackDev(originalUnpackConfig) {
|
|
1780
1721
|
var _unpackConfig_dev, _unpackConfig_server, _unpackConfig_server1, _unpackConfig_dev1, _unpackConfig_server2;
|
|
1781
|
-
let unpackConfig = originalUnpackConfig
|
|
1722
|
+
let unpackConfig = originalUnpackConfig;
|
|
1782
1723
|
(null == (_unpackConfig_dev = unpackConfig.dev) ? void 0 : _unpackConfig_dev.prebundle) && (unpackConfig = await prebundleDeps({
|
|
1783
1724
|
unpackConfig
|
|
1784
1725
|
}));
|
|
1785
|
-
let compiler =
|
|
1726
|
+
let compiler = rspack(await getBundlerConfig(unpackConfig)), port = await getPort(null == (_unpackConfig_server = unpackConfig.server) ? void 0 : _unpackConfig_server.port), proxyConfig = null == (_unpackConfig_server1 = unpackConfig.server) ? void 0 : _unpackConfig_server1.proxy;
|
|
1786
1727
|
isPlainObject(proxyConfig) && (proxyConfig = Object.entries(proxyConfig).map(([contextStr, target])=>({
|
|
1787
1728
|
context: contextStr.split(','),
|
|
1788
1729
|
target,
|
|
@@ -1803,9 +1744,9 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1803
1744
|
devServerOptions.setupMiddlewares = (middlewares)=>(middlewares.unshift((req, _, next)=>{
|
|
1804
1745
|
var _req_headers_accept;
|
|
1805
1746
|
(null == (_req_headers_accept = req.headers.accept) ? void 0 : _req_headers_accept.includes('html')) && (req.url = '/index.html'), next();
|
|
1806
|
-
}),
|
|
1747
|
+
}), middlewares.unshift(experiments.lazyCompilationMiddleware(compiler)), middlewares);
|
|
1807
1748
|
let server = new webpack_dev_server(devServerOptions, compiler);
|
|
1808
|
-
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())}
|
|
1749
|
+
await server.start(), logger_logger.greet(` ${colors.green(`${colors.bold(unpackConfig._context.callerName.toUpperCase())} v3.0.0`)} ${colors.dim(`ready in ${colors.reset(Math.ceil(performance.now() - global.__unpack_start_time))}ms`)}\n`), getAddressUrls({
|
|
1809
1750
|
port: port
|
|
1810
1751
|
}).forEach((addr)=>{
|
|
1811
1752
|
let url;
|
|
@@ -1822,7 +1763,6 @@ async function unpackDev(originalUnpackConfig) {
|
|
|
1822
1763
|
function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
1823
1764
|
let resolveConfig = async ()=>{
|
|
1824
1765
|
let defaultConfig = {
|
|
1825
|
-
bundler: 'rspack',
|
|
1826
1766
|
root: cwd,
|
|
1827
1767
|
build: {
|
|
1828
1768
|
outDir: 'dist',
|
|
@@ -1856,7 +1796,7 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1856
1796
|
]
|
|
1857
1797
|
}, _context = {
|
|
1858
1798
|
callerName,
|
|
1859
|
-
version: "
|
|
1799
|
+
version: "3.0.0"
|
|
1860
1800
|
}, { plugins, bundlerConfig, ...rest } = mergeConfig(defaultConfig, config);
|
|
1861
1801
|
for (let plugin of getNormalizedPluginsByHook('config', plugins))rest = await plugin.config(rest, {
|
|
1862
1802
|
..._context,
|
|
@@ -1871,10 +1811,9 @@ function createUnpack({ cwd = process.cwd(), config, callerName = 'unpack' }) {
|
|
|
1871
1811
|
};
|
|
1872
1812
|
return {
|
|
1873
1813
|
build: async ({ watch } = {})=>{
|
|
1874
|
-
var _config_build;
|
|
1875
1814
|
setNodeEnv(watch ? 'development' : 'production');
|
|
1876
1815
|
let config = await resolveConfig();
|
|
1877
|
-
console.log(colors.rainbow(`${callerName}
|
|
1816
|
+
console.log(colors.rainbow(`${callerName} v3.0.0`), colors.green(`building for ${getNodeEnv()}...`)), unpackBuild(config);
|
|
1878
1817
|
},
|
|
1879
1818
|
dev: async ()=>{
|
|
1880
1819
|
global.__unpack_start_time = performance.now(), setNodeEnv('development'), setDevServer(!0), unpackDev(await resolveConfig());
|
|
@@ -1894,4 +1833,4 @@ async function createChokidar(pathOrGlobs, root = process.cwd(), options) {
|
|
|
1894
1833
|
...options
|
|
1895
1834
|
});
|
|
1896
1835
|
}
|
|
1897
|
-
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_BROWSERSLIST, DEFAULT_DEV_HOST, DEFAULT_ES_TARGET,
|
|
1836
|
+
export { CSS_MODULES_LOCAL_IDENT_NAME, CSS_MODULES_REGEX, CSS_NAMED_EXPORT, DEFAULT_BROWSERSLIST, DEFAULT_DEV_HOST, DEFAULT_ES_TARGET, DEV_DEFAULT_FILENAME, EXPORT_LOCALS_CONVENTION, logger_LogColor as LogColor, NODE_MODULES_REGEX, PROD_DEFAULT_FILENAME, TEMPLATE_CONTENT, TEMP_DIR, THREAD_OPTIONS, clearLine, colors, createChokidar, createUnpack, debounce, defineConfig, 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, loadConfig, logUpdate, logger_logger as logger, mergeConfig, pathExists, prettyTime, removeDir, resolveConfigPath, restartCleaners, rspack, setDevServer, setNodeEnv, setValueByPath, trackPerformance };
|