mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
fix(npm): handle json files in require (#16125)
This commit is contained in:
parent
a6618dc01c
commit
048c06f84f
8 changed files with 22 additions and 0 deletions
|
@ -749,6 +749,14 @@ pub fn translate_cjs_to_esm(
|
|||
{
|
||||
return Ok(analysis);
|
||||
}
|
||||
|
||||
if media_type == MediaType::Json {
|
||||
return Ok(CjsAnalysis {
|
||||
exports: vec![],
|
||||
reexports: vec![],
|
||||
});
|
||||
}
|
||||
|
||||
let parsed_source = deno_ast::parse_script(deno_ast::ParseParams {
|
||||
specifier: specifier.to_string(),
|
||||
text_info: deno_ast::SourceTextInfo::new(code.into()),
|
||||
|
|
|
@ -181,6 +181,13 @@ itest!(nonexistent_file {
|
|||
exit_code: 1,
|
||||
});
|
||||
|
||||
itest!(require_json {
|
||||
args: "run --unstable -A --quiet npm/require_json/main.js",
|
||||
output: "npm/require_json/main.out",
|
||||
envs: env_vars(),
|
||||
http_server: true,
|
||||
});
|
||||
|
||||
#[test]
|
||||
fn parallel_downloading() {
|
||||
let (out, _err) = util::run_and_collect_output_with_args(
|
||||
|
|
BIN
cli/tests/testdata/npm/registry/globals/globals-13.17.0.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/globals/globals-13.17.0.tgz
vendored
Normal file
Binary file not shown.
1
cli/tests/testdata/npm/registry/globals/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/globals/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
1
cli/tests/testdata/npm/registry/type-fest/registry.json
vendored
Normal file
1
cli/tests/testdata/npm/registry/type-fest/registry.json
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
cli/tests/testdata/npm/registry/type-fest/type-fest-0.20.2.tgz
vendored
Normal file
BIN
cli/tests/testdata/npm/registry/type-fest/type-fest-0.20.2.tgz
vendored
Normal file
Binary file not shown.
2
cli/tests/testdata/npm/require_json/main.js
vendored
Normal file
2
cli/tests/testdata/npm/require_json/main.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
import globals from "npm:globals@13.17.0";
|
||||
console.log(globals);
|
3
cli/tests/testdata/npm/require_json/main.out
vendored
Normal file
3
cli/tests/testdata/npm/require_json/main.out
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
[WILDCARD]
|
||||
devtools: {
|
||||
[WILDCARD]
|
Loading…
Reference in a new issue