Closed mrcego closed 1 year ago
In the case you provided, I did not find that ce-ui-core.js
was used in the playground, so I donโt know how you used it specifically, but I noticed that you used createCEApp
incorrectly.
I made changes to the files in the package directory, and the alert component can be rendered.
// index.ts
import { createCEApp } from '@unplugin-vue-ce/ce-app'
import './style.css'
import Alert from '@components/Alert'
const ClgAlert = createCEApp(Alert.AlertBase)
// export individual elements
export { ClgAlert }
export function register() {
ClgAlert.mount('clg-alert')
}
register()
// index.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + Vue + TS</title>
</head>
<body>
<div id="app">
<clg-alert></clg-alert>
</div>
<script type="module" src="/src/index.ts"></script>
</body>
</html>
I just built package repo using pnpm build
and then pnpm i
to do it part as project dependency, and tried to use in index.html file of playground monorepo. My idea was the same as your example, exposing and using register()
in playground monorepo directly.
The warning message about Component is missing template or render function
is because you exported an object, so you need to make sure to pass in a specific component object.
const ClgAlert = createCEApp(Alert.AlertBase)
Look like it's correct now, I missed miserably that detail ๐. In the other hand, I just ran in issue with slots, but this is another story. Thanks again @baiwusanyu-c.
Describe the bug
If we try building an library with Vite and then want to use in another project, "Component is missing template or render function" is shown, no matter where.
I'm combining ce-app and substyle for accomplish this. The reproduction is a monorepo with playground and package repos.
Reproduction
https://github.com/mrcego/unplugin-vue-ce-library-attempt
System Info
Used Package Manager
pnpm
Validations