mirror of
https://github.com/denoland/deno.git
synced 2025-03-04 01:44:26 -05:00
fix: stub node:module.register()
(#24965)
This is commonly used to register loading non standard file types. But some libs also register TS loaders which Deno supports natively, like the npm `payload` package. This PR unblocks those. Fixes https://github.com/denoland/deno/issues/24902
This commit is contained in:
parent
fc02303842
commit
f474c4f4ff
2 changed files with 23 additions and 0 deletions
|
@ -1293,6 +1293,19 @@ export function findSourceMap(_path) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string | URL} _specifier
|
||||||
|
* @param {string | URL} _parentUrl
|
||||||
|
* @param {{ parentURL: string | URL, data: any, transferList: any[] }} [_options]
|
||||||
|
*/
|
||||||
|
export function register(_specifier, _parentUrl, _options) {
|
||||||
|
// TODO(@marvinhagemeister): Stub implementation for programs registering
|
||||||
|
// TypeScript loaders. We don't support registering loaders for file
|
||||||
|
// types that Deno itself doesn't support at the moment.
|
||||||
|
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
export { builtinModules, createRequire, isBuiltin, Module };
|
export { builtinModules, createRequire, isBuiltin, Module };
|
||||||
export const _cache = Module._cache;
|
export const _cache = Module._cache;
|
||||||
export const _extensions = Module._extensions;
|
export const _extensions = Module._extensions;
|
||||||
|
|
|
@ -6,6 +6,11 @@ import {
|
||||||
findSourceMap,
|
findSourceMap,
|
||||||
isBuiltin,
|
isBuiltin,
|
||||||
Module,
|
Module,
|
||||||
|
// @ts-ignore Our internal @types/node is at v18.16.19 which predates
|
||||||
|
// this change. Updating it is difficult due to different types in Node
|
||||||
|
// for `import.meta.filename` and `import.meta.dirname` that Deno
|
||||||
|
// provides.
|
||||||
|
register,
|
||||||
} from "node:module";
|
} from "node:module";
|
||||||
import { assert, assertEquals } from "@std/assert";
|
import { assert, assertEquals } from "@std/assert";
|
||||||
import process from "node:process";
|
import process from "node:process";
|
||||||
|
@ -99,3 +104,8 @@ Deno.test("[node/module builtinModules] has 'module' in builtins", () => {
|
||||||
Deno.test("[node/module findSourceMap] is a function", () => {
|
Deno.test("[node/module findSourceMap] is a function", () => {
|
||||||
assertEquals(findSourceMap("foo"), undefined);
|
assertEquals(findSourceMap("foo"), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// https://github.com/denoland/deno/issues/24902
|
||||||
|
Deno.test("[node/module register] is a function", () => {
|
||||||
|
assertEquals(register("foo"), undefined);
|
||||||
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue