You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running Vite in library mode, it fails to build if there are types imported from relative paths. The issue has previously been raised in a discussion, but I believe it's likely to be a bug and would like to report it for visibility here. Thanks!
$ vite build --config vite.config.ts
vite v5.3.1 building for production...
✓ 2 modules transformed.
x Build failed in 16ms
error during build:
src/index.ts (1:18): "MyType" is not exported by "src/impl.ts", imported by "src/index.ts".
file: /Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/src/index.ts:1:18
1: export { MyClass, MyType } from "./impl.js";
^
at getRollupError (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/parseAst.js:396:41)
at error (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/parseAst.js:392:42)
at Module.error (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:13858:16)
at Module.getVariableForExportName (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:14022:29)
at Module.includeAllExports (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:14098:37)
at Graph.includeStatements (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:20033:36)
at Graph.build (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:19969:14)
at async file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:20611:13
at async catchUnfinishedHookActions (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:20119:16)
at async rollupInternal (file:///Users/donmccurdy/Demos/2024-06-20_vite_lib_ts/node_modules/rollup/dist/es/shared/node-entry.js:20606:5)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
I think this is working intended and Vite requires type import/export to be explicitly flagged as export { type MyType } since each ts file is transpiled independently.
src/index.ts:1:19 - error TS1205: Re-exporting a type when 'isolatedModules' is enabled requires using 'export type'.
1 export { MyClass, MyType } from "./impl.js";
~~~~~~
Describe the bug
When running Vite in library mode, it fails to build if there are types imported from relative paths. The issue has previously been raised in a discussion, but I believe it's likely to be a bug and would like to report it for visibility here. Thanks!
Reproduction
https://github.com/donmccurdy/2024-06-20_vite_lib_ts
Steps to reproduce
System Info
Used Package Manager
yarn
Logs
Validations
The text was updated successfully, but these errors were encountered: