@rstest/core 0.7.3 → 0.7.5
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/0~130.js +2 -1
- package/dist/0~151.js +18 -21
- package/dist/0~173.js +49 -7
- package/dist/0~255.js +1 -1
- package/dist/0~403.js +2 -1
- package/dist/0~426.js +5 -3
- package/dist/0~583.js +3 -2
- package/dist/0~588.js +5 -3
- package/dist/0~62.js +1 -1
- package/dist/0~634.js +55 -7
- package/dist/0~809.js +1 -1
- package/dist/0~835.js +5 -3
- package/dist/{0~122.js → 0~89.js} +178 -47
- package/dist/0~919.js +1 -1
- package/dist/0~923.js +4 -3
- package/dist/0~973.js +50 -0
- package/dist/131.js +42 -22
- package/dist/{946.js → 157.js} +10 -890
- package/dist/198.js +4 -0
- package/dist/{404.js → 216.js} +1 -2
- package/dist/278.js +765 -0
- package/dist/554.js +5 -6714
- package/dist/693.js +91 -0
- package/dist/734.js +5 -3
- package/dist/881.js +4 -0
- package/dist/913.js +6718 -0
- package/dist/globalSetupWorker.d.ts +9 -0
- package/dist/globalSetupWorker.js +115 -0
- package/dist/index.d.ts +168 -21
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +166 -21
- package/package.json +3 -2
- /package/dist/{554.js.LICENSE.txt → 913.js.LICENSE.txt} +0 -0
|
@@ -4,8 +4,12 @@ import { __webpack_require__ } from "./rslib-runtime.js";
|
|
|
4
4
|
import node_events from "node:events";
|
|
5
5
|
import { Tinypool } from "tinypool";
|
|
6
6
|
import node_inspector from "node:inspector";
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
7
|
+
import "./693.js";
|
|
8
|
+
import { node_process, basename, isDebug, dirname, posix, resolve as pathe_M_eThtNZ_resolve, join } from "./278.js";
|
|
9
|
+
import { fileURLToPath } from "./198.js";
|
|
10
|
+
import { node_v8, createBirpc } from "./216.js";
|
|
11
|
+
import { serializableConfig, bgColor, TEMP_RSTEST_OUTPUT_DIR, TEMP_RSTEST_OUTPUT_DIR_GLOB, castArray, ADDITIONAL_NODE_BUILTINS, needFlagExperimentalDetectModule } from "./157.js";
|
|
12
|
+
import { isBuiltin } from "./881.js";
|
|
9
13
|
import { core_logger, createRsbuild } from "./131.js";
|
|
10
14
|
const DefaultMaxHeapSize = 1073741824;
|
|
11
15
|
function memory_isMemorySufficient(options) {
|
|
@@ -63,6 +67,8 @@ const createForksPool = (poolOptions)=>{
|
|
|
63
67
|
isolateWorkers: isolate
|
|
64
68
|
};
|
|
65
69
|
const pool = new Tinypool(options);
|
|
70
|
+
const destroy = pool.destroy.bind(pool);
|
|
71
|
+
process.on('SIGTERM', destroy);
|
|
66
72
|
return {
|
|
67
73
|
name: 'forks',
|
|
68
74
|
runTest: async ({ options, rpcMethods })=>{
|
|
@@ -85,7 +91,10 @@ const createForksPool = (poolOptions)=>{
|
|
|
85
91
|
cleanup();
|
|
86
92
|
}
|
|
87
93
|
},
|
|
88
|
-
close: ()=>
|
|
94
|
+
close: ()=>{
|
|
95
|
+
process.off('SIGTERM', destroy);
|
|
96
|
+
return destroy();
|
|
97
|
+
}
|
|
89
98
|
};
|
|
90
99
|
};
|
|
91
100
|
const external_node_os_ = __webpack_require__("node:os");
|
|
@@ -104,7 +113,10 @@ const parseWorkers = (maxWorkers)=>{
|
|
|
104
113
|
const getRuntimeConfig = (context)=>{
|
|
105
114
|
const { testNamePattern, testTimeout, passWithNoTests, retry, globals, clearMocks, resetMocks, restoreMocks, unstubEnvs, unstubGlobals, maxConcurrency, printConsoleTrace, disableConsoleIntercept, testEnvironment, hookTimeout, isolate, coverage, snapshotFormat, env, logHeapUsage, bail, chaiConfig, includeTaskLocation } = context.normalizedConfig;
|
|
106
115
|
return {
|
|
107
|
-
env
|
|
116
|
+
env: {
|
|
117
|
+
...process.env,
|
|
118
|
+
...env
|
|
119
|
+
},
|
|
108
120
|
testNamePattern,
|
|
109
121
|
testTimeout,
|
|
110
122
|
hookTimeout,
|
|
@@ -121,7 +133,10 @@ const getRuntimeConfig = (context)=>{
|
|
|
121
133
|
disableConsoleIntercept,
|
|
122
134
|
testEnvironment,
|
|
123
135
|
isolate,
|
|
124
|
-
coverage
|
|
136
|
+
coverage: {
|
|
137
|
+
...coverage,
|
|
138
|
+
reporters: []
|
|
139
|
+
},
|
|
125
140
|
snapshotFormat,
|
|
126
141
|
logHeapUsage,
|
|
127
142
|
bail,
|
|
@@ -165,8 +180,7 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
165
180
|
].filter(Boolean),
|
|
166
181
|
env: {
|
|
167
182
|
NODE_ENV: 'test',
|
|
168
|
-
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1'
|
|
169
|
-
...process.env
|
|
183
|
+
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1'
|
|
170
184
|
}
|
|
171
185
|
});
|
|
172
186
|
const rpcMethods = {
|
|
@@ -313,6 +327,78 @@ const createPool = async ({ context, recommendWorkerCount = 1 / 0 })=>{
|
|
|
313
327
|
close: ()=>pool.close()
|
|
314
328
|
};
|
|
315
329
|
};
|
|
330
|
+
let globalTeardownCallbacks = [];
|
|
331
|
+
function applyEnvChanges(changes) {
|
|
332
|
+
for(const key in changes)if (void 0 === changes[key]) delete process.env[key];
|
|
333
|
+
else process.env[key] = changes[key];
|
|
334
|
+
}
|
|
335
|
+
const globalSetup_filename = fileURLToPath(import.meta.url);
|
|
336
|
+
const globalSetup_dirname = dirname(globalSetup_filename);
|
|
337
|
+
async function createSetupPool() {
|
|
338
|
+
const options = {
|
|
339
|
+
runtime: 'child_process',
|
|
340
|
+
filename: pathe_M_eThtNZ_resolve(globalSetup_dirname, './globalSetupWorker.js'),
|
|
341
|
+
execArgv: [
|
|
342
|
+
...process.execArgv,
|
|
343
|
+
'--experimental-vm-modules',
|
|
344
|
+
'--experimental-import-meta-resolve',
|
|
345
|
+
'--no-warnings'
|
|
346
|
+
],
|
|
347
|
+
maxThreads: 1,
|
|
348
|
+
minThreads: 1,
|
|
349
|
+
concurrentTasksPerWorker: 1,
|
|
350
|
+
isolateWorkers: false,
|
|
351
|
+
env: {
|
|
352
|
+
NODE_ENV: 'test',
|
|
353
|
+
FORCE_COLOR: '1' === process.env.NO_COLOR ? '0' : '1',
|
|
354
|
+
...process.env
|
|
355
|
+
}
|
|
356
|
+
};
|
|
357
|
+
const pool = new Tinypool(options);
|
|
358
|
+
const destroy = pool.destroy.bind(pool);
|
|
359
|
+
process.on('SIGTERM', destroy);
|
|
360
|
+
return pool;
|
|
361
|
+
}
|
|
362
|
+
async function runGlobalSetup({ globalSetupEntries, assetFiles, sourceMaps, interopDefault, outputModule }) {
|
|
363
|
+
const pool = await createSetupPool();
|
|
364
|
+
const result = await pool.run({
|
|
365
|
+
type: 'setup',
|
|
366
|
+
entries: globalSetupEntries,
|
|
367
|
+
assetFiles,
|
|
368
|
+
interopDefault,
|
|
369
|
+
outputModule,
|
|
370
|
+
sourceMaps
|
|
371
|
+
});
|
|
372
|
+
if (result.success) {
|
|
373
|
+
if (result.envChanges) applyEnvChanges(result.envChanges);
|
|
374
|
+
if (result.hasTeardown) globalTeardownCallbacks.push(()=>runWorkerTeardown(pool));
|
|
375
|
+
}
|
|
376
|
+
return {
|
|
377
|
+
success: result.success,
|
|
378
|
+
errors: result.errors
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
async function runWorkerTeardown(pool) {
|
|
382
|
+
const result = await pool.run({
|
|
383
|
+
type: 'teardown'
|
|
384
|
+
});
|
|
385
|
+
if (!result.success) process.exitCode = 1;
|
|
386
|
+
await pool.destroy();
|
|
387
|
+
}
|
|
388
|
+
async function runGlobalTeardown() {
|
|
389
|
+
const teardownCallbacks = [
|
|
390
|
+
...globalTeardownCallbacks
|
|
391
|
+
];
|
|
392
|
+
globalTeardownCallbacks = [];
|
|
393
|
+
for (const teardown of teardownCallbacks.reverse())try {
|
|
394
|
+
await teardown();
|
|
395
|
+
} catch (error) {
|
|
396
|
+
console.error(bgColor('bgRed', 'Error during global teardown'));
|
|
397
|
+
if (error instanceof Error) error.stack ? console.error(picocolors_default().red(error.stack)) : console.error(picocolors_default().red(error.message));
|
|
398
|
+
else console.error(picocolors_default().red(String(error)));
|
|
399
|
+
process.exitCode = 1;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
316
402
|
const RUNTIME_CHUNK_NAME = 'runtime';
|
|
317
403
|
const requireShim = `// Rstest ESM shims
|
|
318
404
|
import __rstest_shim_module__ from 'node:module';
|
|
@@ -417,7 +503,7 @@ const pluginBasic = (context)=>({
|
|
|
417
503
|
});
|
|
418
504
|
}
|
|
419
505
|
});
|
|
420
|
-
const external_node_path_ = __webpack_require__("path");
|
|
506
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
421
507
|
const PLUGIN_CSS_FILTER = 'rstest:css-filter';
|
|
422
508
|
const css_filter_dirname = external_node_path_["default"].dirname(fileURLToPath(import.meta.url));
|
|
423
509
|
const pluginCSSFilter = ()=>({
|
|
@@ -461,7 +547,7 @@ class TestFileWatchPlugin {
|
|
|
461
547
|
});
|
|
462
548
|
}
|
|
463
549
|
}
|
|
464
|
-
const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context })=>({
|
|
550
|
+
const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, globalSetupFiles, context })=>({
|
|
465
551
|
name: 'rstest:entry-watch',
|
|
466
552
|
setup: (api)=>{
|
|
467
553
|
api.modifyRspackConfig(async (config, { environment })=>{
|
|
@@ -471,13 +557,14 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
471
557
|
const sourceEntries = await globTestSourceEntries(environment.name);
|
|
472
558
|
return {
|
|
473
559
|
...sourceEntries,
|
|
474
|
-
...setupFiles[environment.name]
|
|
560
|
+
...setupFiles[environment.name],
|
|
561
|
+
...globalSetupFiles?.[environment.name] || {}
|
|
475
562
|
};
|
|
476
563
|
};
|
|
477
564
|
config.watchOptions ??= {};
|
|
478
565
|
config.watchOptions.ignored = castArray(config.watchOptions.ignored || []);
|
|
479
566
|
if (0 === config.watchOptions.ignored.length) config.watchOptions.ignored.push('**/.git', '**/node_modules');
|
|
480
|
-
config.watchOptions.ignored.push(TEMP_RSTEST_OUTPUT_DIR_GLOB, context.normalizedConfig.coverage.reportsDirectory, '**/*.snap');
|
|
567
|
+
config.watchOptions.ignored.push(TEMP_RSTEST_OUTPUT_DIR_GLOB, context.normalizedConfig.coverage.reportsDirectory, ...Object.values(globalSetupFiles?.[environment.name] || {}), '**/*.snap');
|
|
481
568
|
const configFilePath = context.projects.find((project)=>project.environmentName === environment.name)?.configFilePath;
|
|
482
569
|
if (configFilePath) config.watchOptions.ignored.push(configFilePath);
|
|
483
570
|
} else {
|
|
@@ -487,6 +574,7 @@ const pluginEntryWatch = ({ isWatch, globTestSourceEntries, setupFiles, context
|
|
|
487
574
|
const sourceEntries = await globTestSourceEntries(environment.name);
|
|
488
575
|
config.entry = {
|
|
489
576
|
...setupFiles[environment.name],
|
|
577
|
+
...globalSetupFiles?.[environment.name] || {},
|
|
490
578
|
...sourceEntries
|
|
491
579
|
};
|
|
492
580
|
}
|
|
@@ -694,7 +782,7 @@ function parseInlineSourceMapStr(code) {
|
|
|
694
782
|
}
|
|
695
783
|
}
|
|
696
784
|
const isMultiCompiler = (compiler)=>'compilers' in compiler && Array.isArray(compiler.compilers);
|
|
697
|
-
const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
785
|
+
const prepareRsbuild = async (context, globTestSourceEntries, setupFiles, globalSetupFiles)=>{
|
|
698
786
|
const { command, normalizedConfig: { isolate, dev = {}, coverage } } = context;
|
|
699
787
|
const debugMode = isDebug();
|
|
700
788
|
core_logger.level = debugMode ? 'verbose' : 'error';
|
|
@@ -733,11 +821,15 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
|
733
821
|
pluginEntryWatch({
|
|
734
822
|
globTestSourceEntries,
|
|
735
823
|
setupFiles,
|
|
824
|
+
globalSetupFiles,
|
|
736
825
|
context,
|
|
737
826
|
isWatch: 'watch' === command
|
|
738
827
|
}),
|
|
739
828
|
pluginExternal(context),
|
|
740
|
-
!isolate ? pluginCacheControl(Object.values(
|
|
829
|
+
!isolate ? pluginCacheControl(Object.values({
|
|
830
|
+
...setupFiles,
|
|
831
|
+
...globalSetupFiles
|
|
832
|
+
}).flatMap((files)=>Object.values(files))) : null,
|
|
741
833
|
pluginInspect()
|
|
742
834
|
].filter(Boolean)
|
|
743
835
|
}
|
|
@@ -750,7 +842,7 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
|
750
842
|
pluginCoverageCore: mod.pluginCoverageCore
|
|
751
843
|
}));
|
|
752
844
|
const { pluginCoverage } = await loadCoverageProvider(coverage, context.rootPath);
|
|
753
|
-
coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)));
|
|
845
|
+
coverage.exclude.push(...Object.values(setupFiles).flatMap((files)=>Object.values(files)), ...Object.values(globalSetupFiles || {}).flatMap((files)=>Object.values(files)));
|
|
754
846
|
rsbuildInstance.addPlugins([
|
|
755
847
|
pluginCoverage(coverage),
|
|
756
848
|
pluginCoverageCore(coverage)
|
|
@@ -758,50 +850,79 @@ const prepareRsbuild = async (context, globTestSourceEntries, setupFiles)=>{
|
|
|
758
850
|
}
|
|
759
851
|
return rsbuildInstance;
|
|
760
852
|
};
|
|
761
|
-
const calcEntriesToRerun = (entries, chunks, buildData, runtimeChunkName)=>{
|
|
762
|
-
const
|
|
763
|
-
const buildChunkHashes = (entry)=>{
|
|
853
|
+
const calcEntriesToRerun = (entries, chunks, buildData, runtimeChunkName, setupEntries)=>{
|
|
854
|
+
const buildChunkHashes = (entry, map)=>{
|
|
764
855
|
const validChunks = (entry.chunks || []).filter((chunk)=>chunk !== runtimeChunkName);
|
|
765
856
|
validChunks.forEach((chunkName)=>{
|
|
766
857
|
const chunkInfo = chunks?.find((c)=>c.names?.includes(chunkName));
|
|
767
858
|
if (chunkInfo) {
|
|
768
|
-
const existing =
|
|
859
|
+
const existing = map.get(entry.testPath) || {};
|
|
769
860
|
existing[chunkName] = chunkInfo.hash ?? '';
|
|
770
|
-
|
|
861
|
+
map.set(entry.testPath, existing);
|
|
771
862
|
}
|
|
772
863
|
});
|
|
773
864
|
};
|
|
774
|
-
(
|
|
865
|
+
const processEntryChanges = (_entries, prevHashes, currentHashesMap)=>{
|
|
866
|
+
const affectedPaths = new Set();
|
|
867
|
+
const deletedPaths = [];
|
|
868
|
+
if (prevHashes) {
|
|
869
|
+
const prevMap = new Map(prevHashes.map((e)=>[
|
|
870
|
+
e.name,
|
|
871
|
+
e.chunks
|
|
872
|
+
]));
|
|
873
|
+
const currentNames = new Set(currentHashesMap.keys());
|
|
874
|
+
deletedPaths.push(...Array.from(prevMap.keys()).filter((name)=>!currentNames.has(name)));
|
|
875
|
+
const findAffectedEntry = (testPath)=>{
|
|
876
|
+
const currentChunks = currentHashesMap.get(testPath);
|
|
877
|
+
const prevChunks = prevMap.get(testPath);
|
|
878
|
+
if (!currentChunks) return;
|
|
879
|
+
if (!prevChunks) return void affectedPaths.add(testPath);
|
|
880
|
+
const hasChanges = Object.entries(currentChunks).some(([chunkName, hash])=>prevChunks[chunkName] !== hash);
|
|
881
|
+
if (hasChanges) affectedPaths.add(testPath);
|
|
882
|
+
};
|
|
883
|
+
currentHashesMap.forEach((_, testPath)=>{
|
|
884
|
+
findAffectedEntry(testPath);
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
return {
|
|
888
|
+
affectedPaths,
|
|
889
|
+
deletedPaths
|
|
890
|
+
};
|
|
891
|
+
};
|
|
892
|
+
const previousSetupHashes = buildData.setupEntryToChunkHashes;
|
|
893
|
+
const previousEntryHashes = buildData.entryToChunkHashes;
|
|
894
|
+
const setupEntryToChunkHashesMap = new Map();
|
|
895
|
+
setupEntries.forEach((entry)=>{
|
|
896
|
+
buildChunkHashes(entry, setupEntryToChunkHashesMap);
|
|
897
|
+
});
|
|
898
|
+
const setupEntryToChunkHashes = Array.from(setupEntryToChunkHashesMap.entries()).map(([name, chunks])=>({
|
|
899
|
+
name,
|
|
900
|
+
chunks
|
|
901
|
+
}));
|
|
902
|
+
buildData.setupEntryToChunkHashes = setupEntryToChunkHashes;
|
|
903
|
+
const entryToChunkHashesMap = new Map();
|
|
904
|
+
(entries || []).forEach((entry)=>{
|
|
905
|
+
buildChunkHashes(entry, entryToChunkHashesMap);
|
|
906
|
+
});
|
|
775
907
|
const entryToChunkHashes = Array.from(entryToChunkHashesMap.entries()).map(([name, chunks])=>({
|
|
776
908
|
name,
|
|
777
909
|
chunks
|
|
778
910
|
}));
|
|
779
|
-
const affectedTestPaths = new Set();
|
|
780
|
-
const deletedEntries = [];
|
|
781
|
-
if (buildData.entryToChunkHashes) {
|
|
782
|
-
const prevMap = new Map(buildData.entryToChunkHashes.map((e)=>[
|
|
783
|
-
e.name,
|
|
784
|
-
e.chunks
|
|
785
|
-
]));
|
|
786
|
-
const currentNames = new Set(entryToChunkHashesMap.keys());
|
|
787
|
-
deletedEntries.push(...Array.from(prevMap.keys()).filter((name)=>!currentNames.has(name)));
|
|
788
|
-
const findAffectedEntry = (testPath)=>{
|
|
789
|
-
const currentChunks = entryToChunkHashesMap.get(testPath);
|
|
790
|
-
const prevChunks = prevMap.get(testPath);
|
|
791
|
-
if (!currentChunks) return;
|
|
792
|
-
if (!prevChunks) return void affectedTestPaths.add(testPath);
|
|
793
|
-
const hasChanges = Object.entries(currentChunks).some(([chunkName, hash])=>prevChunks[chunkName] !== hash);
|
|
794
|
-
if (hasChanges) affectedTestPaths.add(testPath);
|
|
795
|
-
};
|
|
796
|
-
entryToChunkHashesMap.forEach((_, testPath)=>{
|
|
797
|
-
findAffectedEntry(testPath);
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
911
|
buildData.entryToChunkHashes = entryToChunkHashes;
|
|
912
|
+
const isSetupChanged = ()=>{
|
|
913
|
+
const { affectedPaths: affectedSetupPaths, deletedPaths: deletedSetups } = processEntryChanges(setupEntries, previousSetupHashes, setupEntryToChunkHashesMap);
|
|
914
|
+
const affectedSetups = Array.from(affectedSetupPaths).map((testPath)=>setupEntries.find((e)=>e.testPath === testPath)).filter((entry)=>void 0 !== entry);
|
|
915
|
+
return affectedSetups.length > 0 || deletedSetups.length > 0;
|
|
916
|
+
};
|
|
917
|
+
if (isSetupChanged()) return {
|
|
918
|
+
affectedEntries: entries,
|
|
919
|
+
deletedEntries: []
|
|
920
|
+
};
|
|
921
|
+
const { affectedPaths: affectedTestPaths, deletedPaths } = processEntryChanges(entries, previousEntryHashes, entryToChunkHashesMap);
|
|
801
922
|
const affectedEntries = Array.from(affectedTestPaths).map((testPath)=>entries.find((e)=>e.testPath === testPath)).filter((entry)=>void 0 !== entry);
|
|
802
923
|
return {
|
|
803
924
|
affectedEntries,
|
|
804
|
-
deletedEntries
|
|
925
|
+
deletedEntries: deletedPaths
|
|
805
926
|
};
|
|
806
927
|
};
|
|
807
928
|
class AssetsMemorySafeMap extends Map {
|
|
@@ -811,7 +932,7 @@ class AssetsMemorySafeMap extends Map {
|
|
|
811
932
|
return super.set(key, value);
|
|
812
933
|
}
|
|
813
934
|
}
|
|
814
|
-
const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildInstance, inspectedConfig })=>{
|
|
935
|
+
const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, globalSetupFiles, rsbuildInstance, inspectedConfig, isWatchMode })=>{
|
|
815
936
|
let rspackCompiler;
|
|
816
937
|
const rstestCompilerPlugin = {
|
|
817
938
|
name: 'rstest:compiler',
|
|
@@ -876,12 +997,13 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
876
997
|
const entryFiles = await getEntryFiles(manifest, outputPath);
|
|
877
998
|
const entries = [];
|
|
878
999
|
const setupEntries = [];
|
|
1000
|
+
const globalSetupEntries = [];
|
|
879
1001
|
const sourceEntries = await globTestSourceEntries(environmentName);
|
|
880
1002
|
for (const entry of Object.keys(entrypoints)){
|
|
881
1003
|
const e = entrypoints[entry];
|
|
882
1004
|
const filteredAssets = e.assets.filter((asset)=>!asset.name.endsWith('.wasm'));
|
|
883
1005
|
const distPath = posix.join(outputPath, filteredAssets[filteredAssets.length - 1].name);
|
|
884
|
-
if (setupFiles[environmentName][entry]) setupEntries.push({
|
|
1006
|
+
if (setupFiles[environmentName]?.[entry]) setupEntries.push({
|
|
885
1007
|
distPath,
|
|
886
1008
|
testPath: setupFiles[environmentName][entry],
|
|
887
1009
|
files: entryFiles[entry],
|
|
@@ -895,7 +1017,12 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
895
1017
|
files: entryFiles[entry],
|
|
896
1018
|
chunks: e.chunks || []
|
|
897
1019
|
});
|
|
898
|
-
}
|
|
1020
|
+
} else if (globalSetupFiles?.[environmentName]?.[entry]) globalSetupEntries.push({
|
|
1021
|
+
distPath,
|
|
1022
|
+
testPath: globalSetupFiles[environmentName][entry],
|
|
1023
|
+
files: entryFiles[entry],
|
|
1024
|
+
chunks: e.chunks || []
|
|
1025
|
+
});
|
|
899
1026
|
}
|
|
900
1027
|
const inlineSourceMap = 'inline-source-map' === stats.compilation.options.devtool;
|
|
901
1028
|
const sourceMapPaths = Object.fromEntries(assets.map((asset)=>{
|
|
@@ -918,7 +1045,10 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
918
1045
|
];
|
|
919
1046
|
}));
|
|
920
1047
|
buildData[environmentName] ??= {};
|
|
921
|
-
const { affectedEntries, deletedEntries } = calcEntriesToRerun(entries, chunks, buildData[environmentName], `${environmentName}-${RUNTIME_CHUNK_NAME}
|
|
1048
|
+
const { affectedEntries, deletedEntries } = isWatchMode ? calcEntriesToRerun(entries, chunks, buildData[environmentName], `${environmentName}-${RUNTIME_CHUNK_NAME}`, setupEntries) : {
|
|
1049
|
+
affectedEntries: [],
|
|
1050
|
+
deletedEntries: []
|
|
1051
|
+
};
|
|
922
1052
|
const cachedAssetFiles = new AssetsMemorySafeMap();
|
|
923
1053
|
const cachedSourceMaps = new AssetsMemorySafeMap();
|
|
924
1054
|
const readFileWithCache = async (name)=>{
|
|
@@ -949,6 +1079,7 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
949
1079
|
hash,
|
|
950
1080
|
entries,
|
|
951
1081
|
setupEntries,
|
|
1082
|
+
globalSetupEntries,
|
|
952
1083
|
assetNames,
|
|
953
1084
|
getAssetFiles: async (names)=>Object.fromEntries(await Promise.all(names.map(async (name)=>{
|
|
954
1085
|
const content = await readFileWithCache(name);
|
|
@@ -971,4 +1102,4 @@ const createRsbuildServer = async ({ globTestSourceEntries, setupFiles, rsbuildI
|
|
|
971
1102
|
getRsbuildStats
|
|
972
1103
|
};
|
|
973
1104
|
};
|
|
974
|
-
export { createPool, createRsbuildServer, prepareRsbuild };
|
|
1105
|
+
export { createPool, createRsbuildServer, prepareRsbuild, runGlobalSetup, runGlobalTeardown };
|
package/dist/0~919.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import "./
|
|
4
|
+
import "./693.js";
|
|
5
5
|
__webpack_require__.add({
|
|
6
6
|
"../../node_modules/.pnpm/js-tokens@4.0.0/node_modules/js-tokens/index.js" (__unused_rspack_module, exports) {
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
package/dist/0~923.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import 'module';
|
|
2
2
|
/*#__PURE__*/ import.meta.url;
|
|
3
3
|
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
-
import
|
|
5
|
-
import { pathToFileURL } from "./
|
|
4
|
+
import "./693.js";
|
|
5
|
+
import { pathToFileURL } from "./198.js";
|
|
6
6
|
import { node_vm, interopModule, shouldInterop } from "./0~346.js";
|
|
7
|
-
|
|
7
|
+
import { posix, logger_logger } from "./278.js";
|
|
8
|
+
const external_node_path_ = __webpack_require__("node:path");
|
|
8
9
|
var loadEsModule_EsmMode = /*#__PURE__*/ function(EsmMode) {
|
|
9
10
|
EsmMode[EsmMode["Unknown"] = 0] = "Unknown";
|
|
10
11
|
EsmMode[EsmMode["Evaluated"] = 1] = "Evaluated";
|
package/dist/0~973.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import { __webpack_require__ } from "./rslib-runtime.js";
|
|
4
|
+
import "./693.js";
|
|
5
|
+
import { fileURLToPath } from "./198.js";
|
|
6
|
+
import { rspack } from "./131.js";
|
|
7
|
+
import { getAbsolutePath, formatTestEntryName } from "./157.js";
|
|
8
|
+
import { posix } from "./278.js";
|
|
9
|
+
const external_node_fs_ = __webpack_require__("node:fs");
|
|
10
|
+
const picocolors = __webpack_require__("../../node_modules/.pnpm/picocolors@1.1.1/node_modules/picocolors/picocolors.js");
|
|
11
|
+
var picocolors_default = /*#__PURE__*/ __webpack_require__.n(picocolors);
|
|
12
|
+
const tryResolve = (request, rootPath)=>{
|
|
13
|
+
const { resolver } = rspack.experiments;
|
|
14
|
+
const esmFirstResolver = new resolver.ResolverFactory({
|
|
15
|
+
conditionNames: [
|
|
16
|
+
'node',
|
|
17
|
+
'import',
|
|
18
|
+
'require'
|
|
19
|
+
]
|
|
20
|
+
});
|
|
21
|
+
const { path: resolvedPath } = esmFirstResolver.sync(rootPath, request);
|
|
22
|
+
return resolvedPath;
|
|
23
|
+
};
|
|
24
|
+
const getSetupFiles = (setups, rootPath)=>{
|
|
25
|
+
if (!setups.length) return {};
|
|
26
|
+
return Object.fromEntries(setups.map((filePath)=>{
|
|
27
|
+
const setupFile = filePath.startsWith('file://') ? fileURLToPath(filePath) : filePath;
|
|
28
|
+
const setupFilePath = getAbsolutePath(rootPath, setupFile);
|
|
29
|
+
try {
|
|
30
|
+
if (!(0, external_node_fs_.existsSync)(setupFilePath)) {
|
|
31
|
+
let errorMessage = `Setup file ${picocolors_default().red(setupFile)} not found`;
|
|
32
|
+
if (setupFilePath !== setupFile) errorMessage += picocolors_default().gray(` (resolved path: ${setupFilePath})`);
|
|
33
|
+
throw errorMessage;
|
|
34
|
+
}
|
|
35
|
+
const relativePath = posix.relative(rootPath, setupFilePath);
|
|
36
|
+
return [
|
|
37
|
+
formatTestEntryName(relativePath),
|
|
38
|
+
setupFilePath
|
|
39
|
+
];
|
|
40
|
+
} catch (err) {
|
|
41
|
+
const resolvedPath = tryResolve(setupFile, rootPath);
|
|
42
|
+
if (resolvedPath) return [
|
|
43
|
+
formatTestEntryName(setupFile),
|
|
44
|
+
resolvedPath
|
|
45
|
+
];
|
|
46
|
+
throw err;
|
|
47
|
+
}
|
|
48
|
+
}));
|
|
49
|
+
};
|
|
50
|
+
export { getSetupFiles };
|