vite icon indicating copy to clipboard operation
vite copied to clipboard

refactor(types): bundle client types

Open sapphi-red opened this issue 1 year ago • 5 comments

Description

Moved d.ts files under types to src/dep-types and src/types and use api-extractor to bundle client types.

This solves following issues:

  • prevent inconsistency between 'vite' and 'types/*'
    • #9962
    • #6433, #6456, #6531
  • types directory is not included in exports field but was included in package
    • it was not clear whether this is intended to be exported
  • types directory included dep types and it was a bit hard to differentiate types of deps or not
  • fixes #9827
    • Now vite/types/importMeta can be imported by vite/import-meta or import ViteImportMeta type from vite/client/types

This PR deprecates:

  • import 'vite/types/*'
    • Use import 'vite/client/types' or import 'vite'
  • import { /* import.meta.glob related types */ } from 'vite' (related: #9813)
    • Use import 'vite/client/types'

I added facade files under types directory so there should be backward compatibility.

Additional context

https://vitejs.dev/guide/api-plugin.html#typescript-for-custom-events This example was not working for server.ws.send('custom:foo', { msg: 'foo' }). So I updated the docs.


What is the purpose of this pull request?

  • [ ] Bug fix
  • [ ] New Feature
  • [ ] Documentation update
  • [x] Other

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

  • [x] Read the Contributing Guidelines.
  • [x] Read the Pull Request Guidelines and follow the Commit Convention.
  • [x] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • [x] 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.

sapphi-red avatar Sep 02 '22 11:09 sapphi-red

/ecosystem-ci run

patak-dev avatar Sep 02 '22 13:09 patak-dev

📝 Ran ecosystem CI: Open

suite result
astro :white_check_mark: success
iles :white_check_mark: success
ladle :white_check_mark: success
laravel :white_check_mark: success
marko :white_check_mark: success
nuxt-framework :white_check_mark: success
rakkas :white_check_mark: success
storybook :x: failure
svelte :white_check_mark: success
vite-plugin-ssr :white_check_mark: success
vite-setup-catalogue :white_check_mark: success
vitepress :x: failure
vitest :white_check_mark: success
windicss :white_check_mark: success

vite-ecosystem-ci[bot] avatar Sep 02 '22 13:09 vite-ecosystem-ci[bot]

Amazing work @sapphi-red! I think to play safe it is better to merge this one on the 3.2 beta, and we could delete the facade in v4.

patak-dev avatar Sep 02 '22 13:09 patak-dev

/ecosystem-ci run

sapphi-red avatar Sep 03 '22 08:09 sapphi-red

📝 Ran ecosystem CI: Open

suite result
astro :white_check_mark: success
iles :white_check_mark: success
ladle :white_check_mark: success
laravel :white_check_mark: success
marko :white_check_mark: success
nuxt-framework :white_check_mark: success
rakkas :white_check_mark: success
storybook :x: failure
svelte :white_check_mark: success
vite-plugin-ssr :white_check_mark: success
vite-setup-catalogue :white_check_mark: success
vitepress :white_check_mark: success
vitest :white_check_mark: success
windicss :white_check_mark: success

vite-ecosystem-ci[bot] avatar Sep 03 '22 08:09 vite-ecosystem-ci[bot]

Tried this PR inside Astro to see if it fixed #9827 and everything worked 👍 Nice work!

Princesseuh avatar Sep 19 '22 14:09 Princesseuh

/ecosystem-ci run

sapphi-red avatar Sep 24 '22 10:09 sapphi-red

📝 Ran ecosystem CI: Open

suite result
astro :white_check_mark: success
iles :white_check_mark: success
ladle :x: failure
laravel :x: failure
marko :white_check_mark: success
nuxt-framework :white_check_mark: success
rakkas :white_check_mark: success
storybook :white_check_mark: success
svelte :white_check_mark: success
vite-plugin-ssr :white_check_mark: success
vite-setup-catalogue :white_check_mark: success
vitepress :white_check_mark: success
vitest :white_check_mark: success
windicss :white_check_mark: success

vite-ecosystem-ci[bot] avatar Sep 24 '22 10:09 vite-ecosystem-ci[bot]