Skip to content

Commit

Permalink
Add support for enabling .mjs extension resolving (#6525)
Browse files Browse the repository at this point in the history
### Description

Adds support for resolving `.mjs` files without the extension. This is
something we do currently in Next.js.

<!--
  ✍️ Write a short summary of your work.
  If necessary, include relevant screenshots.
-->

### Testing Instructions

<!--
  Give a quick description of steps to test your changes.
-->
  • Loading branch information
timneutkens committed Nov 22, 2023
1 parent 94df485 commit 3905991
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/turbopack/src/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ async fn base_resolve_options(
ext.push(".jsx".to_string());
}
ext.push(".js".to_string());
if opt.enable_mjs_extension {
ext.push(".mjs".to_string());
}
if opt.enable_node_native_modules {
ext.push(".node".to_string());
}
Expand Down
3 changes: 3 additions & 0 deletions crates/turbopack/src/resolve_options_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ pub struct ResolveOptionsContext {
#[serde(default)]
pub enable_node_native_modules: bool,
#[serde(default)]
// Enable resolving of .mjs files without the .mjs extension
pub enable_mjs_extension: bool,
#[serde(default)]
/// Enable resolving of the node_modules folder when within the provided
/// directory
pub enable_node_modules: Option<Vc<FileSystemPath>>,
Expand Down

1 comment on commit 3905991

@vercel
Copy link

@vercel vercel bot commented on 3905991 Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.