samchungy / zod-openapi

Use Zod Schemas to create OpenAPI v3.x documentation
MIT License
256 stars 12 forks source link

`Server` and `ServerVariable` are getting referenced in JS build but shouldn't be #91

Closed rattrayalex closed 1 year ago

rattrayalex commented 1 year ago
../node_modules/.pnpm/zod-openapi@2.3.0_zod@3.21.4/node_modules/zod-openapi/lib-es2015/openapi3-ts/dist/oas31.js
export 'Server' (reexported as 'Server') was not found in './model/server' (module has no exports)

Import trace for requested module:
../node_modules/.pnpm/zod-openapi@2.3.0_zod@3.21.4/node_modules/zod-openapi/lib-es2015/openapi3-ts/dist/oas31.js
../node_modules/.pnpm/zod-openapi@2.3.0_zod@3.21.4/node_modules/zod-openapi/lib-es2015/openapi3-ts/dist/index.js
../node_modules/.pnpm/zod-openapi@2.3.0_zod@3.21.4/node_modules/zod-openapi/lib-es2015/index.js

In oas31.js, I see this:

export * from './dsl/openapi-builder31';
export * from './model/openapi31';
export { Server, ServerVariable } from './model/server';
//# sourceMappingURL=oas31.js.map

and in model/server.js, I see this:

export {};
//# sourceMappingURL=server.js.map

It looks like perhaps this line:

export { Server, ServerVariable } from './model/server';

should be

export type { Server, ServerVariable } from './model/server';

or maybe a build configuration change is needed.

The isolatedModules option may help with debugging there

samchungy commented 1 year ago

Ooo are you building in esm? I'll see if I can fix it today 👀. Ah I see the types use a export declare class. I think I might have a workaround.

rattrayalex commented 1 year ago

Amazing, thank you! I think we're doing a vanilla nextjs setup which I don't think uses esm…