Closed RobinTail closed 2 years ago
If you are consuming it with Typescript, reference the sources (from the src
folder). CJS (CommonJS version is packaged for JS consumers in NodeJS mainly).
In this case I'm getting another error:
node_modules/openapi3-ts/src/index.ts:1
export * from './model/index.js';
^^^^^^
SyntaxError: Unexpected token 'export'
Any recommendations?
My tsconfig
{
"extends": "@tsconfig/node14/tsconfig.json",
"compilerOptions": {
"noImplicitAny": true,
"strictNullChecks": true,
"resolveJsonModule": true
},
}
where the extension is
{
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Node 14",
"compilerOptions": {
"lib": ["es2020"],
"module": "commonjs",
"target": "es2020",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node"
}
}
Look at this @jonluca
I guess the hack we did at https://github.com/metadevpro/openapi3-ts/pull/80#discussion_r940379397 adding the *.js
extension could be producing this issue here.
The problem is the export
itself.
As per my understanding export
works in ESM, while my project is not.
Or maybe the build itself should be adjusted to include the definition of __exportStar
, so /dist/cjs
can be used without any issues.
I found out that __exportStar
is a part of tslib
:
https://www.npmjs.com/package/tslib
Ah! I think I found out what causes that. In your tsconfig.json there is a line
"noEmitHelpers": true,
it's also not overridden in tsconfig-cjs.json, so the produced CJS build does not have those tslib helpers for exports/imports.
I made a PR that I believe should fix the issue: https://github.com/metadevpro/openapi3-ts/pull/82 @pjmolina && @jonluca
Yes those are helpers emitted by typescript that might be missing when you consume the bundle. That PR should fix it up. Thanks @RobinTail!
Thanks @RobinTail & @jonluca Merged.
Hello. I wanted to try the latest major update, but I'm getting the following error:
Node version is 18.6. Typescript 4.7.4
Do you know why this is happening and/or how it can be fixed?