Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix JSON Modules #1514

Merged
merged 1 commit into from
Jan 14, 2019
Merged

Fix JSON Modules #1514

merged 1 commit into from
Jan 14, 2019

Conversation

kitsonk
Copy link
Contributor

@kitsonk kitsonk commented Jan 14, 2019

Because ESM does not support export = assignments, nor allow "spreading" of exports, JSON modules when targeting ESM need to use a export default. From a type checking perspective, though, TypeScript assumes JSON modules will be an export = affair, even when targeting ESM as the output. This means we to add the esModuleInterop flag to the compiler options. This doesn't change the emit, but allows TypeScript to assume that the default import of a module is the same as the namespace import.

This does mean that to properly import JSON modules, we have no option but to deal with the default import, so instead of:

import * as config from "./config.json";

Only the following is supported:

import config from "./config.json";

This currently includes #1512 as well, which I will rebase when that is merged.

Rebased and ready. @ry

Copy link
Member

@ry ry left a comment

Choose a reason for hiding this comment

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

LGTM - thanks!

@ry ry merged commit 7d08db2 into denoland:master Jan 14, 2019
@kitsonk kitsonk deleted the fix-json-modules-2 branch August 2, 2022 04:44
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.

None yet

2 participants