From 33c4d45328166d103e99a8c243727eead626080c Mon Sep 17 00:00:00 2001 From: Luca Casonato Date: Wed, 24 Aug 2022 19:36:05 +0200 Subject: fix: resolve `jsxImportSource` relative to module (#15561) Previously `jsxImportSource` was resolved relative to the config file during graph building, and relative to the emitted module during runtime. This is now fixed so that the JSX import source is resolved relative to the module both during graph building and at runtime. --- cli/tests/integration/run_tests.rs | 12 ++++++++++++ cli/tests/testdata/jsx/import-map-scoped.json | 8 ++++++++ cli/tests/testdata/jsx_import_source_error.out | 2 +- cli/tests/testdata/subdir/jsx_import_source_no_pragma.tsx | 7 +++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 cli/tests/testdata/jsx/import-map-scoped.json create mode 100644 cli/tests/testdata/subdir/jsx_import_source_no_pragma.tsx (limited to 'cli/tests') diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs index 8998eecc9..20661f27f 100644 --- a/cli/tests/integration/run_tests.rs +++ b/cli/tests/integration/run_tests.rs @@ -1337,6 +1337,18 @@ itest!(jsx_import_source_import_map_dev { http_server: true, }); +itest!(jsx_import_source_import_map_scoped { + args: "run --reload --import-map jsx/import-map-scoped.json --config jsx/deno-jsx-import-map.jsonc subdir/jsx_import_source_no_pragma.tsx", + output: "jsx_import_source_import_map.out", + http_server: true, +}); + +itest!(jsx_import_source_import_map_scoped_dev { + args: "run --reload --import-map jsx/import-map-scoped.json --config jsx/deno-jsxdev-import-map.jsonc subdir/jsx_import_source_no_pragma.tsx", + output: "jsx_import_source_import_map_dev.out", + http_server: true, +}); + itest!(jsx_import_source_pragma_no_check { args: "run --reload --no-check jsx_import_source_pragma.tsx", output: "jsx_import_source.out", diff --git a/cli/tests/testdata/jsx/import-map-scoped.json b/cli/tests/testdata/jsx/import-map-scoped.json new file mode 100644 index 000000000..9b2005128 --- /dev/null +++ b/cli/tests/testdata/jsx/import-map-scoped.json @@ -0,0 +1,8 @@ +{ + "scopes": { + "../subdir/": { + "jsx/jsx-runtime": "http://localhost:4545/jsx/jsx-runtime/index.ts", + "jsx/jsx-dev-runtime": "http://localhost:4545/jsx/jsx-dev-runtime/index.ts" + } + } +} diff --git a/cli/tests/testdata/jsx_import_source_error.out b/cli/tests/testdata/jsx_import_source_error.out index 957fa4a97..634a5b09b 100644 --- a/cli/tests/testdata/jsx_import_source_error.out +++ b/cli/tests/testdata/jsx_import_source_error.out @@ -1,2 +1,2 @@ error: Module not found "file:///[WILDCARD]/nonexistent/jsx-runtime". - at file:///[WILDCARD]/deno-jsx-error.jsonc:1:1 + at file:///[WILDCARD]/jsx_import_source_no_pragma.tsx:1:1 diff --git a/cli/tests/testdata/subdir/jsx_import_source_no_pragma.tsx b/cli/tests/testdata/subdir/jsx_import_source_no_pragma.tsx new file mode 100644 index 000000000..2c756054f --- /dev/null +++ b/cli/tests/testdata/subdir/jsx_import_source_no_pragma.tsx @@ -0,0 +1,7 @@ +function A() { + return "hello"; +} + +export function B() { + return ; +} -- cgit v1.2.3