Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perfect-freehand throws an error when using in vitest #17

Open
Ursuss21 opened this issue Sep 28, 2023 · 2 comments
Open

perfect-freehand throws an error when using in vitest #17

Ursuss21 opened this issue Sep 28, 2023 · 2 comments

Comments

@Ursuss21
Copy link

Hello! Recently I've added v-perfect-signature to the project I'm writing and it's working great. I wanted to write some tests though, and got the following error.

FAIL src/tests/components/VComponent.spec.ts [ src/tests/components/VComponent.spec.ts ]
SyntaxError: Unexpected token 'export'
Module /project/node_modules/perfect-freehand/dist/esm/index.js:1 seems to be an ES Module but shipped in a CommonJS package. You might want to create an issue to the package "perfect-freehand" 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: {
    server: {
      deps: {
        inline: [
          "perfect-freehand"
        ]
      }
    }
  }
}

I'm using vue 3 and vitest 0.34.4.

I've made some research and found out this issue with perfect-freehand. As you can see, it has been resolved and pushed, although there wasn't any official release since the push. I've tested changing manually package.json in my node_modules to check, if this solution resolves my issue, and it does, so I assume it's just a matter of updating the dependency and potentially releasing new version for perfect-signature. I'm going to write about that in the mentioned issue too and hopefully they will do a release, so that it will just be matter of updating the version.

@wobsoriano
Copy link
Owner

Thanks for the info!

@garand
Copy link

garand commented Mar 7, 2024

This has been released. v1.2.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants