mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 02:48:24 +00:00
refactor: allow to provide polyfills for Node modules from the snapshot (#17706)
This commit does preparatory work to allow snapshotting Node.js compatibility layer, that currently lives in `std/node`. The logic was changed to allow loading some modules from the snapshot and some from the remote URL. Additionally "module_es_shim.js" that provides exports for "node:module" is now snapshotted.
This commit is contained in:
parent
9ea899afa7
commit
ed3a7ce2f7
4 changed files with 83 additions and 69 deletions
|
@ -77,13 +77,11 @@ impl CliModuleLoader {
|
|||
specifier: &ModuleSpecifier,
|
||||
maybe_referrer: Option<ModuleSpecifier>,
|
||||
) -> Result<ModuleCodeSource, AnyError> {
|
||||
if specifier.as_str() == "node:module" {
|
||||
return Ok(ModuleCodeSource {
|
||||
code: deno_runtime::deno_node::MODULE_ES_SHIM.to_string(),
|
||||
found_url: specifier.to_owned(),
|
||||
media_type: MediaType::JavaScript,
|
||||
});
|
||||
}
|
||||
// TODO(bartlomieju): uncomment, when all `node:` module have been
|
||||
// snapshotted
|
||||
// if specifier.scheme() == "node" {
|
||||
// unreachable!("Node built-in modules should be handled internally.");
|
||||
// }
|
||||
let graph = self.ps.graph();
|
||||
match graph.get(specifier) {
|
||||
Some(deno_graph::Module {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue