Skip to content

CommonJS and ESM lack appropriate extensions #41

Open
@javiertury

Description

@javiertury

Using this library with vite and pre-render, produces the following error:

[vite-plugin-ssr:autoFullBuild] Named export 'Fetcher' not found. The requested module 'openapi-typescript-fetch' is a CommonJS module, which may not support all module.exports as named exports.

The reason is that both CommonJS and ESM exports are using the .js extension. If package.json#type is commonjs (default), .js can be used for CommonJS but .mjs should be used for ESM. And if package.json#type is module, .js can be used for ESM output, but .cjs should be used for CommonJS.

I think "type": "module" is better because the .js extension can be used for NodeJS modules and browsers alike, making mandatory .cjs only for CommonJS files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions