path-serializer 0.0.4 → 0.0.5-beta.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/cjs/main.cjs +12 -2
- package/dist/esm/main.js +12 -2
- package/package.json +7 -2
- package/dist/rsbuild.config.cjs.mjs +0 -333
- package/dist/rsbuild.config.esm.mjs +0 -339
- package/dist/rspack.config.cjs.mjs +0 -420
- package/dist/rspack.config.esm.mjs +0 -422
package/dist/cjs/main.cjs
CHANGED
|
@@ -1044,7 +1044,7 @@ function applyMatcherReplacement(matchers, str, options = {}) {
|
|
|
1044
1044
|
const createDefaultPathMatchers = ()=>{
|
|
1045
1045
|
const ret = [
|
|
1046
1046
|
{
|
|
1047
|
-
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)
|
|
1047
|
+
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/g,
|
|
1048
1048
|
mark: 'pnpmInner'
|
|
1049
1049
|
}
|
|
1050
1050
|
];
|
|
@@ -1064,10 +1064,20 @@ const createDefaultPathMatchers = ()=>{
|
|
|
1064
1064
|
return ret;
|
|
1065
1065
|
};
|
|
1066
1066
|
|
|
1067
|
+
;// CONCATENATED MODULE: ./src/transformCodeToPosixPath.ts
|
|
1068
|
+
|
|
1069
|
+
function transformCodeToPosixPath(code) {
|
|
1070
|
+
return code.replace(/([a-zA-Z]:\\)([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+\\)*/g, (match)=>{
|
|
1071
|
+
return normalizeToPosixPath(match);
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1075
|
+
|
|
1067
1076
|
;// CONCATENATED MODULE: ./src/createSnapshotSerializer.ts
|
|
1068
1077
|
|
|
1069
1078
|
|
|
1070
1079
|
|
|
1080
|
+
|
|
1071
1081
|
function createSnapshotSerializer(options) {
|
|
1072
1082
|
const { cwd = process.cwd(), workspace = process.cwd(), replace: customMatchers = [] } = options || {};
|
|
1073
1083
|
const pathMatchers = [
|
|
@@ -1092,7 +1102,7 @@ function createSnapshotSerializer(options) {
|
|
|
1092
1102
|
// match path-format string
|
|
1093
1103
|
test: (val)=>typeof val === 'string' && isPathString(val),
|
|
1094
1104
|
print: (val)=>{
|
|
1095
|
-
const normalized =
|
|
1105
|
+
const normalized = transformCodeToPosixPath(val);
|
|
1096
1106
|
const replaced = applyMatcherReplacement(pathMatchers, normalized).replace(/"/g, '\\"');
|
|
1097
1107
|
return `"${replaced}"`;
|
|
1098
1108
|
}
|
package/dist/esm/main.js
CHANGED
|
@@ -1035,7 +1035,7 @@ function applyMatcherReplacement(matchers, str, options = {}) {
|
|
|
1035
1035
|
const createDefaultPathMatchers = ()=>{
|
|
1036
1036
|
const ret = [
|
|
1037
1037
|
{
|
|
1038
|
-
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)
|
|
1038
|
+
match: /(?<=\/)(\.pnpm\/.+?\/node_modules)(?=\/)/g,
|
|
1039
1039
|
mark: 'pnpmInner'
|
|
1040
1040
|
}
|
|
1041
1041
|
];
|
|
@@ -1055,10 +1055,20 @@ const createDefaultPathMatchers = ()=>{
|
|
|
1055
1055
|
return ret;
|
|
1056
1056
|
};
|
|
1057
1057
|
|
|
1058
|
+
;// CONCATENATED MODULE: ./src/transformCodeToPosixPath.ts
|
|
1059
|
+
|
|
1060
|
+
function transformCodeToPosixPath(code) {
|
|
1061
|
+
return code.replace(/([a-zA-Z]:\\)([-\u4e00-\u9fa5\w\s.()~!@#$%^&()\[\]{}+=]+\\)*/g, (match)=>{
|
|
1062
|
+
return normalizeToPosixPath(match);
|
|
1063
|
+
});
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1066
|
+
|
|
1058
1067
|
;// CONCATENATED MODULE: ./src/createSnapshotSerializer.ts
|
|
1059
1068
|
|
|
1060
1069
|
|
|
1061
1070
|
|
|
1071
|
+
|
|
1062
1072
|
function createSnapshotSerializer(options) {
|
|
1063
1073
|
const { cwd = process.cwd(), workspace = process.cwd(), replace: customMatchers = [] } = options || {};
|
|
1064
1074
|
const pathMatchers = [
|
|
@@ -1083,7 +1093,7 @@ function createSnapshotSerializer(options) {
|
|
|
1083
1093
|
// match path-format string
|
|
1084
1094
|
test: (val)=>typeof val === 'string' && isPathString(val),
|
|
1085
1095
|
print: (val)=>{
|
|
1086
|
-
const normalized =
|
|
1096
|
+
const normalized = transformCodeToPosixPath(val);
|
|
1087
1097
|
const replaced = applyMatcherReplacement(pathMatchers, normalized).replace(/"/g, '\\"');
|
|
1088
1098
|
return `"${replaced}"`;
|
|
1089
1099
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "path-serializer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5-beta.0",
|
|
4
4
|
"description": "path-serializer",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"snapshot",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"pre-commit": "npx nano-staged"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
+
"vitest": "^2.0.5",
|
|
39
40
|
"@biomejs/biome": "^1.8.3",
|
|
40
41
|
"@microsoft/api-extractor": "^7.47.5",
|
|
41
42
|
"@rslib/core": "file:./scripts/rslib-core-0.0.0.tgz",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"lodash-es": "^4.17.21",
|
|
45
46
|
"nano-staged": "^0.8.0",
|
|
46
47
|
"simple-git-hooks": "^2.11.1",
|
|
48
|
+
"slash": "5.1.0",
|
|
47
49
|
"typescript": "^5.5.2",
|
|
48
50
|
"upath": "^2.0.1"
|
|
49
51
|
},
|
|
@@ -59,6 +61,9 @@
|
|
|
59
61
|
"scripts": {
|
|
60
62
|
"build": "rslib build",
|
|
61
63
|
"dev": "rslib build --watch",
|
|
62
|
-
"lint": "biome check --write"
|
|
64
|
+
"lint": "biome check --write",
|
|
65
|
+
"test:watch": "vitest",
|
|
66
|
+
"test": "vitest run",
|
|
67
|
+
"prepublish": "pnpm run build"
|
|
63
68
|
}
|
|
64
69
|
}
|
|
@@ -1,333 +0,0 @@
|
|
|
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
|
-
}
|