You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dist/cjs is loaded as ESM because of "type": "module", so all require exports fail #124
package.json sets "type": "module", while "main" and every "require" condition in "exports" point to .js files under dist/cjs/ without a dist/cjs/package.json ({"type": "commonjs"}) or .cjs extension, so Node parses the CommonJS output as ES modules.
Save as repro.cjs and run npm install react-datocms@8.1.2 react react-dom && node repro.cjs:
file:///.../node_modules/react-datocms/dist/cjs/Seo/index.js:16
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and '.../node_modules/react-datocms/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
The same error occurs for require("react-datocms") and all 11 subpath exports (./seo, ./image, ./rsc-image, ./video-player, ./structured-text, ./use-query-subscription, ./use-site-search, ./use-video-player, ./use-content-link, ./content-link, ./stega). ESM import resolves to dist/esm and works.
Expected output: require("react-datocms/seo") and the other "require" entry points load dist/cjs as CommonJS without throwing. Writing {"type": "commonjs"} to dist/cjs/package.json after tsc:cjs makes all 12 entry points load cleanly.
Versions tested: react-datocms@8.1.2 (npm latest) and master (759b5b404), Node.js v26.13.0 and v24.22.2.
Activity
roger-datocms commentedon Nov 16, 2026
Thank you for this report! I'll try to get it fixed in #125