-
Notifications
You must be signed in to change notification settings - Fork 5.8k
feat: add --require run arg to support commonJS #31201
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -849,6 +849,11 @@ pub async fn run( | |
| node_resolution_sys, | ||
| node_resolver::NodeResolverOptions::default(), | ||
| )); | ||
| let require_modules = metadata | ||
| .require_modules | ||
| .iter() | ||
| .map(|key| root_dir_url.join(key).unwrap()) | ||
| .collect::<Vec<_>>(); | ||
|
Comment on lines
+852
to
+856
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍
Comment on lines
+852
to
+856
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace The Apply this diff: - let require_modules = metadata
- .require_modules
- .iter()
- .map(|key| root_dir_url.join(key).unwrap())
- .collect::<Vec<_>>();
+ let require_modules = metadata
+ .require_modules
+ .iter()
+ .map(|key| {
+ root_dir_url.join(key).with_context(|| {
+ format!("Failed to resolve require module: {}", key)
+ })
+ })
+ .collect::<Result<Vec<_>, _>>()?;
🤖 Prompt for AI Agents |
||
| let cjs_tracker = Arc::new(CjsTracker::new( | ||
| in_npm_pkg_checker.clone(), | ||
| pkg_json_resolver.clone(), | ||
|
|
@@ -859,6 +864,7 @@ pub async fn run( | |
| } else { | ||
| IsCjsResolutionMode::ExplicitTypeCommonJs | ||
| }, | ||
| require_modules.clone(), | ||
| )); | ||
| let npm_req_resolver = Arc::new(NpmReqResolver::new(NpmReqResolverOptions { | ||
| sys: sys.clone(), | ||
|
|
@@ -1088,6 +1094,7 @@ pub async fn run( | |
| permissions, | ||
| main_module, | ||
| preload_modules, | ||
| require_modules, | ||
| )?; | ||
|
|
||
| let exit_code = worker.run().await?; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, really confusing :D I need an explanation for the difference between
all_preload_modules(),preload_modules()andrequire_modules()- feels like we only need to latter two?