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

Allow imports of JSON #1065

Merged
merged 1 commit into from Oct 31, 2018

Conversation

2 participants
@kitsonk
Copy link
Contributor

kitsonk commented Oct 22, 2018

Fixes #1048

This is a WIP PR for allowing the import of JSON as a module, which would include the ability to ensure its type safety in consuming code. This would allow:

config.json

{
  "debug": true,
  "version": "1.0.0"
}

main.ts

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

if (configJson.debug === true) {
  console.log(`Version: ${configJson.version}`);
}

@kitsonk kitsonk referenced this pull request Oct 22, 2018

Merged

Media Type enforcement #1020

3 of 3 tasks complete

@kitsonk kitsonk force-pushed the kitsonk:json-modules branch from ef0ea3c to e409942 Oct 29, 2018

@kitsonk kitsonk changed the title [WIP] Allow imports of JSON Allow imports of JSON Oct 29, 2018

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

kitsonk commented Oct 29, 2018

@ry this is ready for review

@kitsonk kitsonk closed this Oct 29, 2018

@kitsonk kitsonk force-pushed the kitsonk:json-modules branch from e409942 to a68403d Oct 29, 2018

@kitsonk kitsonk reopened this Oct 29, 2018

@kitsonk kitsonk referenced this pull request Oct 29, 2018

Open

Custom tsconfig.json #51

@ry
Copy link
Collaborator

ry left a comment

Looks good! Just a few comments-

Show resolved Hide resolved js/compiler.ts Outdated
Show resolved Hide resolved js/compiler.ts
Show resolved Hide resolved js/compiler.ts Outdated
Show resolved Hide resolved js/compiler.ts
Show resolved Hide resolved js/compiler_test.ts Outdated

@kitsonk kitsonk force-pushed the kitsonk:json-modules branch from d028718 to 9169c8b Oct 31, 2018

@kitsonk

This comment has been minimized.

Copy link
Contributor Author

kitsonk commented Oct 31, 2018

@ry ready for review again

@ry

ry approved these changes Oct 31, 2018

Copy link
Collaborator

ry left a comment

LGTM

assertEqual(deps && deps.length, 0);
assert(factory != null);
const factoryResult = factory();
assertEqual(factoryResult, { hello: "world", foo: "bar" });

This comment has been minimized.

@ry

ry Oct 31, 2018

Collaborator

Nice. Thanks.

@ry ry merged commit 2422e52 into denoland:master Oct 31, 2018

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
license/cla Contributor License Agreement is signed.
Details

ry added a commit to ry/deno that referenced this pull request Nov 2, 2018

Revert "Add ability to load JSON as modules (denoland#1065)"
Slowdowns cold-boot benchmark: 0.5s -> 0.8s

This reverts commit 2422e52.

ry added a commit to ry/deno that referenced this pull request Nov 5, 2018

v0.1.11
- Performance and stability improvements on all platforms.
- Add repl (denoland#998)
- Add deno.Buffer (denoland#1121)
- Support cargo check (denoland#1128)
- Upgrade Rust crates and Flatbuffers. (denoland#1145, denoland#1127)
- Add helper to turn deno.Reader into async iterator (denoland#1130)
- Add ability to load JSON as modules (denoland#1065)
- Add deno.resources() (denoland#1119)
- Add application/x-typescript mime type support (denoland#1111)

@ry ry referenced this pull request Nov 5, 2018

Merged

v0.1.11 #1157

ry added a commit that referenced this pull request Nov 5, 2018

v0.1.11
- Performance and stability improvements on all platforms.
- Add repl (#998)
- Add deno.Buffer (#1121)
- Support cargo check (#1128)
- Upgrade Rust crates and Flatbuffers. (#1145, #1127)
- Add helper to turn deno.Reader into async iterator (#1130)
- Add ability to load JSON as modules (#1065)
- Add deno.resources() (#1119)
- Add application/x-typescript mime type support (#1111)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment