Skip to content

node-config can't be an ESM module until it's an ESM module (typescript compatibility) #891

Open

Description

@jdmarshall

If I attempt to set node-config to type: "module", then the typescript integration tests fail:

Error: Cannot parse config file: '/Users/jasonmarshall/Projects/cobbler/node-config/test/x-config-ts/default.ts': Error: Must use import to load ES Module: /Users/jasonmarshall/Projects/cobbler/node-config/test/x-config-ts/default.ts
require() of ES modules is not supported.
require() of /Users/jasonmarshall/Projects/cobbler/node-config/test/x-config-ts/default.ts from /Users/jasonmarshall/Projects/cobbler/node-config is an ES module file as it is a .ts file whose nearest parent package.json contains "type": "module" which defines all .ts files in that package scope as ES modules.
Instead change the requiring code to use import(), or remove "type": "module" from /Users/jasonmarshall/Projects/cobbler/node-config/package.json.

Essentially we need to import ts files if node-config is an ESM module, but that makes them async, which means parse() needs to be async. Which means people already need to be treating nodejs as an ESM module so that the top-level async that will work properly with their code importing node-config.

So we need to ship 5.0 in order to fix this. And then decide if fixing this bug constitutes a 6.0 version number or a 5.X version number. But I suspect the change in parse() constitutes a breaking change. I'll have to look at it more.

Activity

  1. added this to the someday milestone on Feb 24, 2026
  2. jdmarshall commented on Feb 24, 2026

    @jdmarshall
    CollaboratorAuthor

    Other option might be defer or async, but defer really wants to operate on children of the returned file, not the entire body, so I'm not entirely sure that would work.

  3. modified the milestones: someday, 6.0 on Jul 10, 2026
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions