Skip to content

devraul/astro-lil-gui-build-error

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Astro + lil-gui => build error

site dev mode with lil-gui

Steps to repro

  1. install deps: pnpm i;
  2. run dev server: pnpm run dev (everything should be working);
  3. stop dev server;
  4. run a build: pnpm run build
  5. 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)
    

Workaround 1

  1. open lil-gui package.json (node_modules/lil-gui/package.json);
  2. add the following:
    "exports":{
        ".":{
        "import": "./dist/lil-gui.esm.js",
        "require": "./dist/lil-gui.umd.js"
        }
    },
  3. run build again;
  4. now everything will work

Workaround 2

Based on this comment, I've realized that's another workaround.

  1. open astro.config.mjs file;
  2. define vite.ssr.noExternal;
  3. add the library to the array:
    export default defineConfig({
      vite: {
        ssr: {
          noExternal: ["lil-gui"],
        },
      },
    });

The error will go away.

Reference

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published