From 40b1c42138c47e89eefa859cd36a9e3d62541e7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Wed, 16 Oct 2024 00:25:24 +0100 Subject: fix: improve suggestions and hints when using CommonJS modules (#26287) Ref https://github.com/denoland/deno/issues/26225 --- tests/specs/run/import_common_js/module_error.out | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tests/specs/run/import_common_js/module_error.out') diff --git a/tests/specs/run/import_common_js/module_error.out b/tests/specs/run/import_common_js/module_error.out index 53a908d29..1c1140fe4 100644 --- a/tests/specs/run/import_common_js/module_error.out +++ b/tests/specs/run/import_common_js/module_error.out @@ -3,5 +3,10 @@ module.exports = { ^ at [WILDCARD]module_error.js:1:1 - info: Deno does not support CommonJS modules without `.cjs` extension. - hint: Rewrite this module to ESM or change the file extension to `.cjs`. + info: Deno supports CommonJS modules in .cjs files, or when there's a package.json + with "type": "commonjs" option and --unstable-detect-cjs flag is used. + hint: Rewrite this module to ESM, + or change the file extension to .cjs, + or add package.json next to the file with "type": "commonjs" option + and pass --unstable-detect-cjs flag. + hint: See https://docs.deno.com/go/commonjs for details -- cgit v1.2.3 From 28b5640657ce875a73eb3a1ffed287a61de164b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 22 Oct 2024 21:22:26 +0100 Subject: refactor: add 'docs' suggestion (#26463) Adds another kind to `FixSuggestionKind` specifically for links documentation pages. --- tests/specs/run/import_common_js/module_error.out | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/specs/run/import_common_js/module_error.out') diff --git a/tests/specs/run/import_common_js/module_error.out b/tests/specs/run/import_common_js/module_error.out index 1c1140fe4..654ee838d 100644 --- a/tests/specs/run/import_common_js/module_error.out +++ b/tests/specs/run/import_common_js/module_error.out @@ -9,4 +9,4 @@ module.exports = { or change the file extension to .cjs, or add package.json next to the file with "type": "commonjs" option and pass --unstable-detect-cjs flag. - hint: See https://docs.deno.com/go/commonjs for details + docs: https://docs.deno.com/go/commonjs -- cgit v1.2.3 From f091d1ad69b4e5217ae3272b641171781a372c4f Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 13 Nov 2024 10:10:09 -0500 Subject: feat(node): stabilize detecting if CJS via `"type": "commonjs"` in a package.json (#26439) This will respect `"type": "commonjs"` in a package.json to determine if `.js`/`.jsx`/`.ts`/.tsx` files are CJS or ESM. If the file is found to be ESM it will be loaded as ESM though. --- tests/specs/run/import_common_js/module_error.out | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'tests/specs/run/import_common_js/module_error.out') diff --git a/tests/specs/run/import_common_js/module_error.out b/tests/specs/run/import_common_js/module_error.out index 654ee838d..957b19cb1 100644 --- a/tests/specs/run/import_common_js/module_error.out +++ b/tests/specs/run/import_common_js/module_error.out @@ -3,10 +3,9 @@ module.exports = { ^ at [WILDCARD]module_error.js:1:1 - info: Deno supports CommonJS modules in .cjs files, or when there's a package.json - with "type": "commonjs" option and --unstable-detect-cjs flag is used. + info: Deno supports CommonJS modules in .cjs files, or when the closest + package.json has a "type": "commonjs" option. hint: Rewrite this module to ESM, or change the file extension to .cjs, - or add package.json next to the file with "type": "commonjs" option - and pass --unstable-detect-cjs flag. + or add package.json next to the file with "type": "commonjs" option. docs: https://docs.deno.com/go/commonjs -- cgit v1.2.3