Skip to content

Remove CJS build for @vue/compat #6602

Closed
@sheremet-va

Description

@sheremet-va

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions