Skip to content

TypeError when a dependency module depends upon Chalk - @rollup/plugin-commonjs > 23.0.4  #1446

Closed
@Jason3S

Description

@Jason3S

Expected Behavior

The app not to crash on startup. See repo:

npm run test:ok

Result is as expected:

Hello Node.js v16.14.2!
{ config: {}, filepath: '/home/projects/node-acyqrb/test-cosmic.json' }

Actual Behavior

npm run test:broken

Result:

TypeError: Cannot read properties of undefined (reading 'close')
    at eval (file://file:///home/projects/node-acyqrb/dist/index.mjs:2513:77)
    at requireChalk (file://file:///home/projects/node-acyqrb/dist/index.mjs:2670:3)
    at requireLib$1 (file://file:///home/projects/node-acyqrb/dist/index.mjs:2691:15)
    at requireLib (file://file:///home/projects/node-acyqrb/dist/index.mjs:2809:19)
    at requireParseJson (file://file:///home/projects/node-acyqrb/dist/index.mjs:2976:29)
    at Object.loadJson (file://file:///home/projects/node-acyqrb/dist/index.mjs:7141:17)
    at ExplorerSync.loadPackageProp (file://file:///home/projects/node-acyqrb/dist/index.mjs:7254:46)
    at ExplorerSync.loadFileContentSync (file://file:///home/projects/node-acyqrb/dist/index.mjs:7681:14)
    at ExplorerSync.createCosmiconfigResultSync (file://file:///home/projects/node-acyqrb/dist/index.mjs:7689:30)
    at ExplorerSync.loadSearchPlaceSync (file://file:///home/projects/node-acyqrb/dist/index.mjs:7666:17) 

Additional Information

This is a bit of a nasty issue because it is related to a nested dependency:

devDependencies:
cosmiconfig 8.1.0
└─┬ parse-json 5.2.0
  └─┬ @babel/code-frame 7.18.6
    └─┬ @babel/highlight 7.18.6
      └─┬ chalk 2.4.2
        └── ansi-styles 3.2.1

It started when upgrading Cosminconfig from 8.0.0 to 8.1.0.

See: cosmiconfig/cosmiconfig#291

I tracked this down to a change in @rollup/plugin-commonjs. Version 23.0.4 works, everything past it does not. It seems to be due to this PR.

Please open an issue in rollup's repository.

If they refuse to fix this for some reason, the package having to adapt would probably be chalk or ansi-styles, not cosmiconfig.

Originally posted by @d-fischer in cosmiconfig/cosmiconfig#291 (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