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

[@vitejs/plugin-vue] Type definition generation in library mode is broken #5044

Closed
7 tasks done
mseele opened this issue Sep 23, 2021 · 3 comments
Closed
7 tasks done

Comments

@mseele
Copy link

mseele commented Sep 23, 2021

Describe the bug

@vitejs/plugin-vue version 1.8.0 broke type definition generation in library mode.
Using version 1.7.1 the generation via rollup-plugin-typescript2 works like expected. From version 1.8.0 it does not longer generate type definitions for components but list them in the index.d.ts file.

Reproduction

  • Checkout https://github.com/mseele/vite-typescript2-output-broken and run yarn install and then yarn build

  • In the dist directory a index.d.ts file will be generated with the reference to ./components/Hello.vue

  • The ./components/Hello.vue.d.ts file will not be generated

  • Change @vitejs/plugin-vue in package.json to 1.7.1, run yarn install and then yarn build again

  • Everything works as expected: the missing ./components/Hello.vue.d.ts file has been generated

System Info

System:
    OS: Windows 10 10.0.19043
    CPU: (12) x64 Intel(R) Xeon(R) CPU E5-1650 v4 @ 3.60GHz
    Memory: 16.74 GB / 31.92 GB
  Binaries:
    Node: 14.17.6 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 93.0.4577.82
    Edge: Spartan (44.19041.1023.0), Chromium (93.0.961.52)
    Internet Explorer: 11.0.19041.1202
  npmPackages:
    @vitejs/plugin-vue: 1.7.1 => 1.7.1
    vite: 2.5.10 => 2.5.10

Used Package Manager

yarn

Logs

yarn run v1.22.5
$ vue-tsc --noEmit && vite build --debug
  vite:config bundled config file loaded in 658ms +0ms
  vite:config using resolved config: {
  vite:config   resolve: { dedupe: undefined, alias: [ [Object], [Object], [Object] ] },
  vite:config   build: {
  vite:config     target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
  vite:config     polyfillModulePreload: true,
  vite:config     outDir: 'dist',
  vite:config     assetsDir: 'assets',
  vite:config     assetsInlineLimit: 4096,
  vite:config     cssCodeSplit: false,
  vite:config     sourcemap: true,
  vite:config     rollupOptions: { external: [Array], output: [Object] },
  vite:config     commonjsOptions: { include: [Array], extensions: [Array] },
  vite:config     dynamicImportVarsOptions: { warnOnError: true, exclude: [Array] },
  vite:config     minify: false,
  vite:config     terserOptions: {},
  vite:config     write: true,
  vite:config     emptyOutDir: null,
  vite:config     manifest: false,
  vite:config     lib: {
  vite:config       entry: 'C:\\dev\\git\\vite-typescript2-output-broken\\src\\index.ts',
  vite:config       name: 'Vite TS Output Broken',
  vite:config       fileName: [Function: fileName]
  vite:config     },
  vite:config     ssr: false,
  vite:config     ssrManifest: false,
  vite:config     brotliSize: true,
  vite:config     chunkSizeWarningLimit: 500,
  vite:config     watch: null
  vite:config   },
  vite:config   plugins: [
  vite:config     'alias',
  vite:config     'rpt2',
  vite:config     'vite:modulepreload-polyfill',
  vite:config     'vite:resolve',
  vite:config     'vite:html',
  vite:config     'vite:css',
  vite:config     'vite:esbuild',
  vite:config     'vite:json',
  vite:config     'vite:wasm',
  vite:config     'vite:worker',
  vite:config     'vite:asset',
  vite:config     'vite:vue',
  vite:config     'vite:define',
  vite:config     'vite:css-post',
  vite:config     'vite:build-html',
  vite:config     'commonjs',
  vite:config     'vite:data-uri',
  vite:config     'rollup-plugin-dynamic-import-variables',
  vite:config     'asset-import-meta-url',
  vite:config     'vite:import-analysis',
  vite:config     'vite:esbuild-transpile',
  vite:config     'vite:reporter',
  vite:config     'load-fallback'
  vite:config   ],
  vite:config   define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
  vite:config   ssr: { external: [ 'vue', '@vue/server-renderer' ] },
  vite:config   configFile: 'C:/dev/git/vite-typescript2-output-broken/vite.config.ts',
  vite:config   configFileDependencies: [ 'vite.config.ts' ],
  vite:config   inlineConfig: {
  vite:config     root: undefined,
  vite:config     base: undefined,
  vite:config     mode: undefined,
  vite:config     configFile: undefined,
  vite:config     logLevel: undefined,
  vite:config     clearScreen: undefined,
  vite:config     build: {}
  vite:config   },
  vite:config   root: 'C:/dev/git/vite-typescript2-output-broken',
  vite:config   base: '/',
  vite:config   publicDir: 'C:\\dev\\git\\vite-typescript2-output-broken\\public',
  vite:config   cacheDir: 'C:\\dev\\git\\vite-typescript2-output-broken\\node_modules\\.vite',
  vite:config   command: 'build',
  vite:config   mode: 'production',
  vite:config   isProduction: true,
  vite:config   server: { fs: { strict: undefined, allow: [Array] } },
  vite:config   env: { BASE_URL: '/', MODE: 'production', DEV: false, PROD: true },
  vite:config   assetsInclude: [Function: assetsInclude],
  vite:config   logger: {
  vite:config     hasWarned: false,
  vite:config     info: [Function: info],
  vite:config     warn: [Function: warn],
  vite:config     warnOnce: [Function: warnOnce],
  vite:config     error: [Function: error],
  vite:config     clearScreen: [Function: clearScreen],
  vite:config     hasErrorLogged: [Function: hasErrorLogged]
  vite:config   },
  vite:config   createResolver: [Function: createResolver],
  vite:config   optimizeDeps: { esbuildOptions: { keepNames: undefined } }
  vite:config } +8ms
vite v2.5.10 building for production...
✓ 3 modules transformed.
dist/index.d.ts                    0.06 KiB
dist/vite-ts-output-broken.es.js   0.73 KiB / brotli: 0.35 KiB
dist/vite-ts-output-broken.es.js.map 0.84 KiB
dist/index.d.ts                     0.06 KiB
dist/vite-ts-output-broken.umd.js   1.19 KiB / brotli: 0.51 KiB
dist/vite-ts-output-broken.umd.js.map 0.86 KiB
Done in 18.48s.

Validations

@mseele mseele changed the title Type definition generation in library mode is broken [@vitejs/plugin-vue] Type definition generation in library mode is broken Sep 23, 2021
@bluwy
Copy link
Member

bluwy commented Mar 20, 2022

Still reproducible in plugin-vue 2.2.4. But I'm not sure what needs to be fixed here.

@sapphi-red
Copy link
Member

This is caused by this change.
93d9a2d#diff-50999b66ad3fff48fd315417d4f8c98741da9f85a0fa6bb4ba212cc8f8bac967L271-R267

Before when it is not during dev, it went through other plugins. But after it does not.

jods4 added a commit to jods4/vite that referenced this issue Apr 26, 2022
Partial revert of 93d9a2d
When building, TS scripts must not be inlined so that loaders (e.g. rollup-plugin-typescript2) are correctly applied.

Fixes vitejs#5044, vitejs#5795, vitejs#7908
@patak-dev
Copy link
Member

Fixed by #7909

@github-actions github-actions bot locked and limited conversation to collaborators May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants