Skip to content

ES module build contains CommonJS files (extract/transform.js, transformToRn.js), breaking native-ESM dev servers #3127

Closed

Description

@matte-bollypiano

Description

In 15.16.1, two files in the ES module build are still CommonJS, while other files in that build import them with named ES imports:

  • lib/module/lib/extract/transform.js and lib/module/lib/extract/transformToRn.js (PEG.js output) end with module.exports = { SyntaxError: peg$SyntaxError, parse: peg$parse }.
  • lib/module/lib/extract/extractTransform.js does import { parse } from './transform'; and import { parse as parseTransformSvgToRnStyle } from './transformToRn';.

Bundlers that interoperate CommonJS and ESM (Metro, Rollup/Rolldown in a production build) handle this. A dev server that serves the module build as native ESM does not. With react-native-web under Vite 8, with react-native-svg in optimizeDeps.exclude (needed because pre-bundling follows react-native imports into Flow sources), the browser fails with:

SyntaxError: The requested module '/node_modules/react-native-svg/lib/module/lib/extract/transform.js' does not provide an export named 'parse'

Steps to reproduce

  1. A react-native-web app under Vite 8 that imports react-native-svg 15.16.1, with optimizeDeps.exclude: ['react-native-svg', ...].
  2. vite (dev server), open the page.
  3. The error above; production vite build works.

Expected

The module build is ESM throughout, e.g. the two generated parsers emit export { peg$SyntaxError as SyntaxError, peg$parse as parse } (or are wrapped by a small ESM re-export).

Versions

react-native-svg 15.16.1, react-native-web 0.21, Vite 8.3.8 (Rolldown), Node 26.

Activity

  1. github-actions commented on Nov 14, 2026

    @github-actions

    Hey! 👋

    The issue doesn't seem to contain a minimal reproduction.

    Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

  2. github-actions commented on Nov 14, 2026

    @github-actions

    Hey! 👋

    It looks like you've omitted a few important sections from the issue template.

    Please complete Snack or a link to a repository, SVG version, React Native version and Platforms sections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Missing infoThe user didn't precise the problem enoughMissing reproThis issue need minimum repro scenario

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions