compute-scroll-into-view icon indicating copy to clipboard operation
compute-scroll-into-view copied to clipboard

Vite v3 error saying shipped as CommonJS package

Open janosh opened this issue 3 years ago • 0 comments

I'm trying to use this package over at https://github.com/janosh/svelte-multiselect with vite v3 and getting the following error:

SyntaxError: Unexpected token 'export' ❯ Object.compileFunction node:vm:360:18

Module node_modules/compute-scroll-into-view/dist/index.module.js:1 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "compute-scroll-into-view" asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

As a temporary workaround you can try to inline the package by updating your config:

// vitest.config.js
export default {
  test: {
    deps: {
      inline: [
        "compute-scroll-into-view"
      ]
    }
  }
}

Any reservations about adding "type": "module" to package.json?

janosh avatar Aug 02 '22 16:08 janosh