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

Use NodeNext for Typescript module resolution #487

Merged
merged 2 commits into from
Oct 3, 2022

Conversation

akphi
Copy link
Contributor

@akphi akphi commented Oct 2, 2022

Fixes #486

@nene This is an extensive fix to upgrade the codebase to fully embrace ESM (i.e. specifying extensions in exports). This will make sql-formatter naturally work with Typescript projects which use module = Node16/NodeNext. Otherwise, we will have to find some other way to tweak package.json to make things work.

For example, uuid

https://github.com/uuidjs/uuid/blob/main/package.json

doesn't use the field type: module and fully specify exports but I personally think it's just makeshift, we might as well move to adopt ESM fully.


I have run yarn build and yarn test locally to make sure things work.
One thing you might not like is I don't think we could use alias like src anymore so I resolved all imports to use relative paths, sorry about that 🙏

@akphi akphi changed the title add extension to import to make code comply with ESM Use NodeNext for Typescript module resolution to make codebase fully comply ESM Oct 2, 2022
@akphi akphi changed the title Use NodeNext for Typescript module resolution to make codebase fully comply ESM Use NodeNext for Typescript module resolution Oct 2, 2022
@akphi akphi marked this pull request as draft October 2, 2022 22:53
@akphi akphi marked this pull request as ready for review October 2, 2022 23:24
@nene
Copy link
Collaborator

nene commented Oct 3, 2022

Thanks for the bug report and pull request.

It turns out that the ts-transform-paths plugin doesn't work with latest TypeScript. It should be compiling away these src/ paths, but it's not working. I tried applying some of the suggested patches, but they also did nothing. Given that this issue has remained unsolved for about a year, it's probably better to move away from using of that plugin.

@nene nene merged commit ad8dd40 into sql-formatter-org:master Oct 3, 2022
@akphi akphi deleted the ian branch October 3, 2022 12:42
@nene nene mentioned this pull request Oct 3, 2022
@nene
Copy link
Collaborator

nene commented Oct 3, 2022

These fixes, plus a few more, are now released as 11.0.1

@akphi
Copy link
Contributor Author

akphi commented Oct 3, 2022

These fixes, plus a few more, are now released as 11.0.1

Fantastic! Thank you so much!

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.

11.0.0 does not work well with Typescript module=NodeNext/Node16
2 participants