Skip to content

Modules export errors when using with Vite #1405

@ng-hai

Description

@ng-hai

I have two issues when working with Uniforms in a Vite project (Remix | React Router).

JSONSchemaBridgeModule cannot be used as constructor

__vite_ssr_import_2__.default is not a constructor

Named export error from uniforms-unstyled package (could be other themes as well)

[vite] Named export 'AutoForm' not found.
The requested module 'uniforms-unstyled' is a CommonJS module,
which may not support all module.exports as named exports.

Reproduce on codesandbox: https://codesandbox.io/p/devbox/tw9mnm

What I have tried
For the named export issue, I can make it work by changing

- import { AutoForm } from "uniforms-unstyled"
+ import * as Unstyled from "uniforms-unstyled"

- <AutoForm />
+ <Unstyled.AutoForm />

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugBug reports and their fixes

    Type

    No type

    Projects

    Status

    To do

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions