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

Add ESM Support #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

daniel-nagy
Copy link

When using format: "esm", with esbuild, this plugin will produce runtime errors because TypeScript will transpile the module to CommonJS. You'll even get a warning from esbuild:

[WARNING] The CommonJS "exports" variable is treated as a
global variable in an ECMAScript module and may not work as expected

The canonical way to get TypeScript to treat input files as ESM is to use the .mts file extension. However, this plugin will filter those files and they won't be compiled by typescript. To fix this I updated the filter regex to allow .mts and .mtsx.

In addition, a lot of folks likely do not use the .mts extension and renaming the files of a large project would likely be tedious so I added an option to force TypeScript to treat the files as ESM.

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.

1 participant