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

GenType: ensure JS import works regardless moduleResolution #6541

Merged
merged 2 commits into from
Dec 29, 2023

Conversation

cometkim
Copy link
Contributor

@cometkim cometkim commented Dec 28, 2023

As I and @fhammerschmidt discussed in fhammerschmidt/rescript-lang.org#1

This is a necessary change as we want to use the .res.js suffix instead of .bs.js. This is because import './Module.res' will be resolved as the original ReScript file instead of the generated Module.res.js file.

In #6182, I differentiated the case when moduleResolution: node to minimize output changes, but in fact, it is preferable always to use the full path if possible.

I added ModuleResolution1.res and ModuleResolution2.res tests to ensure that the moduleResolution option still applies to type import. But as they are always type-only modules since v11, the moduleResolution option doesn't make much sense anymore. This option should be removed again after the breaking change in #6196.

Copy link
Collaborator

@cristianoc cristianoc left a comment

Choose a reason for hiding this comment

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

Are there any consequences to existing projects?
Eg the way bundlers work: does this change affect the results in some cases?

@cometkim
Copy link
Contributor Author

This fixes cases where .res.js suffix could not be used due to the resolution issue, or cases where a custom rule had to be added to the bundler configuration.

@cristianoc cristianoc merged commit 1af8505 into rescript-lang:master Dec 29, 2023
@cometkim cometkim deleted the gentype-module-resolution branch December 29, 2023 22:05
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