Open China-xiaoFang opened 1 week ago
Hi, from v4.1.2
you should import from https://cdn.jsdelivr.net/npm/pinia-plugin-persistedstate@4.1.2/dist/index.global.js
and it should work.
Let me know if that fixes the issue!
Hello, thank you for taking the time to deal with this issue.
However, after my test, as shown in the figure, I still can't find the global var name, but it may be that my global var name is used incorrectly.
Maybe the iife
build does not support this operation.
Generally, we build libraries through the umd
mode, so I think you should add the umd
mode build and specify the global var name, which may solve this problem.
In the smallest demo provided before, I have updated and reproduced this problem.
Are you using Nuxt?
Describe the bug
When I tried to use
pinia-plugin-persistedstate
inVue3
+Vite
+TypeScript
environment, I imported the library through CDN, and the browser console reported an errorI think this should be a problem of not handling umd format build during build. Because it relies on third-party dependencies,
deep-pick-omit
,defu
,destr
Althoughpnpm
will automatically load these third-party dependencies in ES mode, they will not be automatically loaded in CDN mode, so these third-party dependencies cannot be excluded when buildingumd
format js files. Otherwise, the CDN reference may not be able to find the third-party dependencies or may report an import error.I wanted to modify the build configuration myself by cloning the repository, but I found that the cloned project seemed to lack some necessary files, such as
./.nuxt/tsconfig.json
.How to reproduce the smallest demo provided:
pnpm i
The development environment is normalpnpm dev
There will be problems with previewing after packaging, because it is referenced through CDN at this timepnpm build
pnpm preview
Open the browser console and you will find errors.Reproduction
https://stackblitz.com/edit/pinia-plugin-persistedstate-cdn-error
System Info
Used Package Manager
pnpm
Validations