Skip to content

[Bug]: SyntaxError: Unexpected token 'export' using @fluentui/react-components as ES Module #30778

@jason-ha

Description

@jason-ha

Library

React Components / v9 (@fluentui/react-components)

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Memory: 15.10 GB / 31.85 GB
  Browsers:
    Edge: Chromium (122.0.2365.80)
    Internet Explorer: 11.0.22621.1

Are you reporting Accessibility issue?

no

Reproduction

https://codesandbox.io/p/sandbox/pedantic-mopsa-423pkr

Bug Description

Actual Behavior

running test:jest script (uses ES Modules without transformers) results in:

node_modules\@fluentui\react-components\lib\index.js:2
    export { __css, __resetCSS, __resetStyles, __styles, createDOMRenderer, makeResetStyles, makeStaticStyles, makeStyles, mergeClasses, RendererProvider, renderToStyleElements, shorthands } from '@griffel/react';
    ^^^^^^

    SyntaxError: Unexpected token 'export'

      at Runtime.createScriptFromCode (.../node_modules/jest-runtime/build/index.js:1505:14)

index.js is interpreted as a CommonJS module because the nearest package.json (package root) does not specify "type": "module".

Expected Behavior

No syntax errors from @fluentui components

Possible Fix

inject a package.json into all @fluentui package lib folders with:

{
	"type": "module"
}

Logs

No response

Requested priority

Normal

Products/sites affected

No response

Are you willing to submit a PR to fix?

no

Validations

  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • The provided reproduction is a minimal reproducible example of the bug.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions