@unpackjs/core 1.6.0 → 1.6.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/bundler-config/css.cjs +3 -4
- package/dist/bundler-config/css.js +5 -5
- package/dist/bundler-config/experimentCss.cjs +2 -3
- package/dist/bundler-config/experimentCss.js +3 -3
- package/dist/bundler-config/helper.cjs +4 -2
- package/dist/bundler-config/helper.d.ts.map +1 -1
- package/dist/bundler-config/helper.js +4 -2
- package/dist/bundler-config/index.cjs +18 -20
- package/dist/bundler-config/index.d.ts.map +1 -1
- package/dist/bundler-config/index.js +19 -29
- package/dist/config.cjs +14 -46
- package/dist/config.d.ts +2 -2
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +15 -47
- package/dist/createUnpack.cjs +102 -0
- package/dist/createUnpack.d.ts +7 -0
- package/dist/createUnpack.d.ts.map +1 -0
- package/dist/createUnpack.js +78 -0
- package/dist/index.cjs +5 -6
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -4
- package/dist/plugin-progress/rspack.cjs +1 -1
- package/dist/plugin-progress/rspack.js +1 -1
- package/dist/plugin-progress/webpack.cjs +1 -1
- package/dist/plugin-progress/webpack.js +1 -1
- package/dist/reporter.cjs +2 -2
- package/dist/reporter.d.ts +2 -1
- package/dist/reporter.d.ts.map +1 -1
- package/dist/reporter.js +2 -2
- package/dist/run/dev.cjs +1 -1
- package/dist/run/dev.js +1 -1
- package/dist/thread-loader/worker.js +1 -1
- package/dist/utils.cjs +9 -16
- package/dist/utils.d.ts +6 -2
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +7 -14
- package/package.json +2 -2
- package/dist/createService.cjs +0 -65
- package/dist/createService.d.ts +0 -8
- package/dist/createService.d.ts.map +0 -1
- package/dist/createService.js +0 -41
|
@@ -36,12 +36,11 @@ var import_mini_css_extract_plugin = __toESM(require("mini-css-extract-plugin"))
|
|
|
36
36
|
var import_constants = require("../constants.cjs");
|
|
37
37
|
var import_utils = require("../utils.cjs");
|
|
38
38
|
var import_helper = require("./helper.cjs");
|
|
39
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
40
39
|
function addCssSupport({
|
|
41
40
|
config,
|
|
42
41
|
unpackConfig
|
|
43
42
|
}) {
|
|
44
|
-
const MiniCssExtractPlugin = unpackConfig.bundler === "
|
|
43
|
+
const MiniCssExtractPlugin = unpackConfig.bundler === "rspack" ? import_core.rspack.CssExtractRspackPlugin : import_mini_css_extract_plugin.default;
|
|
45
44
|
let modules = unpackConfig.css?.modules;
|
|
46
45
|
if (!(0, import_utils.isPlainObject)(modules) && modules !== false)
|
|
47
46
|
modules = {};
|
|
@@ -109,7 +108,7 @@ function addCssSupport({
|
|
|
109
108
|
{
|
|
110
109
|
loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
|
|
111
110
|
options: {
|
|
112
|
-
lessOptions:
|
|
111
|
+
lessOptions: (0, import_utils.mergeConfig)(
|
|
113
112
|
{
|
|
114
113
|
javascriptEnabled: true
|
|
115
114
|
},
|
|
@@ -124,7 +123,7 @@ function addCssSupport({
|
|
|
124
123
|
const getLightningcssLoader = () => {
|
|
125
124
|
return {
|
|
126
125
|
loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
|
|
127
|
-
options:
|
|
126
|
+
options: (0, import_utils.mergeConfig)(unpackConfig.css?.lightningcss || {}, {
|
|
128
127
|
sourceMap: unpackConfig.css?.sourceMap
|
|
129
128
|
})
|
|
130
129
|
};
|
|
@@ -24,15 +24,15 @@ import {
|
|
|
24
24
|
isDevServer,
|
|
25
25
|
isFunction,
|
|
26
26
|
isPlainObject,
|
|
27
|
-
isRegExp
|
|
27
|
+
isRegExp,
|
|
28
|
+
mergeConfig
|
|
28
29
|
} from "../utils.js";
|
|
29
30
|
import { getOutputFilename } from "./helper.js";
|
|
30
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
31
31
|
function addCssSupport({
|
|
32
32
|
config,
|
|
33
33
|
unpackConfig
|
|
34
34
|
}) {
|
|
35
|
-
const MiniCssExtractPlugin = unpackConfig.bundler === "
|
|
35
|
+
const MiniCssExtractPlugin = unpackConfig.bundler === "rspack" ? rspack.CssExtractRspackPlugin : WebpackMiniCssExtractPlugin;
|
|
36
36
|
let modules = unpackConfig.css?.modules;
|
|
37
37
|
if (!isPlainObject(modules) && modules !== false)
|
|
38
38
|
modules = {};
|
|
@@ -100,7 +100,7 @@ function addCssSupport({
|
|
|
100
100
|
{
|
|
101
101
|
loader: getCompiledPkgPath("less-loader"),
|
|
102
102
|
options: {
|
|
103
|
-
lessOptions:
|
|
103
|
+
lessOptions: mergeConfig(
|
|
104
104
|
{
|
|
105
105
|
javascriptEnabled: true
|
|
106
106
|
},
|
|
@@ -115,7 +115,7 @@ function addCssSupport({
|
|
|
115
115
|
const getLightningcssLoader = () => {
|
|
116
116
|
return {
|
|
117
117
|
loader: path2.resolve(__dirname, "../lightningcss/loader.cjs"),
|
|
118
|
-
options:
|
|
118
|
+
options: mergeConfig(unpackConfig.css?.lightningcss || {}, {
|
|
119
119
|
sourceMap: unpackConfig.css?.sourceMap
|
|
120
120
|
})
|
|
121
121
|
};
|
|
@@ -35,7 +35,6 @@ var import_constants = require("../constants.cjs");
|
|
|
35
35
|
var import_typed_css_modules = require("../typed-css-modules/index.cjs");
|
|
36
36
|
var import_utils = require("../utils.cjs");
|
|
37
37
|
var import_helper = require("./helper.cjs");
|
|
38
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
39
38
|
function addExperimentCssSupport({
|
|
40
39
|
config,
|
|
41
40
|
unpackConfig
|
|
@@ -86,7 +85,7 @@ function addExperimentCssSupport({
|
|
|
86
85
|
return {
|
|
87
86
|
loader: (0, import_utils.getCompiledPkgPath)("less-loader"),
|
|
88
87
|
options: {
|
|
89
|
-
lessOptions:
|
|
88
|
+
lessOptions: (0, import_utils.mergeConfig)(
|
|
90
89
|
{
|
|
91
90
|
javascriptEnabled: true
|
|
92
91
|
},
|
|
@@ -110,7 +109,7 @@ function addExperimentCssSupport({
|
|
|
110
109
|
const getLightningcssLoader = () => {
|
|
111
110
|
return {
|
|
112
111
|
loader: import_node_path.default.resolve(__dirname, "../lightningcss/loader.cjs"),
|
|
113
|
-
options:
|
|
112
|
+
options: (0, import_utils.mergeConfig)(unpackConfig.css?.lightningcss || {}, {
|
|
114
113
|
sourceMap: unpackConfig.css?.sourceMap
|
|
115
114
|
})
|
|
116
115
|
};
|
|
@@ -23,10 +23,10 @@ import {
|
|
|
23
23
|
isFunction,
|
|
24
24
|
isPlainObject,
|
|
25
25
|
isRegExp,
|
|
26
|
+
mergeConfig,
|
|
26
27
|
setValueByPath
|
|
27
28
|
} from "../utils.js";
|
|
28
29
|
import { getOutputFilename } from "./helper.js";
|
|
29
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
30
30
|
function addExperimentCssSupport({
|
|
31
31
|
config,
|
|
32
32
|
unpackConfig
|
|
@@ -77,7 +77,7 @@ function addExperimentCssSupport({
|
|
|
77
77
|
return {
|
|
78
78
|
loader: getCompiledPkgPath("less-loader"),
|
|
79
79
|
options: {
|
|
80
|
-
lessOptions:
|
|
80
|
+
lessOptions: mergeConfig(
|
|
81
81
|
{
|
|
82
82
|
javascriptEnabled: true
|
|
83
83
|
},
|
|
@@ -101,7 +101,7 @@ function addExperimentCssSupport({
|
|
|
101
101
|
const getLightningcssLoader = () => {
|
|
102
102
|
return {
|
|
103
103
|
loader: path2.resolve(__dirname, "../lightningcss/loader.cjs"),
|
|
104
|
-
options:
|
|
104
|
+
options: mergeConfig(unpackConfig.css?.lightningcss || {}, {
|
|
105
105
|
sourceMap: unpackConfig.css?.sourceMap
|
|
106
106
|
})
|
|
107
107
|
};
|
|
@@ -38,13 +38,15 @@ var import_constants = require("../constants.cjs");
|
|
|
38
38
|
var import_logger = require("../logger.cjs");
|
|
39
39
|
const glob = require("../../compiled/fast-glob/index.js");
|
|
40
40
|
async function getEntry(root, customEntry) {
|
|
41
|
-
let entry =
|
|
42
|
-
if (!
|
|
41
|
+
let entry = void 0;
|
|
42
|
+
if (!customEntry) {
|
|
43
43
|
const files = await glob("(index|Index).{js,ts,jsx,tsx}", {
|
|
44
44
|
cwd: import_node_path.default.join(root, "src"),
|
|
45
45
|
absolute: true
|
|
46
46
|
});
|
|
47
47
|
entry = files[0];
|
|
48
|
+
} else {
|
|
49
|
+
entry = import_node_path.default.resolve(root, customEntry);
|
|
48
50
|
}
|
|
49
51
|
if (!import_node_fs.default.existsSync(entry)) {
|
|
50
52
|
import_logger.logger.error(new Error("Could not find entry file"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/bundler-config/helper.ts"],"names":[],"mappings":"AAOA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../../src/bundler-config/helper.ts"],"names":[],"mappings":"AAOA,wBAAsB,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgBjF;AAED,KAAK,cAAc,GAAG;IACpB,IAAI,EAAE,IAAI,GAAG,KAAK,CAAA;IAClB,IAAI,EAAE,OAAO,CAAA;CACd,CAAA;AACD,eAAO,MAAM,iBAAiB,mBAAoB,cAAc,WAqB/D,CAAA"}
|
|
@@ -14,13 +14,15 @@ import { isDev } from "../utils.js";
|
|
|
14
14
|
import { DEV_DEFAULT_FILENAME, PROD_DEFAULT_FILENAME } from "../constants.js";
|
|
15
15
|
import { logger } from "../logger.js";
|
|
16
16
|
async function getEntry(root, customEntry) {
|
|
17
|
-
let entry =
|
|
18
|
-
if (!
|
|
17
|
+
let entry = void 0;
|
|
18
|
+
if (!customEntry) {
|
|
19
19
|
const files = await glob("(index|Index).{js,ts,jsx,tsx}", {
|
|
20
20
|
cwd: path2.join(root, "src"),
|
|
21
21
|
absolute: true
|
|
22
22
|
});
|
|
23
23
|
entry = files[0];
|
|
24
|
+
} else {
|
|
25
|
+
entry = path2.resolve(root, customEntry);
|
|
24
26
|
}
|
|
25
27
|
if (!fs.existsSync(entry)) {
|
|
26
28
|
logger.error(new Error("Could not find entry file"));
|
|
@@ -52,28 +52,26 @@ var import_helper = require("./helper.cjs");
|
|
|
52
52
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
53
53
|
const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
54
54
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
55
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
56
55
|
async function getBundlerConfig(unpackConfig) {
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
return new import_core.rspack.DefinePlugin(define);
|
|
60
|
-
}
|
|
61
|
-
return new import_esbuild_loader.EsbuildPlugin({ define, implementation: import_esbuild.default });
|
|
62
|
-
};
|
|
56
|
+
const isRspack = unpackConfig.bundler === "rspack";
|
|
57
|
+
const definePlugin = (define) => isRspack ? new import_core.rspack.DefinePlugin(define) : new import_esbuild_loader.EsbuildPlugin({ define, implementation: import_esbuild.default });
|
|
63
58
|
const JS_FILENAME = (0, import_helper.getOutputFilename)({ type: "js", hash: unpackConfig.build?.filenameHash });
|
|
64
|
-
const IgnorePlugin =
|
|
65
|
-
const CopyPlugin =
|
|
59
|
+
const IgnorePlugin = isRspack ? import_core.rspack.IgnorePlugin : import_webpack2.default.IgnorePlugin;
|
|
60
|
+
const CopyPlugin = isRspack ? import_core.rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
61
|
+
const tsconfigPath = import_node_path.default.resolve(unpackConfig.root, "tsconfig.json");
|
|
62
|
+
const isTs = import_node_fs.default.existsSync(tsconfigPath);
|
|
66
63
|
const getAliasFromTsconfig = () => {
|
|
67
|
-
const paths = import_json5.default.parse(
|
|
68
|
-
import_node_fs.default.readFileSync(import_node_path.default.resolve(unpackConfig.root, "tsconfig.json"), "utf-8")
|
|
69
|
-
)?.compilerOptions?.paths;
|
|
64
|
+
const paths = import_json5.default.parse(import_node_fs.default.readFileSync(tsconfigPath, "utf-8"))?.compilerOptions?.paths;
|
|
70
65
|
return paths ? Object.keys(paths).reduce((acc, key) => {
|
|
71
|
-
acc[key.replace(/\/\*$/, "")] =
|
|
66
|
+
acc[key.replace(/\/\*$/, "")] = import_node_path.default.resolve(
|
|
67
|
+
unpackConfig.root,
|
|
68
|
+
paths[key][0].replace(/\/\*$/, "")
|
|
69
|
+
);
|
|
72
70
|
return acc;
|
|
73
71
|
}, {}) : {};
|
|
74
72
|
};
|
|
75
73
|
const minifyOptions = (0, import_utils.isPlainObject)(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {};
|
|
76
|
-
const PluginProgress =
|
|
74
|
+
const PluginProgress = isRspack ? import_rspack.RspackPluginProgress : import_webpack.WebpackPluginProgress;
|
|
77
75
|
let config = {
|
|
78
76
|
context: unpackConfig.root,
|
|
79
77
|
mode: (0, import_utils.isDev)() ? "development" : "production",
|
|
@@ -126,14 +124,14 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
126
124
|
contextRegExp: /moment$/
|
|
127
125
|
}),
|
|
128
126
|
unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
|
|
129
|
-
(0, import_utils.isDev)() &&
|
|
127
|
+
(0, import_utils.isDev)() && isTs && new ForkTsCheckerWebpackPlugin({
|
|
130
128
|
typescript: {
|
|
131
129
|
// set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
|
|
132
130
|
mode: "readonly",
|
|
133
131
|
// avoid OOM issue
|
|
134
132
|
memoryLimit: 8192,
|
|
135
133
|
// use tsconfig of user project
|
|
136
|
-
configFile:
|
|
134
|
+
configFile: tsconfigPath,
|
|
137
135
|
// use typescript of user project
|
|
138
136
|
typescriptPath: require.resolve("typescript", {
|
|
139
137
|
paths: [unpackConfig.root]
|
|
@@ -156,7 +154,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
156
154
|
resolve: {
|
|
157
155
|
alias: {
|
|
158
156
|
"@": import_node_path.default.resolve(unpackConfig.root, "src"),
|
|
159
|
-
...
|
|
157
|
+
...isTs ? getAliasFromTsconfig() : {},
|
|
160
158
|
...unpackConfig.resolve?.alias
|
|
161
159
|
},
|
|
162
160
|
extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
|
|
@@ -184,7 +182,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
184
182
|
for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("bundlerConfig", unpackConfig.plugins)) {
|
|
185
183
|
config = await plugin.bundlerConfig(config, {
|
|
186
184
|
unpackConfig,
|
|
187
|
-
mergeConfig:
|
|
185
|
+
mergeConfig: import_utils.mergeConfig,
|
|
188
186
|
bundler: import_webpack2.default
|
|
189
187
|
});
|
|
190
188
|
}
|
|
@@ -192,10 +190,10 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
192
190
|
if ((0, import_utils.isFunction)(unpackConfig.bundlerConfig)) {
|
|
193
191
|
config = await unpackConfig.bundlerConfig(config, {
|
|
194
192
|
bundler: unpackConfig.bundler,
|
|
195
|
-
mergeConfig:
|
|
193
|
+
mergeConfig: import_utils.mergeConfig
|
|
196
194
|
});
|
|
197
195
|
} else {
|
|
198
|
-
config =
|
|
196
|
+
config = (0, import_utils.mergeConfig)(config, unpackConfig.bundlerConfig);
|
|
199
197
|
}
|
|
200
198
|
}
|
|
201
199
|
return config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundler-config/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAqBzE,wBAAsB,gBAAgB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAmKhG"}
|
|
@@ -11,15 +11,7 @@ import fs from "node:fs";
|
|
|
11
11
|
import path2 from "node:path";
|
|
12
12
|
import { rspack } from "@rspack/core";
|
|
13
13
|
import HtmlWebpackPlugin from "html-webpack-plugin";
|
|
14
|
-
import {
|
|
15
|
-
getValidPath,
|
|
16
|
-
isDev,
|
|
17
|
-
isDevServer,
|
|
18
|
-
isFunction,
|
|
19
|
-
isPlainObject,
|
|
20
|
-
isProd,
|
|
21
|
-
isTs
|
|
22
|
-
} from "../utils.js";
|
|
14
|
+
import { isDev, isDevServer, isFunction, isPlainObject, isProd, mergeConfig } from "../utils.js";
|
|
23
15
|
const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin");
|
|
24
16
|
const BundleAnalyzerPlugin = require("../../compiled/webpack-bundle-analyzer/index.js").BundleAnalyzerPlugin;
|
|
25
17
|
const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
@@ -37,28 +29,26 @@ import { addChunkSplitSupport } from "./chunkSplit.js";
|
|
|
37
29
|
import { addCssSupport } from "./css.js";
|
|
38
30
|
import { addExperimentCssSupport } from "./experimentCss.js";
|
|
39
31
|
import { getEntry, getOutputFilename } from "./helper.js";
|
|
40
|
-
const { merge } = require("../../compiled/webpack-merge/index.js");
|
|
41
32
|
async function getBundlerConfig(unpackConfig) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
return new rspack.DefinePlugin(define);
|
|
45
|
-
}
|
|
46
|
-
return new EsbuildPlugin({ define, implementation: esbuild });
|
|
47
|
-
};
|
|
33
|
+
const isRspack = unpackConfig.bundler === "rspack";
|
|
34
|
+
const definePlugin = (define) => isRspack ? new rspack.DefinePlugin(define) : new EsbuildPlugin({ define, implementation: esbuild });
|
|
48
35
|
const JS_FILENAME = getOutputFilename({ type: "js", hash: unpackConfig.build?.filenameHash });
|
|
49
|
-
const IgnorePlugin =
|
|
50
|
-
const CopyPlugin =
|
|
36
|
+
const IgnorePlugin = isRspack ? rspack.IgnorePlugin : webpack.IgnorePlugin;
|
|
37
|
+
const CopyPlugin = isRspack ? rspack.CopyRspackPlugin : CopyWebpackPlugin;
|
|
38
|
+
const tsconfigPath = path2.resolve(unpackConfig.root, "tsconfig.json");
|
|
39
|
+
const isTs = fs.existsSync(tsconfigPath);
|
|
51
40
|
const getAliasFromTsconfig = () => {
|
|
52
|
-
const paths = json5.parse(
|
|
53
|
-
fs.readFileSync(path2.resolve(unpackConfig.root, "tsconfig.json"), "utf-8")
|
|
54
|
-
)?.compilerOptions?.paths;
|
|
41
|
+
const paths = json5.parse(fs.readFileSync(tsconfigPath, "utf-8"))?.compilerOptions?.paths;
|
|
55
42
|
return paths ? Object.keys(paths).reduce((acc, key) => {
|
|
56
|
-
acc[key.replace(/\/\*$/, "")] =
|
|
43
|
+
acc[key.replace(/\/\*$/, "")] = path2.resolve(
|
|
44
|
+
unpackConfig.root,
|
|
45
|
+
paths[key][0].replace(/\/\*$/, "")
|
|
46
|
+
);
|
|
57
47
|
return acc;
|
|
58
48
|
}, {}) : {};
|
|
59
49
|
};
|
|
60
50
|
const minifyOptions = isPlainObject(unpackConfig.build?.minify) ? unpackConfig.build?.minify : {};
|
|
61
|
-
const PluginProgress =
|
|
51
|
+
const PluginProgress = isRspack ? RspackPluginProgress : WebpackPluginProgress;
|
|
62
52
|
let config = {
|
|
63
53
|
context: unpackConfig.root,
|
|
64
54
|
mode: isDev() ? "development" : "production",
|
|
@@ -111,14 +101,14 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
111
101
|
contextRegExp: /moment$/
|
|
112
102
|
}),
|
|
113
103
|
unpackConfig.build?.copy && new CopyPlugin({ patterns: unpackConfig.build.copy }),
|
|
114
|
-
isDev() && isTs
|
|
104
|
+
isDev() && isTs && new ForkTsCheckerWebpackPlugin({
|
|
115
105
|
typescript: {
|
|
116
106
|
// set 'readonly' to avoid emitting tsbuildinfo, as the generated tsbuildinfo will break fork-ts-checker
|
|
117
107
|
mode: "readonly",
|
|
118
108
|
// avoid OOM issue
|
|
119
109
|
memoryLimit: 8192,
|
|
120
110
|
// use tsconfig of user project
|
|
121
|
-
configFile:
|
|
111
|
+
configFile: tsconfigPath,
|
|
122
112
|
// use typescript of user project
|
|
123
113
|
typescriptPath: require.resolve("typescript", {
|
|
124
114
|
paths: [unpackConfig.root]
|
|
@@ -141,7 +131,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
141
131
|
resolve: {
|
|
142
132
|
alias: {
|
|
143
133
|
"@": path2.resolve(unpackConfig.root, "src"),
|
|
144
|
-
...isTs
|
|
134
|
+
...isTs ? getAliasFromTsconfig() : {},
|
|
145
135
|
...unpackConfig.resolve?.alias
|
|
146
136
|
},
|
|
147
137
|
extensions: [".tsx", ".ts", ".jsx", ".js", ...unpackConfig.resolve?.extensions || []]
|
|
@@ -169,7 +159,7 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
169
159
|
for (const plugin of getNormalizedPluginsByHook("bundlerConfig", unpackConfig.plugins)) {
|
|
170
160
|
config = await plugin.bundlerConfig(config, {
|
|
171
161
|
unpackConfig,
|
|
172
|
-
mergeConfig
|
|
162
|
+
mergeConfig,
|
|
173
163
|
bundler: webpack
|
|
174
164
|
});
|
|
175
165
|
}
|
|
@@ -177,10 +167,10 @@ async function getBundlerConfig(unpackConfig) {
|
|
|
177
167
|
if (isFunction(unpackConfig.bundlerConfig)) {
|
|
178
168
|
config = await unpackConfig.bundlerConfig(config, {
|
|
179
169
|
bundler: unpackConfig.bundler,
|
|
180
|
-
mergeConfig
|
|
170
|
+
mergeConfig
|
|
181
171
|
});
|
|
182
172
|
} else {
|
|
183
|
-
config =
|
|
173
|
+
config = mergeConfig(config, unpackConfig.bundlerConfig);
|
|
184
174
|
}
|
|
185
175
|
}
|
|
186
176
|
return config;
|
package/dist/config.cjs
CHANGED
|
@@ -35,13 +35,17 @@ var import_node_fs = __toESM(require("node:fs"));
|
|
|
35
35
|
var import_node_path = require("node:path");
|
|
36
36
|
var import_bundleRequire = require("./bundleRequire.cjs");
|
|
37
37
|
var import_logger = require("./logger.cjs");
|
|
38
|
-
var import_plugin = require("./plugin.cjs");
|
|
39
38
|
var import_utils = require("./utils.cjs");
|
|
40
|
-
const { merge } = require("../compiled/webpack-merge/index.js");
|
|
41
39
|
async function loadConfig({
|
|
42
40
|
cliOptions,
|
|
43
|
-
|
|
41
|
+
command
|
|
44
42
|
}) {
|
|
43
|
+
if (command === "build") {
|
|
44
|
+
(0, import_utils.setNodeEnv)(cliOptions?.watch ? "development" : "production");
|
|
45
|
+
} else {
|
|
46
|
+
(0, import_utils.setNodeEnv)("development");
|
|
47
|
+
(0, import_utils.setDevServer)(true);
|
|
48
|
+
}
|
|
45
49
|
const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
|
|
46
50
|
let userConfig = {};
|
|
47
51
|
if (configPath) {
|
|
@@ -57,49 +61,13 @@ async function loadConfig({
|
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
const defaultConfig = {
|
|
68
|
-
bundler: "rspack",
|
|
69
|
-
root: process.cwd(),
|
|
70
|
-
build: {
|
|
71
|
-
outDir: "dist",
|
|
72
|
-
minify: (0, import_utils.isProd)(),
|
|
73
|
-
sourceMap: (0, import_utils.isProd)() ? false : "cheap-module-source-map",
|
|
74
|
-
parallel: true,
|
|
75
|
-
filenameHash: true,
|
|
76
|
-
cache: (0, import_utils.isDev)()
|
|
77
|
-
},
|
|
78
|
-
server: {
|
|
79
|
-
port: 3e3
|
|
80
|
-
},
|
|
81
|
-
html: {
|
|
82
|
-
mountId: "root"
|
|
83
|
-
},
|
|
84
|
-
css: {
|
|
85
|
-
modules: true,
|
|
86
|
-
transformer: "postcss",
|
|
87
|
-
sourceMap: false
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
let { plugins, bundlerConfig, ...rest } = merge(
|
|
91
|
-
configFromCli,
|
|
92
|
-
defaultConfig,
|
|
93
|
-
parsedUserConfig
|
|
94
|
-
);
|
|
95
|
-
for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("config", plugins)) {
|
|
96
|
-
rest = await plugin.config(rest, { mergeConfig: merge });
|
|
97
|
-
}
|
|
98
|
-
return {
|
|
99
|
-
...rest,
|
|
100
|
-
plugins,
|
|
101
|
-
bundlerConfig
|
|
102
|
-
};
|
|
64
|
+
if (cliOptions?.port)
|
|
65
|
+
(0, import_utils.setValueByPath)(userConfig, ["server", "port"], cliOptions.port);
|
|
66
|
+
if (cliOptions?.open)
|
|
67
|
+
(0, import_utils.setValueByPath)(userConfig, ["server", "open"], cliOptions.open);
|
|
68
|
+
if (cliOptions?.analyze)
|
|
69
|
+
(0, import_utils.setValueByPath)(userConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
|
|
70
|
+
return userConfig;
|
|
103
71
|
}
|
|
104
72
|
function defineConfig(config) {
|
|
105
73
|
return config;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CliOptions, Command, NodeEnv, UnpackConfig } from './types/index';
|
|
2
|
-
export declare function loadConfig({ cliOptions,
|
|
2
|
+
export declare function loadConfig({ cliOptions, command, }: {
|
|
3
3
|
cliOptions?: CliOptions;
|
|
4
|
-
|
|
4
|
+
command: Command;
|
|
5
5
|
}): Promise<UnpackConfig>;
|
|
6
6
|
export type ConfigParams = {
|
|
7
7
|
env: NodeEnv;
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAKjF,wBAAsB,UAAU,CAAC,EAC/B,UAAU,EACV,OAAO,GACR,EAAE;IACD,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC,YAAY,CAAC,CA2BxB;AAED,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,EAAE,OAAO,CAAA;IACZ,OAAO,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,OAAO,CAAC,YAAY,CAAC,CAAA;AACjF,MAAM,MAAM,kBAAkB,GAAG,CAAC,MAAM,EAAE,YAAY,KAAK,YAAY,CAAA;AACvE,MAAM,MAAM,kBAAkB,GAAG,YAAY,GAAG,kBAAkB,GAAG,mBAAmB,CAAA;AACxF,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,GAAG,YAAY,CAAA;AAChE,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA;AAC5E,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAAA;AAC9E,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,kBAAkB,CAAA"}
|
package/dist/config.js
CHANGED
|
@@ -9,15 +9,19 @@ var __dirname = /* @__PURE__ */ getDirname();
|
|
|
9
9
|
var __filename = /* @__PURE__ */ getFilename();
|
|
10
10
|
import fs from "node:fs";
|
|
11
11
|
import { isAbsolute, join } from "node:path";
|
|
12
|
-
const { merge } = require("../compiled/webpack-merge/index.js");
|
|
13
12
|
import { bundleRequire } from "./bundleRequire.js";
|
|
14
13
|
import { logger } from "./logger.js";
|
|
15
|
-
import {
|
|
16
|
-
import { getNodeEnv, isDev, isProd, setValueByPath } from "./utils.js";
|
|
14
|
+
import { getNodeEnv, setDevServer, setNodeEnv, setValueByPath } from "./utils.js";
|
|
17
15
|
async function loadConfig({
|
|
18
16
|
cliOptions,
|
|
19
|
-
|
|
17
|
+
command
|
|
20
18
|
}) {
|
|
19
|
+
if (command === "build") {
|
|
20
|
+
setNodeEnv(cliOptions?.watch ? "development" : "production");
|
|
21
|
+
} else {
|
|
22
|
+
setNodeEnv("development");
|
|
23
|
+
setDevServer(true);
|
|
24
|
+
}
|
|
21
25
|
const configPath = resolveConfigPath(process.cwd(), cliOptions?.config);
|
|
22
26
|
let userConfig = {};
|
|
23
27
|
if (configPath) {
|
|
@@ -33,49 +37,13 @@ async function loadConfig({
|
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const defaultConfig = {
|
|
44
|
-
bundler: "rspack",
|
|
45
|
-
root: process.cwd(),
|
|
46
|
-
build: {
|
|
47
|
-
outDir: "dist",
|
|
48
|
-
minify: isProd(),
|
|
49
|
-
sourceMap: isProd() ? false : "cheap-module-source-map",
|
|
50
|
-
parallel: true,
|
|
51
|
-
filenameHash: true,
|
|
52
|
-
cache: isDev()
|
|
53
|
-
},
|
|
54
|
-
server: {
|
|
55
|
-
port: 3e3
|
|
56
|
-
},
|
|
57
|
-
html: {
|
|
58
|
-
mountId: "root"
|
|
59
|
-
},
|
|
60
|
-
css: {
|
|
61
|
-
modules: true,
|
|
62
|
-
transformer: "postcss",
|
|
63
|
-
sourceMap: false
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
let { plugins, bundlerConfig, ...rest } = merge(
|
|
67
|
-
configFromCli,
|
|
68
|
-
defaultConfig,
|
|
69
|
-
parsedUserConfig
|
|
70
|
-
);
|
|
71
|
-
for (const plugin of getNormalizedPluginsByHook("config", plugins)) {
|
|
72
|
-
rest = await plugin.config(rest, { mergeConfig: merge });
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
...rest,
|
|
76
|
-
plugins,
|
|
77
|
-
bundlerConfig
|
|
78
|
-
};
|
|
40
|
+
if (cliOptions?.port)
|
|
41
|
+
setValueByPath(userConfig, ["server", "port"], cliOptions.port);
|
|
42
|
+
if (cliOptions?.open)
|
|
43
|
+
setValueByPath(userConfig, ["server", "open"], cliOptions.open);
|
|
44
|
+
if (cliOptions?.analyze)
|
|
45
|
+
setValueByPath(userConfig, ["performance", "bundleAnalyze"], cliOptions.analyze);
|
|
46
|
+
return userConfig;
|
|
79
47
|
}
|
|
80
48
|
function defineConfig(config) {
|
|
81
49
|
return config;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var createUnpack_exports = {};
|
|
29
|
+
__export(createUnpack_exports, {
|
|
30
|
+
createUnpack: () => createUnpack
|
|
31
|
+
});
|
|
32
|
+
module.exports = __toCommonJS(createUnpack_exports);
|
|
33
|
+
var import_colors = __toESM(require("./colors.cjs"));
|
|
34
|
+
var import_plugin = require("./plugin.cjs");
|
|
35
|
+
var import_run = require("./run/index.cjs");
|
|
36
|
+
var import_utils = require("./utils.cjs");
|
|
37
|
+
function createUnpack() {
|
|
38
|
+
const resolveConfig = async (unpackConfig) => {
|
|
39
|
+
const defaultConfig = {
|
|
40
|
+
bundler: "rspack",
|
|
41
|
+
root: process.cwd(),
|
|
42
|
+
build: {
|
|
43
|
+
outDir: "dist",
|
|
44
|
+
minify: (0, import_utils.isProd)(),
|
|
45
|
+
sourceMap: (0, import_utils.isProd)() ? false : "cheap-module-source-map",
|
|
46
|
+
parallel: true,
|
|
47
|
+
filenameHash: true,
|
|
48
|
+
cache: (0, import_utils.isDev)()
|
|
49
|
+
},
|
|
50
|
+
server: {
|
|
51
|
+
port: 3e3
|
|
52
|
+
},
|
|
53
|
+
html: {
|
|
54
|
+
mountId: "root"
|
|
55
|
+
},
|
|
56
|
+
css: {
|
|
57
|
+
modules: true,
|
|
58
|
+
transformer: "postcss",
|
|
59
|
+
sourceMap: false
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
let { plugins, bundlerConfig, ...rest } = (0, import_utils.mergeConfig)(defaultConfig, unpackConfig);
|
|
63
|
+
for (const plugin of (0, import_plugin.getNormalizedPluginsByHook)("config", plugins)) {
|
|
64
|
+
rest = await plugin.config(rest, { mergeConfig: import_utils.mergeConfig });
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
...rest,
|
|
68
|
+
plugins,
|
|
69
|
+
bundlerConfig
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
return {
|
|
73
|
+
build: async (unpackConfig) => {
|
|
74
|
+
(0, import_utils.setNodeEnv)("production");
|
|
75
|
+
console.log(
|
|
76
|
+
import_colors.default.rainbow(`unpack v${"1.6.1"}`),
|
|
77
|
+
import_colors.default.green("building for production...")
|
|
78
|
+
);
|
|
79
|
+
const config = await resolveConfig(unpackConfig);
|
|
80
|
+
(0, import_run.bundlerBuild)(config);
|
|
81
|
+
},
|
|
82
|
+
serve: async (unpackConfig) => {
|
|
83
|
+
(0, import_utils.setNodeEnv)("development");
|
|
84
|
+
(0, import_utils.setDevServer)(true);
|
|
85
|
+
const config = await resolveConfig(unpackConfig);
|
|
86
|
+
(0, import_run.bundlerDev)(config);
|
|
87
|
+
},
|
|
88
|
+
watch: async (unpackConfig) => {
|
|
89
|
+
(0, import_utils.setNodeEnv)("development");
|
|
90
|
+
console.log(
|
|
91
|
+
import_colors.default.rainbow(`unpack v${"1.6.1"}`),
|
|
92
|
+
import_colors.default.green("building for development...")
|
|
93
|
+
);
|
|
94
|
+
const config = await resolveConfig(unpackConfig);
|
|
95
|
+
(0, import_run.bundlerBuild)(config);
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
createUnpack
|
|
102
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { UnpackConfig } from './types/index';
|
|
2
|
+
export declare function createUnpack(): {
|
|
3
|
+
build: (unpackConfig: UnpackConfig) => Promise<void>;
|
|
4
|
+
serve: (unpackConfig: UnpackConfig) => Promise<void>;
|
|
5
|
+
watch: (unpackConfig: UnpackConfig) => Promise<void>;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=createUnpack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createUnpack.d.ts","sourceRoot":"","sources":["../src/createUnpack.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAGjD,wBAAgB,YAAY;0BAoCI,YAAY;0BASZ,YAAY;0BAMZ,YAAY;EAU3C"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
var require = createRequire(import.meta['url']);
|
|
3
|
+
|
|
4
|
+
import path from "path";
|
|
5
|
+
import { fileURLToPath } from "url";
|
|
6
|
+
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
+
var getDirname = () => path.dirname(getFilename());
|
|
8
|
+
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
+
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
+
import colors from "./colors.js";
|
|
11
|
+
import { getNormalizedPluginsByHook } from "./plugin.js";
|
|
12
|
+
import { bundlerBuild, bundlerDev } from "./run/index.js";
|
|
13
|
+
import { isDev, isProd, mergeConfig, setDevServer, setNodeEnv } from "./utils.js";
|
|
14
|
+
function createUnpack() {
|
|
15
|
+
const resolveConfig = async (unpackConfig) => {
|
|
16
|
+
const defaultConfig = {
|
|
17
|
+
bundler: "rspack",
|
|
18
|
+
root: process.cwd(),
|
|
19
|
+
build: {
|
|
20
|
+
outDir: "dist",
|
|
21
|
+
minify: isProd(),
|
|
22
|
+
sourceMap: isProd() ? false : "cheap-module-source-map",
|
|
23
|
+
parallel: true,
|
|
24
|
+
filenameHash: true,
|
|
25
|
+
cache: isDev()
|
|
26
|
+
},
|
|
27
|
+
server: {
|
|
28
|
+
port: 3e3
|
|
29
|
+
},
|
|
30
|
+
html: {
|
|
31
|
+
mountId: "root"
|
|
32
|
+
},
|
|
33
|
+
css: {
|
|
34
|
+
modules: true,
|
|
35
|
+
transformer: "postcss",
|
|
36
|
+
sourceMap: false
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
let { plugins, bundlerConfig, ...rest } = mergeConfig(defaultConfig, unpackConfig);
|
|
40
|
+
for (const plugin of getNormalizedPluginsByHook("config", plugins)) {
|
|
41
|
+
rest = await plugin.config(rest, { mergeConfig });
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
...rest,
|
|
45
|
+
plugins,
|
|
46
|
+
bundlerConfig
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
return {
|
|
50
|
+
build: async (unpackConfig) => {
|
|
51
|
+
setNodeEnv("production");
|
|
52
|
+
console.log(
|
|
53
|
+
colors.rainbow(`unpack v${"1.6.1"}`),
|
|
54
|
+
colors.green("building for production...")
|
|
55
|
+
);
|
|
56
|
+
const config = await resolveConfig(unpackConfig);
|
|
57
|
+
bundlerBuild(config);
|
|
58
|
+
},
|
|
59
|
+
serve: async (unpackConfig) => {
|
|
60
|
+
setNodeEnv("development");
|
|
61
|
+
setDevServer(true);
|
|
62
|
+
const config = await resolveConfig(unpackConfig);
|
|
63
|
+
bundlerDev(config);
|
|
64
|
+
},
|
|
65
|
+
watch: async (unpackConfig) => {
|
|
66
|
+
setNodeEnv("development");
|
|
67
|
+
console.log(
|
|
68
|
+
colors.rainbow(`unpack v${"1.6.1"}`),
|
|
69
|
+
colors.green("building for development...")
|
|
70
|
+
);
|
|
71
|
+
const config = await resolveConfig(unpackConfig);
|
|
72
|
+
bundlerBuild(config);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export {
|
|
77
|
+
createUnpack
|
|
78
|
+
};
|
package/dist/index.cjs
CHANGED
|
@@ -28,24 +28,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var src_exports = {};
|
|
30
30
|
__export(src_exports, {
|
|
31
|
-
colors: () => import_colors.default
|
|
32
|
-
defineConfig: () => import_config.defineConfig
|
|
31
|
+
colors: () => import_colors.default
|
|
33
32
|
});
|
|
34
33
|
module.exports = __toCommonJS(src_exports);
|
|
35
|
-
var import_config = require("./config.cjs");
|
|
36
34
|
__reExport(src_exports, require("./logger.cjs"), module.exports);
|
|
37
35
|
__reExport(src_exports, require("./types/index.cjs"), module.exports);
|
|
38
36
|
__reExport(src_exports, require("./utils.cjs"), module.exports);
|
|
39
37
|
__reExport(src_exports, require("./constants.cjs"), module.exports);
|
|
40
|
-
__reExport(src_exports, require("./
|
|
38
|
+
__reExport(src_exports, require("./createUnpack.cjs"), module.exports);
|
|
39
|
+
__reExport(src_exports, require("./config.cjs"), module.exports);
|
|
41
40
|
var import_colors = __toESM(require("./colors.cjs"));
|
|
42
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
42
|
0 && (module.exports = {
|
|
44
43
|
colors,
|
|
45
|
-
defineConfig,
|
|
46
44
|
...require("./logger.cjs"),
|
|
47
45
|
...require("./types/index.cjs"),
|
|
48
46
|
...require("./utils.cjs"),
|
|
49
47
|
...require("./constants.cjs"),
|
|
50
|
-
...require("./
|
|
48
|
+
...require("./createUnpack.cjs"),
|
|
49
|
+
...require("./config.cjs")
|
|
51
50
|
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { defineConfig } from './config';
|
|
2
1
|
export * from './logger';
|
|
3
2
|
export * from './types/index';
|
|
4
3
|
export * from './utils';
|
|
5
4
|
export * from './constants';
|
|
6
|
-
export * from './
|
|
5
|
+
export * from './createUnpack';
|
|
6
|
+
export * from './config';
|
|
7
7
|
export { default as colors } from './colors';
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,eAAe,CAAA;AAC7B,cAAc,SAAS,CAAA;AACvB,cAAc,aAAa,CAAA;AAC3B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,UAAU,CAAA;AACxB,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -7,14 +7,13 @@ var getFilename = () => fileURLToPath(import.meta.url);
|
|
|
7
7
|
var getDirname = () => path.dirname(getFilename());
|
|
8
8
|
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
9
|
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
-
import { defineConfig } from "./config.js";
|
|
11
10
|
export * from "./logger.js";
|
|
12
11
|
export * from "./types/index.js";
|
|
13
12
|
export * from "./utils.js";
|
|
14
13
|
export * from "./constants.js";
|
|
15
|
-
export * from "./
|
|
14
|
+
export * from "./createUnpack.js";
|
|
15
|
+
export * from "./config.js";
|
|
16
16
|
import { default as default2 } from "./colors.js";
|
|
17
17
|
export {
|
|
18
|
-
default2 as colors
|
|
19
|
-
defineConfig
|
|
18
|
+
default2 as colors
|
|
20
19
|
};
|
|
@@ -58,7 +58,7 @@ class RspackPluginProgress extends import_core.rspack.ProgressPlugin {
|
|
|
58
58
|
this.startTime = void 0;
|
|
59
59
|
if (!stats.hasErrors()) {
|
|
60
60
|
if ((0, import_utils.isProd)()) {
|
|
61
|
-
await (0, import_reporter.printFileSize)({ stats });
|
|
61
|
+
await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
|
|
62
62
|
console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
|
|
63
63
|
} else {
|
|
64
64
|
import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
|
|
@@ -35,7 +35,7 @@ class RspackPluginProgress extends rspack.ProgressPlugin {
|
|
|
35
35
|
this.startTime = void 0;
|
|
36
36
|
if (!stats.hasErrors()) {
|
|
37
37
|
if (isProd()) {
|
|
38
|
-
await printFileSize({ stats });
|
|
38
|
+
await printFileSize({ root: compiler.options.context, stats });
|
|
39
39
|
console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
|
|
40
40
|
} else {
|
|
41
41
|
logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
|
|
@@ -68,7 +68,7 @@ class WebpackPluginProgress extends import_webpack.default.ProgressPlugin {
|
|
|
68
68
|
this.startTime = void 0;
|
|
69
69
|
if (!stats.hasErrors()) {
|
|
70
70
|
if ((0, import_utils.isProd)()) {
|
|
71
|
-
await (0, import_reporter.printFileSize)({ stats });
|
|
71
|
+
await (0, import_reporter.printFileSize)({ root: compiler.options.context, stats });
|
|
72
72
|
console.log(import_colors.default.green(`✓ built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`));
|
|
73
73
|
} else {
|
|
74
74
|
import_logger.logger.ready(`built in ${import_colors.default.bold((0, import_utils.prettyTime)(compileTime))}`);
|
|
@@ -45,7 +45,7 @@ class WebpackPluginProgress extends webpack.ProgressPlugin {
|
|
|
45
45
|
this.startTime = void 0;
|
|
46
46
|
if (!stats.hasErrors()) {
|
|
47
47
|
if (isProd()) {
|
|
48
|
-
await printFileSize({ stats });
|
|
48
|
+
await printFileSize({ root: compiler.options.context, stats });
|
|
49
49
|
console.log(colors.green(`✓ built in ${colors.bold(prettyTime(compileTime))}`));
|
|
50
50
|
} else {
|
|
51
51
|
logger.ready(`built in ${colors.bold(prettyTime(compileTime))}`);
|
package/dist/reporter.cjs
CHANGED
|
@@ -60,9 +60,9 @@ async function getCompressedSize(content) {
|
|
|
60
60
|
const data = await gzip(content);
|
|
61
61
|
return data.length;
|
|
62
62
|
}
|
|
63
|
-
async function printFileSize({ stats }) {
|
|
63
|
+
async function printFileSize({ root, stats }) {
|
|
64
64
|
const distPath = stats.compilation.outputOptions.path;
|
|
65
|
-
const distFolder = import_node_path.default.relative(
|
|
65
|
+
const distFolder = import_node_path.default.relative(root, distPath);
|
|
66
66
|
const origin = stats.toJson({
|
|
67
67
|
all: false,
|
|
68
68
|
assets: true,
|
package/dist/reporter.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { Stats as RspackStats } from '@rspack/core';
|
|
2
2
|
import type { Stats as WebpackStats } from 'webpack';
|
|
3
3
|
type Options = {
|
|
4
|
+
root: string;
|
|
4
5
|
stats: WebpackStats | RspackStats;
|
|
5
6
|
};
|
|
6
|
-
export declare function printFileSize({ stats }: Options): Promise<void>;
|
|
7
|
+
export declare function printFileSize({ root, stats }: Options): Promise<void>;
|
|
7
8
|
export {};
|
|
8
9
|
//# sourceMappingURL=reporter.d.ts.map
|
package/dist/reporter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AAGpD,KAAK,OAAO,GAAG;IACb,KAAK,EAAE,YAAY,GAAG,WAAW,CAAA;CAClC,CAAA;AAsCD,wBAAsB,aAAa,CAAC,EAAE,KAAK,EAAE,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"reporter.d.ts","sourceRoot":"","sources":["../src/reporter.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,KAAK,IAAI,WAAW,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,KAAK,EAAE,KAAK,IAAI,YAAY,EAAE,MAAM,SAAS,CAAA;AAGpD,KAAK,OAAO,GAAG;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,YAAY,GAAG,WAAW,CAAA;CAClC,CAAA;AAsCD,wBAAsB,aAAa,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,OAAO,iBAsE3D"}
|
package/dist/reporter.js
CHANGED
|
@@ -37,9 +37,9 @@ async function getCompressedSize(content) {
|
|
|
37
37
|
const data = await gzip(content);
|
|
38
38
|
return data.length;
|
|
39
39
|
}
|
|
40
|
-
async function printFileSize({ stats }) {
|
|
40
|
+
async function printFileSize({ root, stats }) {
|
|
41
41
|
const distPath = stats.compilation.outputOptions.path;
|
|
42
|
-
const distFolder = path2.relative(
|
|
42
|
+
const distFolder = path2.relative(root, distPath);
|
|
43
43
|
const origin = stats.toJson({
|
|
44
44
|
all: false,
|
|
45
45
|
assets: true,
|
package/dist/run/dev.cjs
CHANGED
|
@@ -55,7 +55,7 @@ async function bundlerDev(unpackConfig) {
|
|
|
55
55
|
const server = new import_webpack_dev_server.default(devServerOptions, compiler);
|
|
56
56
|
await server.start();
|
|
57
57
|
import_logger.logger.greet(
|
|
58
|
-
` ${import_colors.default.green(`${import_colors.default.bold("UNPACK")} v${"1.6.
|
|
58
|
+
` ${import_colors.default.green(`${import_colors.default.bold("UNPACK")} v${"1.6.1"}`)} ${import_colors.default.dim(
|
|
59
59
|
`ready in ${import_colors.default.reset(
|
|
60
60
|
import_colors.default.bold(Math.ceil(performance.now() - global.__unpack_start_time))
|
|
61
61
|
)} ms`
|
package/dist/run/dev.js
CHANGED
|
@@ -32,7 +32,7 @@ async function bundlerDev(unpackConfig) {
|
|
|
32
32
|
const server = new WebpackDevServer(devServerOptions, compiler);
|
|
33
33
|
await server.start();
|
|
34
34
|
logger.greet(
|
|
35
|
-
` ${colors.green(`${colors.bold("UNPACK")} v${"1.6.
|
|
35
|
+
` ${colors.green(`${colors.bold("UNPACK")} v${"1.6.1"}`)} ${colors.dim(
|
|
36
36
|
`ready in ${colors.reset(
|
|
37
37
|
colors.bold(Math.ceil(performance.now() - global.__unpack_start_time))
|
|
38
38
|
)} ms`
|
|
@@ -12,7 +12,7 @@ import path from "path";
|
|
|
12
12
|
import { fileURLToPath } from "url";
|
|
13
13
|
var getFilename, getDirname, __dirname, __filename;
|
|
14
14
|
var init_esm = __esm({
|
|
15
|
-
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.
|
|
15
|
+
"../../node_modules/.pnpm/@modern-js+module-tools@2.60.5_typescript@5.5.4/node_modules/@modern-js/module-tools/shims/esm.js"() {
|
|
16
16
|
getFilename = () => fileURLToPath(import.meta.url);
|
|
17
17
|
getDirname = () => path.dirname(getFilename());
|
|
18
18
|
__dirname = /* @__PURE__ */ getDirname();
|
package/dist/utils.cjs
CHANGED
|
@@ -31,10 +31,10 @@ __export(utils_exports, {
|
|
|
31
31
|
getAddressUrls: () => getAddressUrls,
|
|
32
32
|
getCompiledPkgPath: () => getCompiledPkgPath,
|
|
33
33
|
getNodeEnv: () => getNodeEnv,
|
|
34
|
+
getPathInJs: () => getPathInJs,
|
|
34
35
|
getPort: () => getPort,
|
|
35
36
|
getTime: () => getTime,
|
|
36
37
|
getUserDepPath: () => getUserDepPath,
|
|
37
|
-
getValidPath: () => getValidPath,
|
|
38
38
|
getValueByPath: () => getValueByPath,
|
|
39
39
|
isBoolean: () => isBoolean,
|
|
40
40
|
isDev: () => isDev,
|
|
@@ -45,10 +45,10 @@ __export(utils_exports, {
|
|
|
45
45
|
isProd: () => isProd,
|
|
46
46
|
isRegExp: () => isRegExp,
|
|
47
47
|
isString: () => isString,
|
|
48
|
-
isTs: () => isTs,
|
|
49
48
|
isUndefined: () => isUndefined,
|
|
50
49
|
isWatch: () => isWatch,
|
|
51
50
|
isWin: () => isWin,
|
|
51
|
+
mergeConfig: () => mergeConfig,
|
|
52
52
|
prettyTime: () => prettyTime,
|
|
53
53
|
setDevServer: () => setDevServer,
|
|
54
54
|
setNodeEnv: () => setNodeEnv,
|
|
@@ -58,7 +58,6 @@ __export(utils_exports, {
|
|
|
58
58
|
});
|
|
59
59
|
module.exports = __toCommonJS(utils_exports);
|
|
60
60
|
var import_colors = __toESM(require("./colors.cjs"));
|
|
61
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
62
61
|
var import_node_net = __toESM(require("node:net"));
|
|
63
62
|
var import_node_os = __toESM(require("node:os"));
|
|
64
63
|
var import_node_path = __toESM(require("node:path"));
|
|
@@ -66,6 +65,7 @@ var import_constants = require("./constants.cjs");
|
|
|
66
65
|
var import_logger = require("./logger.cjs");
|
|
67
66
|
const glob = require("../compiled/fast-glob/index.js");
|
|
68
67
|
const portfinder = require("../compiled/portfinder/index.js");
|
|
68
|
+
const { merge } = require("../compiled/webpack-merge/index.js");
|
|
69
69
|
const getNodeEnv = () => process.env.NODE_ENV;
|
|
70
70
|
const setNodeEnv = (env) => {
|
|
71
71
|
process.env.NODE_ENV = env;
|
|
@@ -167,17 +167,6 @@ const debounce = (fn, delay) => {
|
|
|
167
167
|
}, delay);
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
|
-
const getValidPath = (filePath) => {
|
|
171
|
-
const absPath = import_node_path.default.isAbsolute(filePath) ? filePath : import_node_path.default.resolve(process.cwd(), filePath);
|
|
172
|
-
if (import_node_fs.default.existsSync(absPath)) {
|
|
173
|
-
return absPath;
|
|
174
|
-
}
|
|
175
|
-
return void 0;
|
|
176
|
-
};
|
|
177
|
-
const isTs = () => {
|
|
178
|
-
const tsconfigPath = import_node_path.default.resolve(process.cwd(), "tsconfig.json");
|
|
179
|
-
return import_node_fs.default.existsSync(tsconfigPath);
|
|
180
|
-
};
|
|
181
170
|
const getIpv4Interfaces = () => {
|
|
182
171
|
const interfaces = import_node_os.default.networkInterfaces();
|
|
183
172
|
const ipv4Interfaces = /* @__PURE__ */ new Map();
|
|
@@ -260,16 +249,20 @@ const trackPerformance = (msg) => {
|
|
|
260
249
|
}
|
|
261
250
|
global[k] = performance.now();
|
|
262
251
|
};
|
|
252
|
+
const getPathInJs = (absPath) => {
|
|
253
|
+
return JSON.stringify(absPath).slice(1, -1);
|
|
254
|
+
};
|
|
255
|
+
const mergeConfig = merge;
|
|
263
256
|
// Annotate the CommonJS export names for ESM import in node:
|
|
264
257
|
0 && (module.exports = {
|
|
265
258
|
debounce,
|
|
266
259
|
getAddressUrls,
|
|
267
260
|
getCompiledPkgPath,
|
|
268
261
|
getNodeEnv,
|
|
262
|
+
getPathInJs,
|
|
269
263
|
getPort,
|
|
270
264
|
getTime,
|
|
271
265
|
getUserDepPath,
|
|
272
|
-
getValidPath,
|
|
273
266
|
getValueByPath,
|
|
274
267
|
isBoolean,
|
|
275
268
|
isDev,
|
|
@@ -280,10 +273,10 @@ const trackPerformance = (msg) => {
|
|
|
280
273
|
isProd,
|
|
281
274
|
isRegExp,
|
|
282
275
|
isString,
|
|
283
|
-
isTs,
|
|
284
276
|
isUndefined,
|
|
285
277
|
isWatch,
|
|
286
278
|
isWin,
|
|
279
|
+
mergeConfig,
|
|
287
280
|
prettyTime,
|
|
288
281
|
setDevServer,
|
|
289
282
|
setNodeEnv,
|
package/dist/utils.d.ts
CHANGED
|
@@ -23,8 +23,6 @@ export declare const getUserDepPath: (root: string, deps: string | string[]) =>
|
|
|
23
23
|
export declare const uniqueId: (length: number) => string;
|
|
24
24
|
export declare function getTime(): string;
|
|
25
25
|
export declare const debounce: (fn: any, delay: any) => (...args: any[]) => void;
|
|
26
|
-
export declare const getValidPath: (filePath: string) => string;
|
|
27
|
-
export declare const isTs: () => boolean;
|
|
28
26
|
type AddressUrl = {
|
|
29
27
|
label: string;
|
|
30
28
|
url: string;
|
|
@@ -35,5 +33,11 @@ export declare const getAddressUrls: ({ protocol, port, host, }: {
|
|
|
35
33
|
host?: string;
|
|
36
34
|
}) => AddressUrl[];
|
|
37
35
|
export declare const trackPerformance: (msg?: string) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Fix path on windows
|
|
38
|
+
* C:\Users\Desktop\project\src\index.js -> C:\\Users\\Desktop\\project\\src\\index.js
|
|
39
|
+
*/
|
|
40
|
+
export declare const getPathInJs: (absPath: string) => string;
|
|
41
|
+
export declare const mergeConfig: any;
|
|
38
42
|
export {};
|
|
39
43
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAG7D,eAAO,MAAM,UAAU,QAAiC,OAAO,CAAA;AAE/D,eAAO,MAAM,UAAU,QAAS,OAAO,SAEtC,CAAA;AAED,eAAO,MAAM,YAAY,gBAAiB,OAAO,SAEhD,CAAA;AAED,eAAO,MAAM,KAAK,QAAO,OAAyC,CAAA;AAElE,eAAO,MAAM,WAAW,QAAO,OAA4C,CAAA;AAE3E,eAAO,MAAM,OAAO,QAAO,OAAoC,CAAA;AAE/D,eAAO,MAAM,MAAM,QAAO,OAAwC,CAAA;AAElE,eAAO,MAAM,KAAK,QAAO,OAAuC,CAAA;AAEhE,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAiC,CAAA;AAEhF,eAAO,MAAM,SAAS,SAAU,OAAO,KAAG,IAAI,IAAI,OAAoC,CAAA;AAEtF,eAAO,MAAM,WAAW,QAAS,OAAO,KAAG,GAAG,IAAI,SAAuC,CAAA;AAEzF,eAAO,MAAM,UAAU,SAAU,OAAO,KAAG,IAAI,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAC3C,CAAA;AAE5B,eAAO,MAAM,QAAQ,QAAS,OAAO,KAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CACxB,CAAA;AAEzC,eAAO,MAAM,aAAa,QAAS,OAAO,KAAG,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CACM,CAAA;AAE5E,eAAO,MAAM,QAAQ,QAAS,GAAG,KAAG,GAAG,IAAI,MACgB,CAAA;AAE3D,eAAO,MAAM,UAAU,YAAa,MAAM,WAYzC,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,gBAAgB,GAAG,QAc5F,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,aAAa,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,SAAS,GAAG,SAUrF,CAAA;AAED,eAAO,MAAM,OAAO,cAAe,MAAM,KAAG,OAAO,CAAC,MAAM,CAWzD,CAAA;AAED,eAAO,MAAM,kBAAkB,gBAAiB,eAAe,WACb,CAAA;AAElD,eAAO,MAAM,cAAc,SAAU,MAAM,QAAQ,MAAM,GAAG,MAAM,EAAE,KAAG,MAAM,GAAG,SAQ/E,CAAA;AAED,eAAO,MAAM,QAAQ,WAAY,MAAM,WAItC,CAAA;AAED,wBAAgB,OAAO,WAMtB;AAED,eAAO,MAAM,QAAQ,mDAQpB,CAAA;AA6CD,KAAK,UAAU,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhD,eAAO,MAAM,cAAc,8BAIxB;IACD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAA;CACd,KAAG,UAAU,EAuCb,CAAA;AAED,eAAO,MAAM,gBAAgB,SAAU,MAAM,SAY5C,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,WAAW,YAAa,MAAM,WAE1C,CAAA;AAED,eAAO,MAAM,WAAW,KAAQ,CAAA"}
|
package/dist/utils.js
CHANGED
|
@@ -10,12 +10,12 @@ var __filename = /* @__PURE__ */ getFilename();
|
|
|
10
10
|
const glob = require("../compiled/fast-glob/index.js");
|
|
11
11
|
import colors from "./colors.js";
|
|
12
12
|
const portfinder = require("../compiled/portfinder/index.js");
|
|
13
|
-
import fs from "node:fs";
|
|
14
13
|
import net from "node:net";
|
|
15
14
|
import os from "node:os";
|
|
16
15
|
import path2 from "node:path";
|
|
17
16
|
import { DEFAULT_DEV_HOST } from "./constants.js";
|
|
18
17
|
import { logger } from "./logger.js";
|
|
18
|
+
const { merge } = require("../compiled/webpack-merge/index.js");
|
|
19
19
|
const getNodeEnv = () => process.env.NODE_ENV;
|
|
20
20
|
const setNodeEnv = (env) => {
|
|
21
21
|
process.env.NODE_ENV = env;
|
|
@@ -117,17 +117,6 @@ const debounce = (fn, delay) => {
|
|
|
117
117
|
}, delay);
|
|
118
118
|
};
|
|
119
119
|
};
|
|
120
|
-
const getValidPath = (filePath) => {
|
|
121
|
-
const absPath = path2.isAbsolute(filePath) ? filePath : path2.resolve(process.cwd(), filePath);
|
|
122
|
-
if (fs.existsSync(absPath)) {
|
|
123
|
-
return absPath;
|
|
124
|
-
}
|
|
125
|
-
return void 0;
|
|
126
|
-
};
|
|
127
|
-
const isTs = () => {
|
|
128
|
-
const tsconfigPath = path2.resolve(process.cwd(), "tsconfig.json");
|
|
129
|
-
return fs.existsSync(tsconfigPath);
|
|
130
|
-
};
|
|
131
120
|
const getIpv4Interfaces = () => {
|
|
132
121
|
const interfaces = os.networkInterfaces();
|
|
133
122
|
const ipv4Interfaces = /* @__PURE__ */ new Map();
|
|
@@ -210,15 +199,19 @@ const trackPerformance = (msg) => {
|
|
|
210
199
|
}
|
|
211
200
|
global[k] = performance.now();
|
|
212
201
|
};
|
|
202
|
+
const getPathInJs = (absPath) => {
|
|
203
|
+
return JSON.stringify(absPath).slice(1, -1);
|
|
204
|
+
};
|
|
205
|
+
const mergeConfig = merge;
|
|
213
206
|
export {
|
|
214
207
|
debounce,
|
|
215
208
|
getAddressUrls,
|
|
216
209
|
getCompiledPkgPath,
|
|
217
210
|
getNodeEnv,
|
|
211
|
+
getPathInJs,
|
|
218
212
|
getPort,
|
|
219
213
|
getTime,
|
|
220
214
|
getUserDepPath,
|
|
221
|
-
getValidPath,
|
|
222
215
|
getValueByPath,
|
|
223
216
|
isBoolean,
|
|
224
217
|
isDev,
|
|
@@ -229,10 +222,10 @@ export {
|
|
|
229
222
|
isProd,
|
|
230
223
|
isRegExp,
|
|
231
224
|
isString,
|
|
232
|
-
isTs,
|
|
233
225
|
isUndefined,
|
|
234
226
|
isWatch,
|
|
235
227
|
isWin,
|
|
228
|
+
mergeConfig,
|
|
236
229
|
prettyTime,
|
|
237
230
|
setDevServer,
|
|
238
231
|
setNodeEnv,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unpackjs/core",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"esbuild": "0.24.0",
|
|
105
105
|
"esbuild-loader": "4.2.2",
|
|
106
106
|
"fork-ts-checker-webpack-plugin": "9.0.2",
|
|
107
|
-
"html-webpack-plugin": "5.6.
|
|
107
|
+
"html-webpack-plugin": "5.6.3",
|
|
108
108
|
"json5": "2.2.3",
|
|
109
109
|
"lightningcss": "1.27.0",
|
|
110
110
|
"loader-runner": "4.3.0",
|
package/dist/createService.cjs
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __create = Object.create;
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
-
mod
|
|
26
|
-
));
|
|
27
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
-
var createService_exports = {};
|
|
29
|
-
__export(createService_exports, {
|
|
30
|
-
createService: () => createService
|
|
31
|
-
});
|
|
32
|
-
module.exports = __toCommonJS(createService_exports);
|
|
33
|
-
var import_colors = __toESM(require("./colors.cjs"));
|
|
34
|
-
var import_config = require("./config.cjs");
|
|
35
|
-
var import_run = require("./run/index.cjs");
|
|
36
|
-
var import_utils = require("./utils.cjs");
|
|
37
|
-
async function createService({ command, cliOptions, defaultConfig }) {
|
|
38
|
-
if (command === "build") {
|
|
39
|
-
(0, import_utils.setNodeEnv)(cliOptions.watch ? "development" : "production");
|
|
40
|
-
(0, import_utils.setDevServer)(false);
|
|
41
|
-
} else {
|
|
42
|
-
(0, import_utils.setNodeEnv)("development");
|
|
43
|
-
(0, import_utils.setDevServer)(true);
|
|
44
|
-
}
|
|
45
|
-
if (!(0, import_utils.isDevServer)()) {
|
|
46
|
-
console.log(
|
|
47
|
-
import_colors.default.rainbow(`unpack v${"1.6.0"}`),
|
|
48
|
-
import_colors.default.green(`building for ${(0, import_utils.isDev)() ? "development" : "production"}...`)
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
const unpackConfig = await (0, import_config.loadConfig)({ cliOptions, defaultConfig });
|
|
52
|
-
const commandMap = {
|
|
53
|
-
build: () => {
|
|
54
|
-
(0, import_run.bundlerBuild)(unpackConfig);
|
|
55
|
-
},
|
|
56
|
-
dev: () => {
|
|
57
|
-
(0, import_run.bundlerDev)(unpackConfig);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
commandMap[command]();
|
|
61
|
-
}
|
|
62
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
63
|
-
0 && (module.exports = {
|
|
64
|
-
createService
|
|
65
|
-
});
|
package/dist/createService.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { CliOptions, Command, UnpackConfig } from './types/index';
|
|
2
|
-
export type CreateServiceOptions = {
|
|
3
|
-
command: Command;
|
|
4
|
-
cliOptions?: CliOptions;
|
|
5
|
-
defaultConfig?: UnpackConfig;
|
|
6
|
-
};
|
|
7
|
-
export declare function createService({ command, cliOptions, defaultConfig }: CreateServiceOptions): Promise<void>;
|
|
8
|
-
//# sourceMappingURL=createService.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createService.d.ts","sourceRoot":"","sources":["../src/createService.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAMxE,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB,aAAa,CAAC,EAAE,YAAY,CAAA;CAC7B,CAAA;AACD,wBAAsB,aAAa,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,EAAE,oBAAoB,iBA0B/F"}
|
package/dist/createService.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'node:module';
|
|
2
|
-
var require = createRequire(import.meta['url']);
|
|
3
|
-
|
|
4
|
-
import path from "path";
|
|
5
|
-
import { fileURLToPath } from "url";
|
|
6
|
-
var getFilename = () => fileURLToPath(import.meta.url);
|
|
7
|
-
var getDirname = () => path.dirname(getFilename());
|
|
8
|
-
var __dirname = /* @__PURE__ */ getDirname();
|
|
9
|
-
var __filename = /* @__PURE__ */ getFilename();
|
|
10
|
-
import colors from "./colors.js";
|
|
11
|
-
import { loadConfig } from "./config.js";
|
|
12
|
-
import { bundlerBuild, bundlerDev } from "./run/index.js";
|
|
13
|
-
import { isDev, isDevServer, setDevServer, setNodeEnv } from "./utils.js";
|
|
14
|
-
async function createService({ command, cliOptions, defaultConfig }) {
|
|
15
|
-
if (command === "build") {
|
|
16
|
-
setNodeEnv(cliOptions.watch ? "development" : "production");
|
|
17
|
-
setDevServer(false);
|
|
18
|
-
} else {
|
|
19
|
-
setNodeEnv("development");
|
|
20
|
-
setDevServer(true);
|
|
21
|
-
}
|
|
22
|
-
if (!isDevServer()) {
|
|
23
|
-
console.log(
|
|
24
|
-
colors.rainbow(`unpack v${"1.6.0"}`),
|
|
25
|
-
colors.green(`building for ${isDev() ? "development" : "production"}...`)
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
const unpackConfig = await loadConfig({ cliOptions, defaultConfig });
|
|
29
|
-
const commandMap = {
|
|
30
|
-
build: () => {
|
|
31
|
-
bundlerBuild(unpackConfig);
|
|
32
|
-
},
|
|
33
|
-
dev: () => {
|
|
34
|
-
bundlerDev(unpackConfig);
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
commandMap[command]();
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
createService
|
|
41
|
-
};
|