diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/npm_tests.rs | 27 | ||||
-rw-r--r-- | tests/testdata/npm/imports_package_json/import_not_defined.out | 5 | ||||
-rw-r--r-- | tests/testdata/npm/imports_package_json/sub_path_import_not_defined.out | 5 |
3 files changed, 25 insertions, 12 deletions
diff --git a/tests/integration/npm_tests.rs b/tests/integration/npm_tests.rs index 33e331fc3..e4e06e830 100644 --- a/tests/integration/npm_tests.rs +++ b/tests/integration/npm_tests.rs @@ -2611,10 +2611,7 @@ fn cjs_rexport_analysis_json() { let dir = test_context.temp_dir(); dir.write("deno.json", r#"{ "unstable": [ "byonm" ] }"#); - dir.write( - "package.json", - r#"{ "name": "test", "packages": { "my-package": "1.0.0" } }"#, - ); + dir.write("package.json", r#"{ "name": "test" }"#); dir.write( "main.js", "import data from 'my-package';\nconsole.log(data);\n", @@ -2670,6 +2667,28 @@ fn cjs_rexport_analysis_json() { ); } +#[test] +fn cjs_export_analysis_import_cjs_directly_relative_import() { + let test_context = TestContextBuilder::for_npm().use_temp_cwd().build(); + let dir = test_context.temp_dir(); + dir.write("deno.json", r#"{ "unstable": [ "byonm" ] }"#); + + dir.write( + "package.json", + r#"{ "name": "test", "dependencies": { "@denotest/cjs-default-export": "1.0.0" } }"#, + ); + // previously it wasn't doing cjs export analysis on this file + dir.write( + "main.ts", + "import { named } from './node_modules/@denotest/cjs-default-export/index.js';\nconsole.log(named());\n", + ); + + test_context.run_npm("install"); + + let output = test_context.new_command().args("run main.ts").run(); + output.assert_matches_text("2\n"); +} + itest!(imports_package_json { args: "run --node-modules-dir=false npm/imports_package_json/main.js", output: "npm/imports_package_json/main.out", diff --git a/tests/testdata/npm/imports_package_json/import_not_defined.out b/tests/testdata/npm/imports_package_json/import_not_defined.out index 3580d9007..4cf72ef82 100644 --- a/tests/testdata/npm/imports_package_json/import_not_defined.out +++ b/tests/testdata/npm/imports_package_json/import_not_defined.out @@ -1,6 +1,3 @@ Download http://localhost:4545/npm/registry/@denotest/imports-package-json Download http://localhost:4545/npm/registry/@denotest/imports-package-json/1.0.0.tgz -error: Could not resolve '#not-defined' from 'file:///[WILDCARD]/@denotest/imports-package-json/1.0.0/import_not_defined.js'. - -Caused by: - [ERR_PACKAGE_IMPORT_NOT_DEFINED] Package import specifier "#not-defined" is not defined in package [WILDCARD]package.json imported from [WILDCARD]import_not_defined.js +error: [ERR_PACKAGE_IMPORT_NOT_DEFINED] Package import specifier "#not-defined" is not defined in package [WILDCARD]package.json imported from [WILDCARD]import_not_defined.js diff --git a/tests/testdata/npm/imports_package_json/sub_path_import_not_defined.out b/tests/testdata/npm/imports_package_json/sub_path_import_not_defined.out index 04a21c99e..1ce2a4c0e 100644 --- a/tests/testdata/npm/imports_package_json/sub_path_import_not_defined.out +++ b/tests/testdata/npm/imports_package_json/sub_path_import_not_defined.out @@ -1,6 +1,3 @@ Download http://localhost:4545/npm/registry/@denotest/imports-package-json Download http://localhost:4545/npm/registry/@denotest/imports-package-json/1.0.0.tgz -error: Could not resolve '#hi' from 'file:///[WILDCARD]/@denotest/imports-package-json/1.0.0/sub_path/import_not_defined.js'. - -Caused by: - [ERR_PACKAGE_IMPORT_NOT_DEFINED] Package import specifier "#hi" is not defined in package [WILDCARD]sub_path[WILDCARD]package.json imported from [WILDCARD]import_not_defined.js +error: [ERR_PACKAGE_IMPORT_NOT_DEFINED] Package import specifier "#hi" is not defined in package [WILDCARD]sub_path[WILDCARD]package.json imported from [WILDCARD]import_not_defined.js |