path-serializer 0.0.2 → 0.0.4
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/cjs/main.cjs +10 -31
- package/dist/esm/main.js +32 -42
- package/dist/rsbuild.config.cjs.mjs +333 -0
- package/dist/rsbuild.config.esm.mjs +339 -0
- package/dist/rspack.config.cjs.mjs +420 -0
- package/dist/rspack.config.esm.mjs +422 -0
- package/package.json +1 -1
package/dist/cjs/main.cjs
CHANGED
|
@@ -269,9 +269,6 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
269
269
|
createSnapshotSerializer: () => (/* reexport */ createSnapshotSerializer)
|
|
270
270
|
});
|
|
271
271
|
|
|
272
|
-
;// CONCATENATED MODULE: external "node:os"
|
|
273
|
-
var external_node_os_namespaceObject = require("node:os");
|
|
274
|
-
var external_node_os_default = /*#__PURE__*/__webpack_require__.n(external_node_os_namespaceObject);
|
|
275
272
|
;// CONCATENATED MODULE: ./node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayReduce.js
|
|
276
273
|
/**
|
|
277
274
|
* A specialized version of `_.reduce` for arrays without support for
|
|
@@ -946,6 +943,9 @@ var snakeCase_snakeCase = _createCompounder(function(result, word, index) {
|
|
|
946
943
|
;// CONCATENATED MODULE: external "node:fs"
|
|
947
944
|
var external_node_fs_namespaceObject = require("node:fs");
|
|
948
945
|
var external_node_fs_default = /*#__PURE__*/__webpack_require__.n(external_node_fs_namespaceObject);
|
|
946
|
+
;// CONCATENATED MODULE: external "node:os"
|
|
947
|
+
var external_node_os_namespaceObject = require("node:os");
|
|
948
|
+
var external_node_os_default = /*#__PURE__*/__webpack_require__.n(external_node_os_namespaceObject);
|
|
949
949
|
;// CONCATENATED MODULE: external "node:path"
|
|
950
950
|
var external_node_path_namespaceObject = require("node:path");
|
|
951
951
|
var external_node_path_default = /*#__PURE__*/__webpack_require__.n(external_node_path_namespaceObject);
|
|
@@ -993,7 +993,7 @@ var upath_default = /*#__PURE__*/__webpack_require__.n(upath);
|
|
|
993
993
|
|
|
994
994
|
|
|
995
995
|
const isPathString = (test)=>external_node_path_default().posix.basename(test) !== test || external_node_path_default().win32.basename(test) !== test;
|
|
996
|
-
function
|
|
996
|
+
function getRealTemporaryDirectory() {
|
|
997
997
|
let ret = null;
|
|
998
998
|
try {
|
|
999
999
|
ret = external_node_os_default().tmpdir();
|
|
@@ -1001,7 +1001,9 @@ function utils_getRealTemporaryDirectory() {
|
|
|
1001
1001
|
} catch {}
|
|
1002
1002
|
return ret;
|
|
1003
1003
|
}
|
|
1004
|
-
const normalizeToPosixPath = (p)=>
|
|
1004
|
+
const normalizeToPosixPath = (p)=>{
|
|
1005
|
+
return upath_default().normalizeSafe(external_node_path_default().normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
|
|
1006
|
+
};
|
|
1005
1007
|
/**
|
|
1006
1008
|
* Compile path string to RegExp.
|
|
1007
1009
|
* @note Only support posix path.
|
|
@@ -1019,7 +1021,6 @@ function splitPathString(str) {
|
|
|
1019
1021
|
;// CONCATENATED MODULE: ./src/applyMatcherReplacement.ts
|
|
1020
1022
|
|
|
1021
1023
|
|
|
1022
|
-
|
|
1023
1024
|
function applyPathMatcher(matcher, str, options = {}) {
|
|
1024
1025
|
const regex = compilePathMatcherRegExp(matcher.match);
|
|
1025
1026
|
const replacer = (substring, ...args)=>{
|
|
@@ -1036,40 +1037,18 @@ function applyMatcherReplacement(matchers, str, options = {}) {
|
|
|
1036
1037
|
return applyPathMatcher(matcher, ret, options);
|
|
1037
1038
|
}, str);
|
|
1038
1039
|
}
|
|
1039
|
-
const createDefaultPathMatchers = ()=>{
|
|
1040
|
-
const ret = [
|
|
1041
|
-
{
|
|
1042
|
-
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
|
|
1043
|
-
mark: 'pnpmInner'
|
|
1044
|
-
}
|
|
1045
|
-
];
|
|
1046
|
-
const tmpdir = getRealTemporaryDirectory();
|
|
1047
|
-
tmpdir && ret.push({
|
|
1048
|
-
match: tmpdir,
|
|
1049
|
-
mark: 'temp'
|
|
1050
|
-
});
|
|
1051
|
-
ret.push({
|
|
1052
|
-
match: os.tmpdir(),
|
|
1053
|
-
mark: 'temp'
|
|
1054
|
-
});
|
|
1055
|
-
ret.push({
|
|
1056
|
-
match: os.homedir(),
|
|
1057
|
-
mark: 'home'
|
|
1058
|
-
});
|
|
1059
|
-
return ret;
|
|
1060
|
-
};
|
|
1061
1040
|
|
|
1062
1041
|
;// CONCATENATED MODULE: ./src/createDefaultPathMatchers.ts
|
|
1063
1042
|
|
|
1064
1043
|
|
|
1065
|
-
const
|
|
1044
|
+
const createDefaultPathMatchers = ()=>{
|
|
1066
1045
|
const ret = [
|
|
1067
1046
|
{
|
|
1068
1047
|
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
|
|
1069
1048
|
mark: 'pnpmInner'
|
|
1070
1049
|
}
|
|
1071
1050
|
];
|
|
1072
|
-
const tmpdir =
|
|
1051
|
+
const tmpdir = getRealTemporaryDirectory();
|
|
1073
1052
|
tmpdir && ret.push({
|
|
1074
1053
|
match: tmpdir,
|
|
1075
1054
|
mark: 'temp'
|
|
@@ -1101,7 +1080,7 @@ function createSnapshotSerializer(options) {
|
|
|
1101
1080
|
match: workspace
|
|
1102
1081
|
},
|
|
1103
1082
|
...customMatchers,
|
|
1104
|
-
...
|
|
1083
|
+
...createDefaultPathMatchers()
|
|
1105
1084
|
];
|
|
1106
1085
|
for (const matcher of pathMatchers){
|
|
1107
1086
|
if (typeof matcher.match === 'string') {
|
package/dist/esm/main.js
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import { createRequire as __WEBPACK_EXTERNAL_createRequire } from "module";
|
|
2
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs__ from "node:fs";
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_os__ from "node:os";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path__ from "node:path";
|
|
1
5
|
var __webpack_modules__ = ({
|
|
2
6
|
"./node_modules/.pnpm/upath@2.0.1/node_modules/upath/build/code/upath.js": (function (__unused_webpack_module, exports, __webpack_require__) {
|
|
3
7
|
/**
|
|
@@ -181,10 +185,8 @@ for (name in extraFunctions) {
|
|
|
181
185
|
;
|
|
182
186
|
|
|
183
187
|
}),
|
|
184
|
-
"path": (function () {
|
|
185
|
-
|
|
186
|
-
;// CONCATENATED MODULE: external "path"
|
|
187
|
-
|
|
188
|
+
"path": (function (module) {
|
|
189
|
+
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("path");
|
|
188
190
|
|
|
189
191
|
}),
|
|
190
192
|
|
|
@@ -249,9 +251,6 @@ __webpack_require__.o = function (obj, prop) {
|
|
|
249
251
|
/************************************************************************/
|
|
250
252
|
var __webpack_exports__ = {};
|
|
251
253
|
|
|
252
|
-
;// CONCATENATED MODULE: external "node:os"
|
|
253
|
-
|
|
254
|
-
var external_node_os_default = /*#__PURE__*/__webpack_require__.n(external_node_os_namespaceObject);
|
|
255
254
|
;// CONCATENATED MODULE: ./node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayReduce.js
|
|
256
255
|
/**
|
|
257
256
|
* A specialized version of `_.reduce` for arrays without support for
|
|
@@ -925,10 +924,22 @@ var snakeCase_snakeCase = _createCompounder(function(result, word, index) {
|
|
|
925
924
|
|
|
926
925
|
;// CONCATENATED MODULE: external "node:fs"
|
|
927
926
|
|
|
928
|
-
var
|
|
927
|
+
var external_node_fs_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
928
|
+
var external_node_fs_y = x => () => x
|
|
929
|
+
var external_node_fs_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_fs__;
|
|
930
|
+
|
|
931
|
+
;// CONCATENATED MODULE: external "node:os"
|
|
932
|
+
|
|
933
|
+
var external_node_os_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
934
|
+
var external_node_os_y = x => () => x
|
|
935
|
+
var external_node_os_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_os__;
|
|
936
|
+
|
|
929
937
|
;// CONCATENATED MODULE: external "node:path"
|
|
930
938
|
|
|
931
|
-
var
|
|
939
|
+
var external_node_path_x = y => { var x = {}; __webpack_require__.d(x, y); return x; }
|
|
940
|
+
var external_node_path_y = x => () => x
|
|
941
|
+
var external_node_path_namespaceObject = __WEBPACK_EXTERNAL_MODULE_node_path__;
|
|
942
|
+
|
|
932
943
|
;// CONCATENATED MODULE: ./node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/escapeRegExp.js
|
|
933
944
|
|
|
934
945
|
|
|
@@ -972,16 +983,18 @@ var upath_default = /*#__PURE__*/__webpack_require__.n(upath);
|
|
|
972
983
|
|
|
973
984
|
|
|
974
985
|
|
|
975
|
-
const isPathString = (test)=>
|
|
976
|
-
function
|
|
986
|
+
const isPathString = (test)=>external_node_path_namespaceObject["default"].posix.basename(test) !== test || external_node_path_namespaceObject["default"].win32.basename(test) !== test;
|
|
987
|
+
function getRealTemporaryDirectory() {
|
|
977
988
|
let ret = null;
|
|
978
989
|
try {
|
|
979
|
-
ret =
|
|
980
|
-
ret =
|
|
990
|
+
ret = external_node_os_namespaceObject["default"].tmpdir();
|
|
991
|
+
ret = external_node_fs_namespaceObject["default"].realpathSync(ret);
|
|
981
992
|
} catch {}
|
|
982
993
|
return ret;
|
|
983
994
|
}
|
|
984
|
-
const normalizeToPosixPath = (p)=>
|
|
995
|
+
const normalizeToPosixPath = (p)=>{
|
|
996
|
+
return upath_default().normalizeSafe(external_node_path_namespaceObject["default"].normalize(p || '')).replace(/^([a-zA-Z]+):/, (_, m)=>`/${m.toLowerCase()}`);
|
|
997
|
+
};
|
|
985
998
|
/**
|
|
986
999
|
* Compile path string to RegExp.
|
|
987
1000
|
* @note Only support posix path.
|
|
@@ -999,7 +1012,6 @@ function splitPathString(str) {
|
|
|
999
1012
|
;// CONCATENATED MODULE: ./src/applyMatcherReplacement.ts
|
|
1000
1013
|
|
|
1001
1014
|
|
|
1002
|
-
|
|
1003
1015
|
function applyPathMatcher(matcher, str, options = {}) {
|
|
1004
1016
|
const regex = compilePathMatcherRegExp(matcher.match);
|
|
1005
1017
|
const replacer = (substring, ...args)=>{
|
|
@@ -1016,50 +1028,28 @@ function applyMatcherReplacement(matchers, str, options = {}) {
|
|
|
1016
1028
|
return applyPathMatcher(matcher, ret, options);
|
|
1017
1029
|
}, str);
|
|
1018
1030
|
}
|
|
1019
|
-
const createDefaultPathMatchers = ()=>{
|
|
1020
|
-
const ret = [
|
|
1021
|
-
{
|
|
1022
|
-
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
|
|
1023
|
-
mark: 'pnpmInner'
|
|
1024
|
-
}
|
|
1025
|
-
];
|
|
1026
|
-
const tmpdir = getRealTemporaryDirectory();
|
|
1027
|
-
tmpdir && ret.push({
|
|
1028
|
-
match: tmpdir,
|
|
1029
|
-
mark: 'temp'
|
|
1030
|
-
});
|
|
1031
|
-
ret.push({
|
|
1032
|
-
match: os.tmpdir(),
|
|
1033
|
-
mark: 'temp'
|
|
1034
|
-
});
|
|
1035
|
-
ret.push({
|
|
1036
|
-
match: os.homedir(),
|
|
1037
|
-
mark: 'home'
|
|
1038
|
-
});
|
|
1039
|
-
return ret;
|
|
1040
|
-
};
|
|
1041
1031
|
|
|
1042
1032
|
;// CONCATENATED MODULE: ./src/createDefaultPathMatchers.ts
|
|
1043
1033
|
|
|
1044
1034
|
|
|
1045
|
-
const
|
|
1035
|
+
const createDefaultPathMatchers = ()=>{
|
|
1046
1036
|
const ret = [
|
|
1047
1037
|
{
|
|
1048
1038
|
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/,
|
|
1049
1039
|
mark: 'pnpmInner'
|
|
1050
1040
|
}
|
|
1051
1041
|
];
|
|
1052
|
-
const tmpdir =
|
|
1042
|
+
const tmpdir = getRealTemporaryDirectory();
|
|
1053
1043
|
tmpdir && ret.push({
|
|
1054
1044
|
match: tmpdir,
|
|
1055
1045
|
mark: 'temp'
|
|
1056
1046
|
});
|
|
1057
1047
|
ret.push({
|
|
1058
|
-
match:
|
|
1048
|
+
match: external_node_os_namespaceObject["default"].tmpdir(),
|
|
1059
1049
|
mark: 'temp'
|
|
1060
1050
|
});
|
|
1061
1051
|
ret.push({
|
|
1062
|
-
match:
|
|
1052
|
+
match: external_node_os_namespaceObject["default"].homedir(),
|
|
1063
1053
|
mark: 'home'
|
|
1064
1054
|
});
|
|
1065
1055
|
return ret;
|
|
@@ -1081,7 +1071,7 @@ function createSnapshotSerializer(options) {
|
|
|
1081
1071
|
match: workspace
|
|
1082
1072
|
},
|
|
1083
1073
|
...customMatchers,
|
|
1084
|
-
...
|
|
1074
|
+
...createDefaultPathMatchers()
|
|
1085
1075
|
];
|
|
1086
1076
|
for (const matcher of pathMatchers){
|
|
1087
1077
|
if (typeof matcher.match === 'string') {
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
html: {
|
|
3
|
+
meta: {
|
|
4
|
+
charset: {
|
|
5
|
+
charset: 'UTF-8'
|
|
6
|
+
},
|
|
7
|
+
viewport: 'width=device-width, initial-scale=1.0'
|
|
8
|
+
},
|
|
9
|
+
title: 'Rsbuild App',
|
|
10
|
+
inject: 'head',
|
|
11
|
+
mountId: 'root',
|
|
12
|
+
crossorigin: false,
|
|
13
|
+
outputStructure: 'flat',
|
|
14
|
+
scriptLoading: 'defer'
|
|
15
|
+
},
|
|
16
|
+
source: {
|
|
17
|
+
alias: {},
|
|
18
|
+
define: {},
|
|
19
|
+
aliasStrategy: 'prefer-tsconfig',
|
|
20
|
+
preEntry: [],
|
|
21
|
+
decorators: {
|
|
22
|
+
version: '2022-03'
|
|
23
|
+
},
|
|
24
|
+
tsconfigPath: '/Users/bytedance/Documents/codes/path-serializer/tsconfig.json',
|
|
25
|
+
entry: {
|
|
26
|
+
main: './src/index.ts'
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
output: {
|
|
30
|
+
target: 'node',
|
|
31
|
+
distPath: {
|
|
32
|
+
root: './dist/cjs',
|
|
33
|
+
css: 'static/css',
|
|
34
|
+
svg: 'static/svg',
|
|
35
|
+
font: 'static/font',
|
|
36
|
+
html: '/',
|
|
37
|
+
wasm: 'static/wasm',
|
|
38
|
+
image: 'static/image',
|
|
39
|
+
media: 'static/media',
|
|
40
|
+
js: './'
|
|
41
|
+
},
|
|
42
|
+
assetPrefix: '/',
|
|
43
|
+
filename: {
|
|
44
|
+
js: '[name].cjs'
|
|
45
|
+
},
|
|
46
|
+
charset: 'ascii',
|
|
47
|
+
polyfill: 'off',
|
|
48
|
+
dataUriLimit: {
|
|
49
|
+
svg: 4096,
|
|
50
|
+
font: 4096,
|
|
51
|
+
image: 4096,
|
|
52
|
+
media: 4096
|
|
53
|
+
},
|
|
54
|
+
legalComments: 'linked',
|
|
55
|
+
injectStyles: false,
|
|
56
|
+
minify: false,
|
|
57
|
+
manifest: false,
|
|
58
|
+
sourceMap: {
|
|
59
|
+
js: undefined,
|
|
60
|
+
css: false
|
|
61
|
+
},
|
|
62
|
+
filenameHash: false,
|
|
63
|
+
inlineScripts: false,
|
|
64
|
+
inlineStyles: false,
|
|
65
|
+
cssModules: {
|
|
66
|
+
auto: true,
|
|
67
|
+
namedExport: false,
|
|
68
|
+
exportGlobals: false,
|
|
69
|
+
exportLocalsConvention: 'camelCase'
|
|
70
|
+
},
|
|
71
|
+
emitAssets: true,
|
|
72
|
+
overrideBrowserslist: [
|
|
73
|
+
'last 1 node versions'
|
|
74
|
+
],
|
|
75
|
+
externals: [
|
|
76
|
+
'assert',
|
|
77
|
+
'assert/strict',
|
|
78
|
+
'async_hooks',
|
|
79
|
+
'buffer',
|
|
80
|
+
'child_process',
|
|
81
|
+
'cluster',
|
|
82
|
+
'console',
|
|
83
|
+
'constants',
|
|
84
|
+
'crypto',
|
|
85
|
+
'dgram',
|
|
86
|
+
'diagnostics_channel',
|
|
87
|
+
'dns',
|
|
88
|
+
'dns/promises',
|
|
89
|
+
'domain',
|
|
90
|
+
'events',
|
|
91
|
+
'fs',
|
|
92
|
+
'fs/promises',
|
|
93
|
+
'http',
|
|
94
|
+
'http2',
|
|
95
|
+
'https',
|
|
96
|
+
'inspector',
|
|
97
|
+
'inspector/promises',
|
|
98
|
+
'module',
|
|
99
|
+
'net',
|
|
100
|
+
'os',
|
|
101
|
+
'path',
|
|
102
|
+
'path/posix',
|
|
103
|
+
'path/win32',
|
|
104
|
+
'perf_hooks',
|
|
105
|
+
'process',
|
|
106
|
+
'punycode',
|
|
107
|
+
'querystring',
|
|
108
|
+
'readline',
|
|
109
|
+
'readline/promises',
|
|
110
|
+
'repl',
|
|
111
|
+
'stream',
|
|
112
|
+
'stream/consumers',
|
|
113
|
+
'stream/promises',
|
|
114
|
+
'stream/web',
|
|
115
|
+
'string_decoder',
|
|
116
|
+
'sys',
|
|
117
|
+
'timers',
|
|
118
|
+
'timers/promises',
|
|
119
|
+
'tls',
|
|
120
|
+
'trace_events',
|
|
121
|
+
'tty',
|
|
122
|
+
'url',
|
|
123
|
+
'util',
|
|
124
|
+
'util/types',
|
|
125
|
+
'v8',
|
|
126
|
+
'vm',
|
|
127
|
+
'wasi',
|
|
128
|
+
'worker_threads',
|
|
129
|
+
'zlib',
|
|
130
|
+
/^node:/,
|
|
131
|
+
'pnpapi'
|
|
132
|
+
]
|
|
133
|
+
},
|
|
134
|
+
tools: {
|
|
135
|
+
cssExtract: {
|
|
136
|
+
loaderOptions: {},
|
|
137
|
+
pluginOptions: {
|
|
138
|
+
ignoreOrder: true
|
|
139
|
+
}
|
|
140
|
+
},
|
|
141
|
+
rspack: [
|
|
142
|
+
{
|
|
143
|
+
externalsType: 'commonjs',
|
|
144
|
+
output: {
|
|
145
|
+
iife: false,
|
|
146
|
+
chunkFormat: 'commonjs',
|
|
147
|
+
library: {
|
|
148
|
+
type: 'commonjs'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
(config) => {
|
|
153
|
+
config.target = ["es2022"];
|
|
154
|
+
return config;
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
target: [
|
|
158
|
+
'node'
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
optimization: {
|
|
163
|
+
moduleIds: 'named'
|
|
164
|
+
},
|
|
165
|
+
experiments: {
|
|
166
|
+
rspackFuture: {
|
|
167
|
+
bundlerInfo: {
|
|
168
|
+
force: false
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
],
|
|
174
|
+
htmlPlugin: false
|
|
175
|
+
},
|
|
176
|
+
security: {
|
|
177
|
+
nonce: '',
|
|
178
|
+
sri: {
|
|
179
|
+
enable: false
|
|
180
|
+
}
|
|
181
|
+
},
|
|
182
|
+
performance: {
|
|
183
|
+
profile: false,
|
|
184
|
+
buildCache: true,
|
|
185
|
+
printFileSize: true,
|
|
186
|
+
removeConsole: false,
|
|
187
|
+
removeMomentLocale: false,
|
|
188
|
+
chunkSplit: {
|
|
189
|
+
strategy: 'split-by-experience'
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
dev: {
|
|
193
|
+
assetPrefix: '/',
|
|
194
|
+
lazyCompilation: undefined,
|
|
195
|
+
progressBar: false,
|
|
196
|
+
hmr: true,
|
|
197
|
+
liveReload: true,
|
|
198
|
+
writeToDisk: false,
|
|
199
|
+
client: {
|
|
200
|
+
path: '/rsbuild-hmr',
|
|
201
|
+
port: '',
|
|
202
|
+
host: '',
|
|
203
|
+
overlay: true
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
_privateMeta: {
|
|
207
|
+
configFilePath: '/Users/bytedance/Documents/codes/path-serializer/rslib.config.ts'
|
|
208
|
+
},
|
|
209
|
+
dts: {
|
|
210
|
+
bundle: true
|
|
211
|
+
},
|
|
212
|
+
plugins: [
|
|
213
|
+
{
|
|
214
|
+
name: 'rsbuild:dts',
|
|
215
|
+
setup(api) {
|
|
216
|
+
options.bundle = options.bundle ?? false;
|
|
217
|
+
options.abortOnError = options.abortOnError ?? true;
|
|
218
|
+
const dtsPromises = [];
|
|
219
|
+
let promisesResult = [];
|
|
220
|
+
api.onBeforeEnvironmentCompile(
|
|
221
|
+
({ isWatch, isFirstCompile, environment }) => {
|
|
222
|
+
if (!isFirstCompile) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
const { config } = environment;
|
|
226
|
+
options.distPath = options.distPath ?? config.output?.distPath?.root;
|
|
227
|
+
const jsExtension = extname(__filename);
|
|
228
|
+
const childProcess = fork(join(__dirname, `./dts${jsExtension}`), [], {
|
|
229
|
+
stdio: "inherit"
|
|
230
|
+
});
|
|
231
|
+
const dtsGenOptions = {
|
|
232
|
+
...options,
|
|
233
|
+
// TODO: temporarily use main as dts entry, only accept single entry
|
|
234
|
+
entryPath: config.source?.entry?.main,
|
|
235
|
+
tsconfigPath: config.source.tsconfigPath,
|
|
236
|
+
name: environment.name,
|
|
237
|
+
cwd: api.context.rootPath,
|
|
238
|
+
isWatch
|
|
239
|
+
};
|
|
240
|
+
childProcess.send(dtsGenOptions);
|
|
241
|
+
dtsPromises.push(
|
|
242
|
+
new Promise((resolve) => {
|
|
243
|
+
childProcess.on("message", (message) => {
|
|
244
|
+
if (message === "success") {
|
|
245
|
+
resolve({
|
|
246
|
+
status: "success"
|
|
247
|
+
});
|
|
248
|
+
} else if (message === "error") {
|
|
249
|
+
resolve({
|
|
250
|
+
status: "error",
|
|
251
|
+
errorMessage: `Error occurred in ${environment.name} DTS generation`
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
});
|
|
255
|
+
})
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
);
|
|
259
|
+
api.onAfterBuild(async ({ isFirstCompile }) => {
|
|
260
|
+
if (!isFirstCompile) {
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
promisesResult = await Promise.all(dtsPromises);
|
|
264
|
+
});
|
|
265
|
+
api.onAfterBuild({
|
|
266
|
+
handler: ({ isFirstCompile }) => {
|
|
267
|
+
if (!isFirstCompile) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
for (const result of promisesResult) {
|
|
271
|
+
if (result.status === "error") {
|
|
272
|
+
if (options.abortOnError) {
|
|
273
|
+
throw new Error(result.errorMessage);
|
|
274
|
+
}
|
|
275
|
+
result.errorMessage && logger.error(result.errorMessage);
|
|
276
|
+
logger.warn(
|
|
277
|
+
"With the `abortOnError` configuration currently turned off, type errors do not cause build failures, but they do not guarantee proper type file output."
|
|
278
|
+
);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
},
|
|
282
|
+
order: "post"
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
],
|
|
287
|
+
server: {
|
|
288
|
+
port: 3000,
|
|
289
|
+
host: '0.0.0.0',
|
|
290
|
+
open: false,
|
|
291
|
+
htmlFallback: 'index',
|
|
292
|
+
compress: true,
|
|
293
|
+
printUrls: true,
|
|
294
|
+
strictPort: false
|
|
295
|
+
},
|
|
296
|
+
pluginNames: [
|
|
297
|
+
'rsbuild:basic',
|
|
298
|
+
'rsbuild:entry',
|
|
299
|
+
'rsbuild:cache',
|
|
300
|
+
'rsbuild:target',
|
|
301
|
+
'rsbuild:output',
|
|
302
|
+
'rsbuild:resolve',
|
|
303
|
+
'rsbuild:file-size',
|
|
304
|
+
'rsbuild:clean-output',
|
|
305
|
+
'rsbuild:asset',
|
|
306
|
+
'rsbuild:html',
|
|
307
|
+
'rsbuild:app-icon',
|
|
308
|
+
'rsbuild:wasm',
|
|
309
|
+
'rsbuild:moment',
|
|
310
|
+
'rsbuild:node-addons',
|
|
311
|
+
'rsbuild:define',
|
|
312
|
+
'rsbuild:css',
|
|
313
|
+
'rsbuild:minimize',
|
|
314
|
+
'rsbuild:progress',
|
|
315
|
+
'rsbuild:swc',
|
|
316
|
+
'rsbuild:externals',
|
|
317
|
+
'rsbuild:split-chunks',
|
|
318
|
+
'rsbuild:open',
|
|
319
|
+
'rsbuild:inline-chunk',
|
|
320
|
+
'rsbuild:rsdoctor',
|
|
321
|
+
'rsbuild:resource-hints',
|
|
322
|
+
'rsbuild:performance',
|
|
323
|
+
'rsbuild:bundle-analyzer',
|
|
324
|
+
'rsbuild:server',
|
|
325
|
+
'rsbuild:manifest',
|
|
326
|
+
'rsbuild:module-federation',
|
|
327
|
+
'rsbuild:rspack-profile',
|
|
328
|
+
'rsbuild:lazy-compilation',
|
|
329
|
+
'rsbuild:sri',
|
|
330
|
+
'rsbuild:nonce',
|
|
331
|
+
'rsbuild:dts'
|
|
332
|
+
]
|
|
333
|
+
}
|