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

fix: use file extensions on type imports so they work with moduleResolution: 'node16' #13947

Merged
merged 2 commits into from
Jul 25, 2023

Conversation

Princesseuh
Copy link
Contributor

Description

At Astro we're currently (attempting) to migrate our tsconfig.json to moduleResolution: 'node16'. We got it mostly figured out, apart from one thing: We can't import types from Vite. Investigating led me to realize that it was because Vite's type imports don't have file extensions, so they always resolve as any under moduleResolution: 'node16'. I tried to workaround this by importing the files in the types folder individually, but they're not part of the exports map so.

This PR adds file extensions to all the imports, easy enough. I tested it downstream and it works. Per #11552, it seems like many users were patching Vite manually for this already.

Additional context

Downstream is currently not able to migrate to moduleResolution: 'node16', so this is kinda blocking.


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the Pull Request Guidelines and follow the PR Title Convention.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@stackblitz
Copy link

stackblitz bot commented Jul 25, 2023

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@Princesseuh Princesseuh changed the title Use file extensions on type imports so they work with moduleResolution: 'node16' fix: Use file extensions on type imports so they work with moduleResolution: 'node16' Jul 25, 2023
@Princesseuh Princesseuh marked this pull request as draft July 25, 2023 10:31
@bluwy bluwy added the p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority) label Jul 25, 2023
@Princesseuh
Copy link
Contributor Author

Hmm, I'm not too sure why the CI is yelling at me. The same tests works fine in local:
image
(and the build works etc)

@Princesseuh Princesseuh changed the title fix: Use file extensions on type imports so they work with moduleResolution: 'node16' fix: use file extensions on type imports so they work with moduleResolution: 'node16' Jul 25, 2023
@Princesseuh Princesseuh marked this pull request as ready for review July 25, 2023 11:03
@patak-dev
Copy link
Member

/ecosystem-ci run

@vite-ecosystem-ci
Copy link

vite-ecosystem-ci bot commented Jul 25, 2023

📝 Ran ecosystem CI: Open

suite result
analogjs ❌ failure
astro ✅ success
histoire ❌ failure
iles ❌ failure
ladle ✅ success
laravel ✅ success
marko ✅ success
nuxt ✅ success
nx ✅ success
previewjs ✅ success
qwik ✅ success
rakkas ✅ success
sveltekit ✅ success
unocss ✅ success
vite-plugin-pwa ✅ success
vite-plugin-ssr ✅ success
vite-plugin-react ✅ success
vite-plugin-react-pages ❌ failure
vite-plugin-react-swc ✅ success
vite-plugin-svelte ✅ success
vite-plugin-vue ✅ success
vite-setup-catalogue ✅ success
vitepress ✅ success
vitest ✅ success

Copy link
Member

@patak-dev patak-dev left a comment

Choose a reason for hiding this comment

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

Same projects are currently failing against main. Let's merge this one. Thanks @Princesseuh!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-downstream-blocker Blocking the downstream ecosystem to work properly (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants