- install deps:
pnpm i
; - run dev server:
pnpm run dev
(everything should be working); - stop dev server;
- run a build:
pnpm run build
- see the error:
error The requested module 'lil-gui' does not provide an export named 'default' file:///Users/raulmelo/development/sandbox/test-lil-gui/dist/chunks/pages/script_d5fa1c97.mjs:1 import GUI from 'lil-gui'; ^^^ SyntaxError: The requested module 'lil-gui' does not provide an export named 'default' at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21) at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)
- open
lil-gui
package.json (node_modules/lil-gui/package.json
); - add the following:
"exports":{ ".":{ "import": "./dist/lil-gui.esm.js", "require": "./dist/lil-gui.umd.js" } },
- run build again;
- now everything will work
Based on this comment, I've realized that's another workaround.
- open
astro.config.mjs
file; - define
vite.ssr.noExternal
; - add the library to the array:
export default defineConfig({ vite: { ssr: { noExternal: ["lil-gui"], }, }, });
The error will go away.