Skip to content

[Request] Publish code with ESM syntax/avoid using default export with CJS syntaxes #184

@sararathje

Description

@sararathje

Description

We are migrating from Vite 7 to Vite 8, and are noticing an issue with importing the EmbedFlow from @formsort/react-embed. The default import from CommonJS modules now work like this (copy pasta'd from the migration docs):

The default import from a CommonJS (CJS) module is now handled in a consistent way.

If it matches one of the following conditions, the default import is the module.exports value of the importee CJS module. Otherwise, the default import is the module.exports.default value of the importee CJS module:

  • The importer is .mjs or .mts.
  • The closest package.json for the importer has a type field set to module.
  • The module.exports.__esModule value of the importee CJS module is not set to true.

When we import the EmbedFlow for our React components from '@formsort/react-embed' like so:

import EmbedFlow from '@formsort/react-embed';

we now get an error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object., and the embedded form fails to load.

Ask

Both Vite and Rolldown recommended raising an issue with the dependency to ensure that code is published with ESM syntax or avoid using default exports:

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