Closed
Description
Description
The openapi-fetch
currently exports a index.js
and (.index.min.js
) file, which might work fine if run in a type: 'module'
environment.
However, this is something that will be bundled for the browser environment, which leads to the joy of bundling, and could also be bundled for CommonJS for the client.
Exporting both a CommonJS and ESM file, and having them indexed correctly in the package.json
should help with this.
A package like tsup should improve it. I think a simple setup like this should be enough.
{
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsup src/index.tsx"
}
}
Error message
Error [ERR_REQUIRE_ESM]: require() of ES Module /Frontend/node_modules/.pnpm/openapi-fetch@0.1.2/node_modules/openapi-fetch/dist/index.js from /Frontend/dist/prerender/prerender.js not supported.
Instead change the require of index.js in /Frontend/dist/prerender/prerender.js to a dynamic import() which is available in all CommonJS modules.
Checklist
- I’m willing to open a PR (see CONTRIBUTING.md)