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

Ideas about how to significantly improve performance #201

Open
SukkaW opened this issue Dec 11, 2024 · 3 comments
Open

Ideas about how to significantly improve performance #201

SukkaW opened this issue Dec 11, 2024 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@SukkaW
Copy link
Collaborator

SukkaW commented Dec 11, 2024

Currently, when eslint-plugin-import-x finds an import, it will resolve the real path of the module (through the eslint import resolvers), read the file, and then parse the module into the AST using the configured parsers (import-x/parser) or the default parser (ruleContext.parserPath). Then eslint-plugin-import-x tried to extract all exports/imports by walking through AST.

Parse any referenced modules are very heavy tasks, resulting eslint-plugin-import-x being slow. But if we use something like es-module-lexer or cjs-module-lexer to scan the imports/exports we skip the entire parsing-into-AST process and significantly improve performance for a few rules.

@SukkaW
Copy link
Collaborator Author

SukkaW commented Dec 11, 2024

We have es-module-lexer that works for ESM and cjs-module-lexer for CommonJS. But we still need lexers for JSX / TypeScript / TSX (or even flow). I still want TypeScript to benefit from this.

Oxc says they will have one for ESM and TypeScript/TSX, but they won't support the CJS.

And we also have rs-module-lexer @fz6m.

@SukkaW SukkaW pinned this issue Dec 11, 2024
@SukkaW SukkaW changed the title Ideas about how to significantly improve performance of some rules Ideas about how to significantly improve performance Dec 11, 2024
@silverwind
Copy link

silverwind commented Dec 11, 2024

We have es-module-lexer that works for ESM and cjs-module-lexer for CommonJS. But we still need lexers for JSX / TypeScript / TSX (or even flow). I still want TypeScript to benefit from this.

For Typescript could strip types with https://github.com/nodejs/amaro or the underlying https://swc.rs/docs/references/wasm-typescript and then pass the result to the lexers. Would be interesting to hear about the performance of that approach vs. full AST parsing.

@SukkaW
Copy link
Collaborator Author

SukkaW commented Dec 12, 2024

For Typescript could strip types with https://github.com/nodejs/amaro or the underlying https://swc.rs/docs/references/wasm-typescript and then pass the result to the lexers.

But IMHO it might not work with export =.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants