mkdist icon indicating copy to clipboard operation
mkdist copied to clipboard

The packaged Vue3 component props. ts cannot call the props. ts type properly

Open InfernalAzazel opened this issue 5 months ago • 1 comments

Environment

os: Ubuntu 22.04 node: v20.17.0 vue: 3.4.37 unbuild: 2.0.0

Reproduction

git docs

Describe the bug

  1. The packaged Vue3 component props. ts cannot call the props. ts type properly
  2. I don't know why the components encapsulated in dist compiled from docs can still be used normally
  3. Uncaught SyntaxError: The requested module '/@fs/work/kylin/github/k-naiveui-pro/packages/k-naiveui-pro/dist/components/ProBaseForm/index.mjs' does not provide an export named 'ProBaseFormColumn' (at ProBaseForm.vue:3:28)
  • In reality, I is exporting ProBaseForm (ProBaseForm/props.ts)[https://github.com/InfernalAzazel/k-naiveui-pro/blob/main/packages/k-naiveui-pro/src/components/ProBaseForm/props.ts]
import type { FormProps} from 'naive-ui'
import type { VNode } from 'vue';


export interface ProBaseFormColumn {
  label: string
  prop: string
  component: string | VNode
  props?: Record<string, any>
  span?: number
  show?: boolean

}

export interface ProBaseFormProps extends  /* @vue-ignore */ FormProps {
  columns: ProBaseFormColumn[],
  cols?: number
  xGap?: number
  yGap?: number
  columnsSpan?: number
  footerSpan?: number
  collapsed?: boolean
  collapsedRows?: number
}

This is my packaging configuration

import { defineBuildConfig } from 'unbuild'
export default defineBuildConfig({

  entries: [
    { builder: 'mkdist', input: './src', pattern: ['**/*.vue'], loaders: ['vue'] },
    { builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'cjs', loaders: ['js'] },
    { builder: 'mkdist', input: './src', pattern: ['**/*.ts'], format: 'esm', loaders: ['js'] },
  ],
  declaration: true,
  clean: true,
  // externals: [
  //   'vue',
  //   'naive-ui',
  //   'unplugin-vue-components',
  // ],
})

Additional context

  1. pnpm docs:dev (Exception occurred) image

2.Compile dist and upload it to GitHub page(natural) image

Logs

Uncaught SyntaxError: The requested module '/@fs/work/kylin/github/k-naiveui-pro/packages/k-naiveui-pro/dist/components/ProBaseForm/index.mjs' does not provide an export named 'ProBaseFormColumn' (at ProBaseForm.vue:3:28)

InfernalAzazel avatar Sep 27 '24 01:09 InfernalAzazel