Skip to content

Fix named exports for parse and stringify in the ESM builds. - #364

Closed
lgarron wants to merge 1 commit into
json5:mainfrom
lgarron:fix-named-exports
Closed

lgarron wants to merge 1 commit into
json5:mainfrom
lgarron:fix-named-exports

Conversation

@lgarron

@lgarron lgarron commented Nov 5, 2025

Copy link
Copy Markdown

This resolves #240 and allows the following to work properly:

import { parse, stringify } from "json5";

(Note that the types for json5 already declared that this import was possible. However, trying to use the import like this resulted in a runtime error.)

There are "better" ways to implement this, but some of the other simple options do not work: #240 (comment) This is a simple change that addresses the broken exports without refactoring the package structure.

This resolves json5#240 and allows the following to work properly:

```js
import { parse, stringify } from "json5";
```

(Note that the *types* for `json5` already declared that this import was possible. However, trying to use the import like this resulted in a runtime error.)

There are "better" ways to implement this, but some of the other simple options do not work: json5#240 (comment)
This is a simple change that addresses the broken exports without refactoring the package structure.
lgarron added a commit to lgarron/naughty-list that referenced this pull request Nov 5, 2025
@kshetline

Copy link
Copy Markdown

I wouldn't hold your breath on getting this accepted. PRs have been languishing for a long time now.

@Tezzlermfjones94 Tezzlermfjones94 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollup.config.js

@jordanbtucker

Copy link
Copy Markdown
Member

Closed by #370

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ESM module export differs from main export

4 participants