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

support newer moduleResolution kinds, update build to TS 5.x #453

Merged
merged 10 commits into from
Jul 17, 2023

Conversation

ezolenko
Copy link
Owner

@ezolenko ezolenko commented Jun 20, 2023

Summary

Fixes #437

Details

  • keeping node* moduleResolution option as is ("node", "node16", "nodenext", "bundler")
  • overriding "classic" and empty to Node10 (old behavior was overriding everything to Node10)

@ezolenko ezolenko marked this pull request as ready for review June 23, 2023 16:08
@agilgur5 agilgur5 changed the title Bug/437 2 add module: 'ES2022', update moduleResolution default to node16 Jun 30, 2023
@agilgur5 agilgur5 changed the title add module: 'ES2022', update moduleResolution default to node16 add module: 'ES2022', update moduleResolution default to node16, update to to TS 5.x Jun 30, 2023
@agilgur5 agilgur5 changed the title add module: 'ES2022', update moduleResolution default to node16, update to to TS 5.x add module: 'ES2022', update moduleResolution default to node16, update build to TS 5.x Jun 30, 2023
@agilgur5 agilgur5 changed the title add module: 'ES2022', update moduleResolution default to node16, update build to TS 5.x update moduleResolution default to node16, update build to TS 5.x Jun 30, 2023
@agilgur5 agilgur5 changed the title update moduleResolution default to node16, update build to TS 5.x update moduleResolution overrides, update build to TS 5.x Jun 30, 2023
@agilgur5 agilgur5 changed the title update moduleResolution overrides, update build to TS 5.x support moduleResolution overrides, update build to TS 5.x Jun 30, 2023
@agilgur5 agilgur5 changed the title support moduleResolution overrides, update build to TS 5.x support newer moduleResolution kinds, update build to TS 5.x Jun 30, 2023
Comment on lines 34 to 36
case tsModule.ModuleResolutionKind.Bundler:
default:
overrides.moduleResolution = tsModule.ModuleResolutionKind.Node10;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm gonna need to review this in a lot more detail (need to catch up on TS changes since 5.x hit GA and refresh myself on this codebase), but I mentioned mjs support and bundler in #434 (comment).

bundler actually seemed the most appropriate at the time (since Rollup is a bundler) for Node16+, particularly due to the file extension issues. That's actually why I didn't implement support for mjs / cjs earlier because the file extension requirement could break many things (that and no user requested it)

Copy link
Owner Author

@ezolenko ezolenko Jun 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, this basically lowest effort to let users use more moduleResolution values without figuring out exactly what the differences are.

Copy link
Collaborator

@agilgur5 agilgur5 Jul 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I think bundler should not be overwritten either. With that change and README modifications about this, I think we could approve and merge this in.

Without tests though, we won't be able to confirm some of the behavior of node16 / nodeNext (particularly around file extensions) -- it is possible we may need to override those two to bundler as well

README.md Outdated Show resolved Hide resolved
Copy link
Collaborator

@agilgur5 agilgur5 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mostly LGTM now, just left a tiny comment style comment. we'll ofc iterate on the docs as we test more and get feedback

README.md Outdated Show resolved Hide resolved
dist/rollup-plugin-typescript2.cjs.js Outdated Show resolved Hide resolved
ezolenko and others added 2 commits July 17, 2023 09:03
@ezolenko ezolenko merged commit ce2038d into master Jul 17, 2023
@ezolenko ezolenko deleted the bug/437_2 branch July 17, 2023 15:22
@agilgur5 agilgur5 added the kind: feature New feature or request label Jul 18, 2023
@agilgur5
Copy link
Collaborator

agilgur5 commented Sep 28, 2023

@PetarKirov this PR only changed the moduleResolution options, not the module options.

There are potentially additional changes needed for the module options, but for the most part, we'd likely just be overriding it to ESNext or something. As Rollup requires ESM throughout, CJS output would be incompatible (TS can output CJS for module node16 and nodenext). So the error is more or less still accurate.

If you need node16 for other tooling, you can use tsconfigOverride to set esnext or es2020 for rpt2 specifically.

@raphael-theriault-swi
Copy link

This doesn't work with either node16 or nodenext since they require the module field to match

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind: feature New feature or request solution: needs test This issue requires creating a test to assuredly close out topic: TS version Related to a change in a TS version version: minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support moduleResolution: 'node16'+ for package.json exports
5 participants