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
Since 1.0, this plugin is incompatible with vite-tsconfig-paths
#70
Comments
Unfortunately, this requires a workaround to work with our "@/foo/bar"-style imports. I believe this is a regression; see: qmhc/vite-plugin-dts#70
Only one different (a breaking change) between v1.0 and v0.9.10: extract a About the limitation of working together with It may be some other reasons to make this issue, could you provide a reproduce repo? We can discuss some others workaround. This also bothers me in recent period that how to get aliases info and transform the alias paths outside the |
I see. I suppose, then, that our configuration "just worked" (by happy coincidence) prior to 1.0 because I confess that I don't understand the documentation for "module": "./dist/index.es.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"import": "./dist/index.es.js"
},
"./style.css": "./dist/style.css"
}, Our {
"compilerOptions": {
"composite": true,
"declaration": true,
"declarationDir": "./dist",
"declarationMap": true,
"sourceMap": true,
"target": "ESNext",
"useDefineForClassFields": true,
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": false,
"skipLibCheck": false,
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"moduleResolution": "Node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react-jsx",
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"alwaysStrict": true,
"exactOptionalPropertyTypes": true,
"noFallthroughCasesInSwitch": true,
"noImplicitAny": true,
"noImplicitOverride": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noPropertyAccessFromIndexSignature": true,
"noUncheckedIndexedAccess": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"plugins": [
{
"name": "typescript-eslint-language-service"
}
],
"types": ["@honkhonk/vite-plugin-svgr/client"],
"baseUrl": "./",
"paths": {
"@/*": ["./src/*"]
}
},
"include": ["./src"]
} and our import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import svgr from "@honkhonk/vite-plugin-svgr";
import checker from "vite-plugin-checker";
import dts from "vite-plugin-dts";
import path from "path";
import tsconfigPaths from "vite-tsconfig-paths";
import OptimizationPersist from "vite-plugin-optimize-persist";
import PkgConfig from "vite-plugin-package-config";
import { name, version } from "./package.json";
// https://vitejs.dev/config/
export default defineConfig({
// Recent versions of the vite-plugin-dts plugin require this. See:
// https://github.com/qmhc/vite-plugin-dts/issues/70
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
}
},
plugins: [
checker({
typescript: true,
}),
dts({
insertTypesEntry: true,
}),
react(),
svgr(),
tsconfigPaths(),
PkgConfig(),
OptimizationPersist(),
],
// Don't write to node_modules, in case someday we can get it from Nix.
cacheDir: ".vite",
// This is a workspace, so we need to be able to serve node_modules
// from the project root in dev mode.
server: {
fs: {
allow: ["../.."],
},
},
build: {
sourcemap: true,
// Library mode settings.
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: name,
formats: ["es"],
fileName: (format) => `index.${format}.js`,
},
rollupOptions: {
// XXX dhess: do we need to add Tailwind UI deps here?
external: ["react", "react-dom", "react-router-dom"],
},
},
define: {
pkgJson: { name, version },
},
}); The |
You can try to add
dts({
entryRoot: path.resolve(__dirname),
insertTypesEntry: true
}) For example, here is a emitted file After v1.0, if |
Ahh, thanks. I was using just plain "src" but that was resolving from the root of the monorepo. I will try this and report back. |
any update on this? Could not make it work. It's still generating the declarations like this: export { default as Filter } from '@templates/Filter';
export type { IFilter, IFilterPayload } from '@common/interfaces/filter'; the |
Just ran into this issue as well. Has anyone found a work around? |
I got this to work in our project with the following settings: viteDts({
entryRoot: 'src',
tsconfigPath: resolve(__dirname, 'tsconfig.build.json'),
// was already using the above settings
compilerOptions: {
baseUrl: '.' // secret sauce, could go in your actual tsconfig too probably
}
}) Figured out this was missing by taking a peek here: Lines 284 to 300 in 9262d01
This plugin won't write the updated aliased paths without |
Hi,
The vite-tsconfig-paths plugin allows you to use TypeScript's path mapping feature without any additional
vite.config.ts
configuration. In other words, you can use nice"@/foo/bar"
style imports with just thetsconfig.json
configuration shown here in your own example:vite-plugin-dts/example/tsconfig.json
Line 16 in 26c6ffe
and with the
vite-tsconfig-paths
plugin, you can remove the redundantalias
configuration invite.config.ts
; i.e., this bit can be removed:vite-plugin-dts/example/vite.config.ts
Line 10 in 26c6ffe
Prior to version 1.0 of this plugin, this plugin and the
vite-tsconfig-paths
plugin worked together.Since version 1.0 of this plugin, this combination no longer works. None of my
"@/foo/bar"
imports resolve in the.d.ts
files generated by this plugin, and it's necessary to add thealias
configuration again invite.config.ts
, which defeats the point of thevite-tsconfig-paths
plugin.The text was updated successfully, but these errors were encountered: