Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support ESM for templates #955

Open
basickarl opened this issue Apr 19, 2024 · 0 comments
Open

Support ESM for templates #955

basickarl opened this issue Apr 19, 2024 · 0 comments

Comments

@basickarl
Copy link

basickarl commented Apr 19, 2024

馃殌 Feature Proposal

Support ESM templates.

Error when loading "--template": svgr-template.mjs

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/karl/development/neo4j/needle-2/packages/react/svgr-template.mjs not supported.
Instead change the require of /Users/karl/development/neo4j/needle-2/packages/react/svgr-template.mjs to a dynamic import() which is available in all CommonJS modules.
    at Option.parseArg (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/dist/index.js:330:22)
    at handleOptionValue (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/node_modules/commander/lib/command.js:539:24)
    at Command.<anonymous> (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/node_modules/commander/lib/command.js:566:7)
    at Command.emit (node:events:514:28)
    at Command.parseOptions (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/node_modules/commander/lib/command.js:1454:18)
    at Command._parseCommand (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/node_modules/commander/lib/command.js:1240:25)
    at Command.parse (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/node_modules/commander/lib/command.js:909:10)
    at Object.<anonymous> (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/dist/index.js:398:19)
    at Object.<anonymous> (/Users/karl/development/neo4j/needle-2/node_modules/@svgr/cli/bin/svgr:3:1)

Currently the docs do show to use CJS: https://react-svgr.com/docs/custom-templates/#custom-index-template

Motivation

The future of JS is ESM, we should be moving away from CJS everywhere.

Example

Everything re-written from CJS to ESM.

Pitch

Less pain having to deal with CJS.

Slightly related to #707

Is this on the roadmap?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant