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

Rewrite esm-shim plugin #444

Merged
merged 4 commits into from
Feb 4, 2024
Merged

Rewrite esm-shim plugin #444

merged 4 commits into from
Feb 4, 2024

Conversation

huozhi
Copy link
Owner

@huozhi huozhi commented Feb 4, 2024

What

Drop the @rollup/plugin-esm-shim plugin and rewrite one with AST parsing, due to it causes issues by the regex matching and replacing with shims. It cannot optionally inject the shims based on the usage.

Improvement

The new plugin is using the AST parsing, and based on the cjs API you're using we inject the certain ones of polyfill and replace the usage. If you only use one, we won't insert two polyfills.
It can handle all the import paths, @rollup/plugin-esm-shim will break with @scope module path, but AST parsing won't have that problem

Resolves #442

@huozhi huozhi merged commit 3bd931f into main Feb 4, 2024
3 checks passed
@huozhi huozhi deleted the replace-esm-shim branch February 4, 2024 20:56
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.

Replace esm shim plugin
1 participant