summaryrefslogtreecommitdiff
path: root/cli/tools
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-10-14 20:48:39 -0400
committerGitHub <noreply@github.com>2024-10-14 20:48:39 -0400
commit1a0cb5b5312941521ab021cfe9eaed498f35900b (patch)
tree2e5c58e25e8506b993ac678e83ba0c2feac37d75 /cli/tools
parentee7d4501435f0ebd655c8b50bd6e41ca19e71abc (diff)
feat(unstable): `--unstable-detect-cjs` for respecting explicit `"type": "commonjs"` (#26149)
When using the `--unstable-detect-cjs` flag or adding `"unstable": ["detect-cjs"]` to a deno.json, it will make a JS file CJS if the closest package.json contains `"type": "commonjs"` and the file is not an ESM module (no TLA, no `import.meta`, no `import`/`export`).
Diffstat (limited to 'cli/tools')
-rw-r--r--cli/tools/compile.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/cli/tools/compile.rs b/cli/tools/compile.rs
index c1f98bc08..3cc4414fc 100644
--- a/cli/tools/compile.rs
+++ b/cli/tools/compile.rs
@@ -54,6 +54,16 @@ pub async fn compile(
);
}
+ if cli_options.unstable_detect_cjs() {
+ log::warn!(
+ concat!(
+ "{} --unstable-detect-cjs is not properly supported in deno compile. ",
+ "The compiled executable may encounter runtime errors.",
+ ),
+ crate::colors::yellow("Warning"),
+ );
+ }
+
let output_path = resolve_compile_executable_output_path(
http_client,
&compile_flags,