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

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

Remove CJS build for @vue/compat #6602

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

Comments

@sheremet-va
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: https://stackblitz.com/edit/node-apcmcb?file=index.js

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": "./index.dev.mjs"
      "import": "./index.mjs",
      "require": "./index.js"
    },
  }
}
// index.dev.mjs
export * from './dist/vue.esm.mjs'
// index.mjs
export * from './dist/vue.esm.prod.mjs'
@yyx990803
Copy link
Member

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.

@cexbrayat
Copy link
Member

@yyx990803 @sheremet-va I bumped VTU to Vue v3.2.40 and tried the latest vitest release, and the issue is still there https://github.com/vuejs/test-utils/actions/runs/3141055322/jobs/5103078070

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
present.

fix vuejs#6602
@github-actions github-actions bot locked and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
✨ feature request New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants