Skip to content

fix: detect bound require reexports in cjs analysis#328

Merged
bartlomieju merged 4 commits intodenoland:mainfrom
Hajime-san:fix-reexport
Feb 23, 2026
Merged

fix: detect bound require reexports in cjs analysis#328
bartlomieju merged 4 commits intodenoland:mainfrom
Hajime-san:fix-reexport

Conversation

@Hajime-san
Copy link
Contributor

@Hajime-san Hajime-san commented Feb 14, 2026

Details in:

It seems that caused by the reexport patterns __export(require(...)) and __export(bound_ident) output by TypeScript were not detected in deno_ast layer.

@CLAassistant
Copy link

CLAassistant commented Feb 14, 2026

CLA assistant check
All committers have signed the CLA.

Comment on lines 17 to 18
/// Analyzes the script for CommonJS exports and re-exports based on similar
/// functionality to cjs-module-lexer (https://github.com/nodejs/cjs-module-lexer).
Copy link
Contributor Author

@Hajime-san Hajime-san Feb 14, 2026

Choose a reason for hiding this comment

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

Side note:
The cjs-module-lexer was replaced to merve recently.

Copy link
Member

Choose a reason for hiding this comment

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

Good find, any chance you could compare if there are cases this new library covers that we don't cover yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link

Choose a reason for hiding this comment

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

Why don't we merge the implementations? I can write a C API, and we can write a rust crate for Merve. Just like Ada?

Copy link
Member

Choose a reason for hiding this comment

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

Aligning the two implementations would be great. We have a ton of complications because we rely on swc for this.

Copy link

Choose a reason for hiding this comment

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

I'm more than happy to collaborate. I'll write C APIs for Merve. We can add Rust crate inside github.com/nodejs/merve

Copy link
Member

@dsherret dsherret Feb 24, 2026

Choose a reason for hiding this comment

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

That would be great! One thing is it would need to be able to be able to compile with cargo build --target=wasm32-unknown-unknown for us to use it though. We want our code to be accessible from JavaScript (ex. this does cjs export analysis: https://jsr.io/@deno/loader)

Copy link

Choose a reason for hiding this comment

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

We've tackled this same problem in Ada (in https://github.com/ada-url/rust/blob/main/build.rs). Probably we can reuse this once the time comes for adding Rust crate. I'll open a PR for C API soon. I'll reach out to you from X (x.com/yagiznizipli).

Copy link

Choose a reason for hiding this comment

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

As promised, here's the Rust crate: https://crates.io/crates/merve, and here's the pull-request: nodejs/merve#14

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! I'll try it out in the deno repo.

@bartlomieju bartlomieju requested a review from dsherret February 16, 2026 17:46
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@bartlomieju bartlomieju merged commit 69f1ceb into denoland:main Feb 23, 2026
2 checks passed
@Hajime-san Hajime-san deleted the fix-reexport branch February 25, 2026 03:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants