Closed RuBaWa closed 1 year ago
Did you declare a module for markdown files in a dts file? Just like:
declare module '*.vue' {
import type { DefineComponent } from 'vue'
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>
export default component
}
declare module '*.md' {
const component: DefineComponent<Record<string, unknown>, Record<string, unknown>, any>
export default component
}
Yes, here is my env.d.ts file in src folder:
/// <reference types="vite-plugin-pages/client" />
/// <reference types="vite/client" />
/// <reference types="vite-svg-loader" />
declare interface Window {
// extend the window
}
// with vite-plugin-md, markdown files can be treated as Vue components
declare module '*.md' {
import { type DefineComponent } from 'vue';
const component: DefineComponent<{}, {}, any>;
export default component;
}
declare module 'mqtt/dist/mqtt.min' {
import MQTT from 'mqtt';
export = MQTT;
}
declare module '*.vue' {
import type { DefineComponent } from 'vue';
// eslint-disable-next-line @typescript-eslint/ban-types
const component: DefineComponent<{}, {}, any>;
export default component;
}
Maybe you can try to add CHANGELOG.md
and env.d.ts
into tsconfig.json
include (In my impression, *.ts
does not include dts files).
But I don't understand why do you ship CHANGELOG.md
into the exports for library? Will somebody use your project's CHANGELOG.md
?
The idea is, that i have a component, which automatically include CHANGELOG and README md files from root, to have standarized pages at our company projects. So users of this plugin should not need to import this md files on there own.
The files are included in plugin project, but are also placed in root folde rof projects, which uses this plugin. With vite aliases the path should be rewritten und reverence the local files. With webpack this was no problem. I am new to vite, maybe this is a bad practice?
I think, the best would be, if dts generation would ignore md files. But i will try add d.ts manually to tsconfig.
Thank you, for your help :-)
It is not working. Now i have to remove all .md files. But thanks anyway
I am building a vue 3 plugin with vite and ts. at build, i get this error:
This file is available and in normal build for web, not plugin, without dts active, this files are included without errors.
tsconfig.json
eslintrc.js
vite.config.js
Vue template