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

fixed an error using import syntax when the moduleResolution field is nodeNext in tsconfig.json #1521

Closed
wants to merge 5 commits into from

Conversation

mlgq
Copy link

@mlgq mlgq commented Apr 25, 2024

This is an awesome project! It helped me a lot with the work I was doing.

type: "module" in package.json is necessary for local development, but not useful for online package. Also using import syntax when the moduleResolution field in tsconfig.json is nodeNext results in an error.

This PR uses npm hooks to remove the type field in package.json before the package is published, and leave the locally development code unchanged.

@mlgq mlgq changed the title fixed an error using import syntax when the field is in tsconfig.json fixed an error using import syntax when the moduleResolution field is nodeNext in tsconfig.json Apr 26, 2024
@fabiosantoscode
Copy link
Collaborator

This is an ESM package with a CJS backup (dist/bundle.min.js) for older node versions. Removing "type": "module" makes it just CJS!

So I can't accept this approach, but I want to understand what the problem was.

Is it the case that typescript's nodeNext finds this setup too weird? After all, there's a sub-package just for bundle.min.js.

@mlgq
Copy link
Author

mlgq commented Apr 28, 2024

Removing "type": "module" makes it just CJS!

Okay, I'm wrong brother. I focused on Typescript but ignored Node. Although this field causes a ts error, but it can be blocked by @ts-ignore

@mlgq mlgq closed this Apr 28, 2024
@mlgq
Copy link
Author

mlgq commented Apr 28, 2024

done

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.

None yet

2 participants