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

BREAKING: remove support for JSON imports #5037

Merged
merged 1 commit into from
May 1, 2020

Conversation

bartlomieju
Copy link
Member

@bartlomieju bartlomieju commented May 1, 2020

This commit removes support for importing JSON files as modules.

This change is dictated by security; browsers rolled back the support.

This commit removes support for importing JSON files as modules.

This change is dictated by security; browsers rolled back on this
support as well.
@@ -118,8 +115,9 @@ impl GlobalState {
let compile_lock = self.compile_lock.lock().await;

let compiled_module = match out.media_type {
msg::MediaType::Unknown => state1.js_compiler.compile(out).await,
msg::MediaType::Json => state1.json_compiler.compile(&out).await,
msg::MediaType::Json | msg::MediaType::Unknown => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I think MediaType::Json could now be removed; it'd be handled as MediaType::Unknown

@bartlomieju
Copy link
Member Author

CC @kitsonk

@bartlomieju bartlomieju requested a review from ry May 1, 2020 17:05
@nayeemrmn
Copy link
Collaborator

nayeemrmn commented May 1, 2020

Closes #3401.

@ry
Copy link
Member

ry commented May 1, 2020

There may be special handling of json imports in the bundler code base.

Comment on lines -398 to -409
#[test]
fn bundle_json() {
let json_modules = util::root_path().join("cli/tests/020_json_modules.ts");
assert!(json_modules.is_file());
let t = TempDir::new().expect("tempdir fail");
let bundle = t.path().join("020_json_modules.bundle.js");
let mut deno = util::deno_cmd()
.current_dir(util::root_path())
.arg("bundle")
.arg(json_modules)
.arg(&bundle)
.spawn()
Copy link
Member Author

Choose a reason for hiding this comment

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

@ry thanks for pointing this out; I guess there should be permission check involved in this case like a regular disk read?

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

(cc @MylesBorins)

@kitsonk
Copy link
Contributor

kitsonk commented May 1, 2020

LGTM

@bartlomieju bartlomieju merged commit de2c042 into denoland:master May 1, 2020
@bartlomieju bartlomieju deleted the remove_json_imports branch May 1, 2020 22:32
SASUKE40 pushed a commit to SASUKE40/deno that referenced this pull request May 7, 2020
This commit removes support for importing JSON files as modules.

This change is dictated by security; browsers rolled back on this
support as well.
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.

4 participants