Skip to content

Regression from 0.17 -> 0.18 Intermittent inability to parse some CJS files. #766

@methompson

Description

@methompson

Reproduction link or steps

Reproduction Link: https://github.com/methompson/tsdown_issue_example

  1. Clone the repo
  2. Install dependencies with npm ci
  3. Run npm run build to test the build process and observe a successful build
  4. Install the latest version with npm i -D tsdown@latest
  5. Run npm run build to observe the failing build process

When using v0.17, this application will build fine.
When using v0.18+, the application no longer builds.

I am running all of this using Node v22.

What is expected?

I expect the build process to build and complete as normal, just like with tsdown v0.17.

What is actually happening?

An error is displayed:

ℹ tsdown v0.20.3 powered by rolldown v1.0.0-rc.3

 ERROR  TypeError: Cannot read properties of undefined (reading 'exports')
    at require (node:internal/modules/esm/translators:152:33)
    at Object.getPkg (/Users/work/Desktop/work/issue_example/node_modules/jsonc-eslint-parser/lib/parser/visitor-keys.js:40:28)
    at loadNewest (/Users/work/Desktop/work/issue_example/node_modules/jsonc-eslint-parser/lib/parser/modules/require-utils.js:73:26)
    at getVisitorKeys (/Users/work/Desktop/work/issue_example/node_modules/jsonc-eslint-parser/lib/parser/visitor-keys.js:21:51)
    at Object.<anonymous> (/Users/work/Desktop/work/issue_example/node_modules/jsonc-eslint-parser/lib/index.js:40:57)
    at loadCJSModule (node:internal/modules/esm/translators:166:3)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:202:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
    at async onImport.tracePromise.__proto__ (node:internal/modules/esm/loader:665:26)
    at async nativeImport (file:///Users/work/Desktop/work/issue_example/node_modules/tsdown/dist/options-DfwuH01N.mjs:489:14)

I've narrowed the issue down to the jsonc-eslint-parser package installed by the @intlify/unplugin-vue-i18n package. This package, in its current incarnation, worked fine with v0.17, but now fails for versions 0.18+.

I understand that the jsonc-eslint-parser project uses CJS, but that hadn't been a problem with vite or versions of tsdown earlier than 0.18.

Any additional comments?

I installed this plugin this past November, I ran into this bug when attempting to upgrade from tsdown v0.17 to v0.20 due to a deprecation warning. Our current library seems to work for now, but I'd rather not be hamstrung due to a single CJS repository...

I'd love to help resolve this issue as best as I can.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions