2022-11-19 06:32:39 -05:00
|
|
|
import { createRequire } from "module";
|
|
|
|
|
|
|
|
console.log(typeof createRequire(import.meta.url));
|
|
|
|
console.log(typeof createRequire(new URL(import.meta.url)));
|
2022-11-29 00:13:14 -05:00
|
|
|
console.log(typeof createRequire("/"));
|
|
|
|
console.log(typeof createRequire("/foo"));
|
|
|
|
console.log(typeof createRequire("/foo/"));
|
|
|
|
console.log(typeof createRequire("c:\\foo"));
|
2022-11-19 06:32:39 -05:00
|
|
|
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);
|
|
|
|
}
|
2022-11-29 00:13:14 -05:00
|
|
|
try {
|
|
|
|
createRequire("foo");
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e.message);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
createRequire("./foo");
|
|
|
|
} catch (e) {
|
|
|
|
console.log(e.message);
|
|
|
|
}
|