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

Remove CJS build for @vue/compat #6602

sheremet-va opened this issue Sep 5, 2022 · 2 comments

Remove CJS build for @vue/compat #6602

sheremet-va opened this issue Sep 5, 2022 · 2 comments
feature request New feature or request


Copy link

sheremet-va commented Sep 5, 2022

What problem does this feature solve?

@vue/compat depends on estree-walker, which doesn't support CJS build:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /home/projects/node-apcmcb/node_modules/estree-walker/package.json

This causes issues in Vitest, for example (#1978), or any tools that imports it without preprocessing.

What does the proposed API look like?

I propose removing CJS build altogether, but keep index.js with an if statement (I assume it's used for more old tools that don't understand "exports" field.) If it is meant to be used with estree-walker@2, we should have it for compatibility with Jest. (it's not specified in package.json)

I would also recommend adding "exports" field with compatible Node ESM build (meaning, type: "module" or .mjs extension, docs)

  "exports": {
    ".": {
      "development": "./"
      "import": "./index.mjs",
      "require": "./index.js"
export * from './dist/vue.esm.mjs'
// index.mjs
export * from './dist/'
Copy link

The root cause is that @vue/compat did not list its own dependencies, so it was resolving to a hoisted & newer version of estree-walker that doesn't have CJS build.

Copy link

@yyx990803 @sheremet-va I bumped VTU to Vue v3.2.40 and tried the latest vitest release, and the issue is still there

chrislone pushed a commit to chrislone/core that referenced this issue Feb 4, 2023
Previously the cjs build implicitly relies on hoisted versions of the
deps, causing it to resolve to newer versions of estree-walker when

fix vuejs#6602
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
feature request New feature or request
None yet

No branches or pull requests

3 participants