Skip to content

Publish as dual module (ESM + CJS) #3255

Open

Description

@FloEdelmann

Right now, eslint-plugin-vue is published as a CommonJS (CJS) package. Since the TypeScript migration is now complete (see #2777) and the code is written in ES modules (ESM) now anyway, publishing it as a dual package (ESM + CJS) should be feasible. This would allow users to migrate to ESM in this minor version and give them some time to do so.

In the next major version (see #3105 and #3167), we can then fully switch to ESM. (Note that #3102 already tried to do this.)

Activity

  1. ValentinYoushkevich commented on Nov 16, 2026

    @ValentinYoushkevich
    Contributor

    I'd like to pick this up once #3250 and #3252 are merged. One design question first. Two separate builds would load two plugin objects whenever a flat config imports the plugin and a CommonJS shareable config requires it, and ESLint then throws Cannot redefine plugin "vue". To avoid that, I'd ship a thin dist/index.mjs that re-exports the CommonJS build, so import and require() share one instance, and require() keeps returning the plugin without .default. Would that be fine for you, or do you prefer real transpiled ESM files despite the double loading? Should it also add named exports (configs, rules, …)?

  2. FloEdelmann commented on Nov 27, 2026

    @FloEdelmann
    MemberAuthor

    @rivajunior you reacted with 👎, may I know why? Do you disagree with the suggestion to publish as dual module, or with the suggestion to go full ESM in the next major version? Or something else?

  3. FloEdelmann commented on Nov 27, 2026

    @FloEdelmann
    MemberAuthor

    Two separate builds would load two plugin objects whenever a flat config imports the plugin and a CommonJS shareable config requires it, and ESLint then throws Cannot redefine plugin "vue".

    Oh, good to know!

    To avoid that, I'd ship a thin dist/index.mjs that re-exports the CommonJS build, so import and require() share one instance, and require() keeps returning the plugin without .default.

    Hmm I guess that would be a sensible first step then.

    Should it also add named exports (configs, rules, …)?

    Not sure, I guess the default export is enough for now.

  4. ValentinYoushkevich commented on Nov 28, 2026

    @ValentinYoushkevich
    Contributor

    Thanks! I'll keep it to the default export and open the PR once #3250 and #3252 are merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions