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

feat(typescript): align with --moduleResolution=bundler #22887

Merged
merged 1 commit into from May 9, 2023

Conversation

dgozman
Copy link
Contributor

@dgozman dgozman commented May 8, 2023

This relaxes import requirements and allows importing .ts files without an extension in CJS and ESM modes.

Fixes #22169.

if (!resolved.endsWith(ext))
continue;
for (const other of others) {
const modified = resolved.substring(0, resolved.length - ext.length) + other;
Copy link
Member

Choose a reason for hiding this comment

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

Looks like you could move it outside of the loop: resolved.substring(0, resolved.length - ext.length)

This relaxes import requirements and allows importing `.ts` files without
an extenstion in CJS and ESM modes.
@dgozman dgozman merged commit cd49f5c into microsoft:main May 9, 2023
17 of 19 checks passed
@kristojorg
Copy link
Contributor

Is there any comment on when this will be released?

@dgozman
Copy link
Contributor Author

dgozman commented May 23, 2023

@kristojorg Should be already available in v1.34.

@kristojorg
Copy link
Contributor

Ah I see it is, didn't see it in the changelog but it's working. I am wondering, however, if directory imports are meant to be supported by this as well? Outside Playwright in my ESModules app I can import directories /dir instead of /dir/index, but in playwright I'm not able to. I no longer have to import /dir/index.ts but I do have to import /dir/index. Is this intended?

@kristojorg
Copy link
Contributor

It does look like TS intends to enable the directory imports according to the bundler PR: microsoft/TypeScript#51669

@dgozman
Copy link
Contributor Author

dgozman commented May 23, 2023

@kristojorg Yeah, it does not work with directory importing, good point! Could you please file a new issue? We'll address it for the next release.

kristojorg added a commit to kristojorg/playwright that referenced this pull request May 24, 2023
This updates previous work in microsoft#22887 to align more fully with `--moduleResolution=bundler`, allowing index files to be imported with the /index extension
@kristojorg
Copy link
Contributor

I went ahead and added a PR: #23254

kristojorg added a commit to kristojorg/playwright that referenced this pull request Jun 5, 2023
This updates previous work in microsoft#22887 to align more fully with `--moduleResolution=bundler`, allowing index files to be imported with the /index extension
dgozman added a commit that referenced this pull request Jun 5, 2023
This updates previous work in #22887 to align more fully with
`--moduleResolution=bundler`, allowing index files to be imported with
the /index extension

---------

Signed-off-by: Kristo Jorgenson <kristojorg@users.noreply.github.com>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
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.

[Feature] Support TypeScript's --moduleResolution bundler
3 participants