Skip to content

ESM Module Support while using Vitest #4986

Description

@Kaustix

When using vite and vitest with @ag-grid-community. I keep gettings the following errors

SyntaxError: Cannot use import statement outside a module
 ❯ Object.compileFunction ../../../../../../../../../../../../node:vm:352:18
 ❯ ../../node_modules/@ag-grid-community/vue/main.js:6:10

@ag-grid-community\vue\lib\AgGridVue.js:8 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package asking them to ship the file in .mjs extension or add "type": "module" in their package.json.

Within vitest setup i've tried adding ag-grid to the dependencies inline, however this does not resolve the issue.

test: {
    deps: {
      inline: ['@ag-grid-community/vue/lib/AgGridVue']
    }
  }

Is there a way to correctly ignore this within vitest, or adding ESM support to @ag-grid-community/vue/AgGridVue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    community-supportSupport request for the AG Grid community

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions