NPM library builds file but fails when imported

18 Views Asked by At

I'm using Vite and rollup. The library builds fine and if I point my project to the source files on the same machine within the tsconfig.json everything works fine. There weren't any significant build changes as far as I can tell since the last publish but now any published use of the library causes the following error.

[ERROR] Could not resolve "canvas"

    node_modules/@mycompany/cil-common-ui/build/index.esm.js:22:25:
      22 │ import require$$3$2 from 'canvas';
         ╵                          ~~~~~~~~

  You can mark the path "canvas" as external to exclude it
  from the bundle, which will remove this error.

I've tried marking it external in the library but it still fails when imported. Any ideas how to get around this error? I've tried marking it external in the vite.config.js but that doesn't effect anything. Looking through the git history I'm kinda at a loss on how this error could have started popping up.

0

There are 0 best solutions below