summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/module_loader.rs2
-rw-r--r--cli/tests/integration/npm_tests.rs14
-rw-r--r--cli/tests/testdata/npm/dynamic_import_json/main.js4
-rw-r--r--cli/tests/testdata/npm/dynamic_import_json/main.out14
-rw-r--r--cli/tests/testdata/npm/import_json/main.js4
-rw-r--r--cli/tests/testdata/npm/import_json/main.out10
6 files changed, 47 insertions, 1 deletions
diff --git a/cli/module_loader.rs b/cli/module_loader.rs
index 6f1a23761..b47e2efee 100644
--- a/cli/module_loader.rs
+++ b/cli/module_loader.rs
@@ -786,7 +786,7 @@ impl NpmModuleLoader {
permissions,
)?
} else {
- // esm code is untouched
+ // esm and json code is untouched
code
};
Ok(ModuleCodeSource {
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index ddb815a15..34b6add26 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -2119,6 +2119,20 @@ itest!(reserved_word_exports {
http_server: true,
});
+itest!(import_json {
+ args: "run -A --quiet npm/import_json/main.js",
+ output: "npm/import_json/main.out",
+ envs: env_vars_for_npm_tests(),
+ http_server: true,
+});
+
+itest!(dynamic_import_json {
+ args: "run -A --quiet npm/import_json/main.js",
+ output: "npm/import_json/main.out",
+ envs: env_vars_for_npm_tests(),
+ http_server: true,
+});
+
itest!(check_package_file_dts_dmts_dcts {
args: "check npm/file_dts_dmts_dcts/main.ts",
output: "npm/file_dts_dmts_dcts/main.out",
diff --git a/cli/tests/testdata/npm/dynamic_import_json/main.js b/cli/tests/testdata/npm/dynamic_import_json/main.js
new file mode 100644
index 000000000..6d8abfc9e
--- /dev/null
+++ b/cli/tests/testdata/npm/dynamic_import_json/main.js
@@ -0,0 +1,4 @@
+const info = await import("npm:@denotest/binary-package@1/package.json", {
+ assert: { type: "json" },
+});
+console.log(json);
diff --git a/cli/tests/testdata/npm/dynamic_import_json/main.out b/cli/tests/testdata/npm/dynamic_import_json/main.out
new file mode 100644
index 000000000..07f48e8a5
--- /dev/null
+++ b/cli/tests/testdata/npm/dynamic_import_json/main.out
@@ -0,0 +1,14 @@
+[Module: null prototype] {
+ default: {
+ {
+ name: "@denotest/binary-package",
+ version: "1.0.0",
+ main: "index.js",
+ optionalDependencies: {
+ "@denotest/binary-package-linux": "1.0.0",
+ "@denotest/binary-package-mac": "1.0.0",
+ "@denotest/binary-package-windows": "1.0.0"
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/cli/tests/testdata/npm/import_json/main.js b/cli/tests/testdata/npm/import_json/main.js
new file mode 100644
index 000000000..b752bdef8
--- /dev/null
+++ b/cli/tests/testdata/npm/import_json/main.js
@@ -0,0 +1,4 @@
+import json from "npm:@denotest/binary-package@1/package.json" assert {
+ type: "json",
+};
+console.log(json);
diff --git a/cli/tests/testdata/npm/import_json/main.out b/cli/tests/testdata/npm/import_json/main.out
new file mode 100644
index 000000000..7db7ec4ea
--- /dev/null
+++ b/cli/tests/testdata/npm/import_json/main.out
@@ -0,0 +1,10 @@
+{
+ name: "@denotest/binary-package",
+ version: "1.0.0",
+ main: "index.js",
+ optionalDependencies: {
+ "@denotest/binary-package-linux": "1.0.0",
+ "@denotest/binary-package-mac": "1.0.0",
+ "@denotest/binary-package-windows": "1.0.0"
+ }
+}