mirror of
https://github.com/denoland/deno.git
synced 2025-08-03 18:38:33 +00:00
fix(ext/node): handle URL in createRequire (#16682)
This commit is contained in:
parent
763d492ed6
commit
7ab08130a0
6 changed files with 61 additions and 2 deletions
6
cli/tests/testdata/npm/create_require/main.out
vendored
Normal file
6
cli/tests/testdata/npm/create_require/main.out
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
[WILDCARD]
|
||||
function
|
||||
function
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received https://example.com/
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received https://example.com/
|
||||
The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 1
|
1
cli/tests/testdata/npm/create_require/main.ts
vendored
Normal file
1
cli/tests/testdata/npm/create_require/main.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
import "npm:@denotest/create-require@1.0.0";
|
19
cli/tests/testdata/npm/registry/@denotest/create-require/1.0.0/index.js
vendored
Normal file
19
cli/tests/testdata/npm/registry/@denotest/create-require/1.0.0/index.js
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { createRequire } from "module";
|
||||
|
||||
console.log(typeof createRequire(import.meta.url));
|
||||
console.log(typeof createRequire(new URL(import.meta.url)));
|
||||
try {
|
||||
createRequire("https://example.com/");
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
try {
|
||||
createRequire(new URL("https://example.com/"));
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
||||
try {
|
||||
createRequire(1);
|
||||
} catch (e) {
|
||||
console.log(e.message);
|
||||
}
|
6
cli/tests/testdata/npm/registry/@denotest/create-require/1.0.0/package.json
vendored
Normal file
6
cli/tests/testdata/npm/registry/@denotest/create-require/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "@denotest/create-require",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"main": "index.js"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue