Skip to content

Can't build custom components with react-docgen 7 #2874

Open
@daviddavo

Description

@daviddavo

Describe your context

Please provide us your environment, so we can easily reproduce the issue.

  • replace the result of pip list | grep dash below
dash                      2.17.0
dash-bootstrap-components 1.6.0
dash-core-components      2.0.0
dash-html-components      2.0.0
dash-table                5.0.0
dash-testing-stub         0.0.2
  • if frontend related, tell us your Browser, Version and OS

    • OS: [e.g. iOS]
    • Browser [e.g. chrome, safari]
    • Version [e.g. 22]

Describe the bug

I developed a library with some custom components. I'm trying to update some dependencies, and it turns out that I can't update react-docgen because of dash's extract-meta.js, which uses a deprecated require()
A clear and concise description of what the bug is.

$  npm run build

> [email protected] build
> npm run build:js && npm run build:backends


> [email protected] build:js
> webpack --mode production

asset dao_analyzer_components.min.js 13.4 KiB [emitted] [compared for emit] [minimized] (name: main) 1 related asset
orphan modules 21.9 KiB [orphan] 6 modules
runtime modules 2.42 KiB 5 modules
./src/lib/index.js + 6 modules 22.2 KiB [not cacheable] [built] [code generated]
webpack 5.91.0 compiled successfully in 1287 ms

> [email protected] build:backends
> dash-generate-components ./src/lib/components dao_analyzer_components -p package-info.json --ignore \.test\.

/home/davo/Documents/GRASIA/dao-analyzer/.direnv/python-3.12/lib/python3.12/site-packages/dash/extract-meta.js:15
const reactDocs = require('react-docgen');
                  ^

Error [ERR_REQUIRE_ESM]: require() of ES Module /home/davo/Documents/GRASIA/dao-analyzer/dao_analyzer_components/node_modules/react-docgen/dist/main.js from /home/davo/Documents/GRASIA/dao-analyzer/.direnv/python-3.12/lib/python3.12/site-packages/dash/extract-meta.js not supported.
Instead change the require of main.js in /home/davo/Documents/GRASIA/dao-analyzer/.direnv/python-3.12/lib/python3.12/site-packages/dash/extract-meta.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/home/davo/Documents/GRASIA/dao-analyzer/.direnv/python-3.12/lib/python3.12/site-packages/dash/extract-meta.js:15:19) {
  code: 'ERR_REQUIRE_ESM'
}

Node.js v22.2.0

Error generating metadata in dao_analyzer_components (status=1)

Expected behavior

To be able to build my library

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokeninfrastructurebuild process etc.sev-4cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions