Open chamby opened 3 months ago
I worked around this by aliasing your precise import in my project. This feels brittle to me, but at least I have a workaround.
resolve: {
alias: {
"@/dist/VPikaday.esm": "./dist/VPikaday.esm.js",
"@": path.resolve(__dirname, "resources/assets/js"),
},
},
I have defined the
@
alias for my project. Vite is picking up theimport VPikaday from "@/dist/VPikaday.esm";
and interpreting your@
alias as my alias. I wasn't aware that Vite does this for imports fromnode_modules
. I tried to find best practice for whether or not to use aliases in theindex.js
entry point file but could not find much. Here is an issue report https://github.com/vitejs/vite/issues/2290 in the Vite repo that didn't offer a workaround. Could you change the import to a simple relative path instead? The alias shouldn't be necessary in the entry point file.I have not created an NPM package myself so let me know I am off base.