-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ModuleKind
to graph and be returned by Resolver.resolve
#97
Comments
I would prefer something just like a field named enum ModuleKind {
Amd,
CommonJs,
Esm,
Script,
SystemJs,
Umd,
} While I don't believe The biggest question I have is how this would be used. I assume the use case is to interrogate the graph when loading a module to determine how it should be loaded? |
I was just in the code on another purpose... we would need to consider how the above would related to this, and whether we would merge all of this into a single tagged enum, or restructure it in some way so that #[derive(Debug, Clone, Serialize)]
#[serde(untagged)]
pub enum Module {
Es(Box<EsModule>),
Synthetic(Box<SyntheticModule>),
} All the above would be effectively the same struct as |
@bartlomieju and I discussed. It is used in the situation where when loading the module into a runtime, it needs to be interrogated, and for example if an ESM module is loading a CJS module, it needs to go through a process to "convert" the CJS module to an ESM module on the fly. |
This should be named |
Resolver.resolve
return a ModuleType
ModuleKind
to graph and be returned by Resolver.resolve
I've started working on this... I am going to collapse everything into a single |
Was talking to @bartlomieju today so this is a quick summary of the discussion. For denoland/deno#12648 we'll need a way to identify if
.js
/MediaType::JavaScript
files are CJS or MJS. This can be determined a number of ways in node (ex. a package.json having say"type": "module"
) which is information that's known by the node compat resolvers in the CLI. Perhaps it would be useful to introduce aModuleType
enum that has membersModuleType::Cjs
&ModuleType::Mjs
and theResolver.resolve
method could return that value which would then be stored in the graph.The text was updated successfully, but these errors were encountered: