File tree Expand file tree Collapse file tree 1 file changed +7
-8
lines changed
Expand file tree Collapse file tree 1 file changed +7
-8
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,12 @@ const fixtures = require('../common/fixtures');
1212// Test case: Loader returning null source for CommonJS module
1313// This should throw ERR_INVALID_RETURN_PROPERTY_VALUE, not ERR_INTERNAL_ASSERTION
1414{
15+ function load ( url , context , next ) {
16+ if ( url . includes ( "test-null-source" ) ) {
17+ return { format : "commonjs" , source : null , shortCircuit : true } ;
18+ }
19+ return next ( url ) ;
20+ }
1521 const result = spawnSync (
1622 process . execPath ,
1723 [
@@ -22,14 +28,7 @@ const fixtures = require('../common/fixtures');
2228 import { register } from 'node:module';
2329
2430 // Register a custom loader that returns null source
25- const code = 'export function load(url, context, next) {' +
26- ' if (url.includes("test-null-source")) {' +
27- ' return { format: "commonjs", source: null, shortCircuit: true };' +
28- ' }' +
29- ' return next(url);' +
30- '}';
31-
32- register('data:text/javascript,' + encodeURIComponent(code));
31+ register('data:text/javascript,export ' + encodeURIComponent(${ load } ));
3332
3433 await assert.rejects(import('file:///test-null-source.js'), { code: 'ERR_INVALID_RETURN_PROPERTY_VALUE' });
3534 ` ,
You can’t perform that action at this time.
0 commit comments