Skip to content

Cannot import @rjsf/utils in node using ESM #4537

@lucasmcht

Description

@lucasmcht

Prerequisites

What theme are you using?

utils

Version

5.24.8

Current Behavior

With the modification done in the 5.24.5 version, I can't import a function from @rjsf/utils in an ESM based Node environment. This bug is happening in 5.24.5 version and above

I have the following error when destructring to import a specific function :

   SyntaxError: The requested module '@rjsf/utils' does not provide an export named 'createSchemaUtils'

and this one when importing the whole module

(node:6424) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/lucasmichalet/Documents/Workspace/turbocv/node_modules/.pnpm/@[email protected][email protected]/node_modules/@rjsf/utils/lib/index.js:1
import allowAdditionalItems from './allowAdditionalItems.js';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (node:internal/modules/cjs/loader:1378:20)
    at Module._compile (node:internal/modules/cjs/loader:1428:41)
    at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
    at Module.load (node:internal/modules/cjs/loader:1288:32)
    at Module._load (node:internal/modules/cjs/loader:1104:12)
    at cjsLoader (node:internal/modules/esm/translators:346:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:286:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
    at async ProvidersManager.#resolveProvider (/Users/lucasmichalet/Documents/Workspace/turbocv/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]/node_modules/@adonisjs/application/src/managers/providers.ts:81:29)

Node.js v20.18.3

Expected Behavior

Launch without crashing. Importing full module in ESM is working using version 5.24.4, but destructuring is not working in this version either

Steps To Reproduce

  1. Launch an ESM node environnement
  2. import a function from @rjsf/utils

Environment

- OS: MacOS Sequoia 15.1
- Node: 20.18.3
- pnpm: 10.3.0

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugutilsRelated to @rjsf/utils

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions