When this library is imported under node as ESM, named exports are broken.
Reproduction steps
This can be reproduced by creating these files:
demo.mjs:
import { Helmet } from 'react-helmet-async';
console.log(Helmet);
demo.cjs:
const { Helmet } = require('react-helmet-async');
console.log(Helmet);
And then running them:
node demo.mjs
node demo.cjs
Running the .mjs demo file leads to the following crash currently:
import { Helmet } from 'react-helmet-async';
^^^^^^
SyntaxError: Named export 'Helmet' not found. The requested module 'react-helmet-async' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from 'react-helmet-async';
const { Helmet } = pkg;
Solution
This seems to be fixable by adding the currently missing exports key in package.json:
"exports": {
".": {
"types": "./lib/index.d.ts",
"import": "./lib/index.esm.js",
"require": "./lib/index.js"
}
},
This preserves CJS compatibility but fixes ESM support.
When this library is imported under node as ESM, named exports are broken.
Reproduction steps
This can be reproduced by creating these files:
demo.mjs:
demo.cjs:
And then running them:
node demo.mjsnode demo.cjsRunning the .mjs demo file leads to the following crash currently:
Solution
This seems to be fixable by adding the currently missing
exportskey in package.json:This preserves CJS compatibility but fixes ESM support.