Skip to content

temporal-utils is incompatible with CJS #100

Description

@connor-baer

Relates to #99 and #62.

Thanks for fixing the export conditions for temporal-polyfill in v1.0.3 to support requiring from CJS. Unfortunately, temporal-utils has a similar issue that can likely be fixed in the same way.

I ran into this issue when testing code that depends on temporal-polyfill with Jest (v30.4). I get the following error:

Cannot find module 'temporal-utils/protected' from '../../../node_modules/temporal-polyfill/chunks/internal.js'

    Require stack:
      /<redacted>/node_modules/temporal-polyfill/chunks/internal.js
      /<redacted>/node_modules/temporal-polyfill/chunks/classApi-basic.js
      /<redacted>/node_modules/temporal-polyfill/index.js
      ...

Manually editing the package.json#exports config for temporal-utils to use the same format as temporal-polyfill fixes the issue:

"exports": {
    ".": {
      "types": "./dist/index.d.ts",
-      "import": "./dist/index.js"
+      "default": "./dist/index.js"
    },
    "./protected": {
      "types": "./dist/protected.d.ts",
-      "import": "./dist/protected.js"
+      "default": "./dist/protected.js"
    },
    "./protected-error-messages": {
      "types": "./dist/protected-error-messages.d.ts",
-      "import": "./dist/protected-error-messages.js"
+      "default": "./dist/protected-error-messages.js"
    }
  },

I'll open a pull request in a few minutes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions