Skip to content
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

New tool: oxc_module_lexer #2650

Merged
merged 1 commit into from Mar 9, 2024
Merged

New tool: oxc_module_lexer #2650

merged 1 commit into from Mar 9, 2024

Conversation

Boshen
Copy link
Member

@Boshen Boshen commented Mar 9, 2024

Oxc Module Lexer

This is not a lexer. The name "lexer" is used for easier recognition.

es-module-lexer

Outputs the list of exports and locations of import specifiers, including dynamic import and import meta handling.

Does not have any limitations mentioned in es-module-lexer.

I'll also work on the following cases to make this feature complete.

cjs-module-lexer

  • TODO

Benchmark

This is 2 times slower than es-module-lexer, but will be significantly faster when TypeScript is processed.

The difference is around 10ms vs 20ms on a large file (700k).

@Boshen Boshen merged commit 32303b2 into main Mar 9, 2024
23 checks passed
@Boshen Boshen deleted the module-lexer branch March 9, 2024 15:23
Copy link

codspeed-hq bot commented Mar 9, 2024

CodSpeed Performance Report

Merging #2650 will not alter performance

Comparing module-lexer (49a4e6e) with main (66a64df)

Summary

✅ 29 untouched benchmarks

@pastelsky
Copy link

Will this also cover both imports and exports for CJS?
cjs-module-lexer doesn't seem to support the former unless re-exported.

@Boshen
Copy link
Member Author

Boshen commented Mar 10, 2024

Will this also cover both imports and exports for CJS? cjs-module-lexer doesn't seem to support the former unless re-exported.

Depending on the use case, it's difficult to statically analyze cjs ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants