forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change default resolver to not throw on unknown scheme
Fixes nodejs/loaders#138
- Loading branch information
Showing
9 changed files
with
136 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { spawnPromisified } from '../common/index.mjs'; | ||
import * as fixtures from '../common/fixtures.mjs'; | ||
import assert from 'node:assert'; | ||
import { execPath } from 'node:process'; | ||
import {describe, it} from 'node:test' | ||
|
||
describe('default resolver', () => { | ||
it('should accept foreign schemas without exception (e.g. uyyt://something/or-other', async () => { | ||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
'--no-warnings', | ||
'--experimental-loader', | ||
fixtures.fileURL('/es-module-loaders/uyyt-dummy-loader.mjs'), | ||
fixtures.path('/es-module-loaders/uyyt-dummy-loader-main.mjs'), | ||
]); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(stdout.trim(), 'index.mjs!'); | ||
assert.strictEqual(stderr, ''); | ||
}) | ||
it('should resolve foreign schemas by doing regular url absolutization', async () => { | ||
const { code, signal, stdout, stderr } = await spawnPromisified(execPath, [ | ||
'--no-warnings', | ||
'--experimental-loader', | ||
fixtures.fileURL('/es-module-loaders/uyyt-dummy-loader.mjs'), | ||
fixtures.path('/es-module-loaders/uyyt-dummy-loader-main2.mjs'), | ||
]); | ||
assert.strictEqual(code, 0); | ||
assert.strictEqual(stdout.trim(), '42'); | ||
assert.strictEqual(stderr, ''); | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'uyyt://1/index.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import 'uyyt://1/index2.mjs'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
export function load(url, context, nextLoad) { | ||
switch (url) { | ||
case 'uyyt://1/index.mjs': | ||
return { | ||
source: 'console.log("index.mjs!")', | ||
format: 'module', | ||
shortCircuit: true, | ||
}; | ||
case 'uyyt://1/index2.mjs': | ||
return { | ||
source: 'import c from "./sub.mjs"; console.log(c);', | ||
format: 'module', | ||
shortCircuit: true, | ||
}; | ||
case 'uyyt://1/sub.mjs': | ||
return { | ||
source: 'export default 42', | ||
format: 'module', | ||
shortCircuit: true, | ||
}; | ||
default: | ||
return nextLoad(url, context); | ||
} | ||
} |