mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix(node): resolve .css files in npm packages when type checking (#22804)
When type checking, we should just resolve css files in npm packages and not surface a type checking error on the specifier.
This commit is contained in:
parent
8fdc376b4a
commit
fee4943f76
4 changed files with 30 additions and 0 deletions
|
@ -518,6 +518,10 @@ impl NodeResolver {
|
|||
return Some(path);
|
||||
}
|
||||
}
|
||||
// allow resolving .css files for types resolution
|
||||
if lowercase_path.ends_with(".css") {
|
||||
return Some(path);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -2551,6 +2551,22 @@ console.log(getValue());
|
|||
output.assert_matches_text("Check file:///[WILDCARD]/main.ts\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_css_package_json_exports() {
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
let dir = test_context.temp_dir();
|
||||
dir.write(
|
||||
"main.ts",
|
||||
r#"import "npm:@denotest/css-export/dist/index.css";"#,
|
||||
);
|
||||
test_context
|
||||
.new_command()
|
||||
.args("check main.ts")
|
||||
.run()
|
||||
.assert_matches_text("Download [WILDCARD]css-export\nDownload [WILDCARD]css-export/1.0.0.tgz\nCheck [WILDCARD]/main.ts\n")
|
||||
.assert_exit_code(0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cjs_export_analysis_require_re_export() {
|
||||
let test_context = TestContextBuilder::for_npm().use_temp_cwd().build();
|
||||
|
|
1
tests/testdata/npm/registry/@denotest/css-export/1.0.0/dist/index.css
vendored
Normal file
1
tests/testdata/npm/registry/@denotest/css-export/1.0.0/dist/index.css
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
body {}
|
9
tests/testdata/npm/registry/@denotest/css-export/1.0.0/package.json
vendored
Normal file
9
tests/testdata/npm/registry/@denotest/css-export/1.0.0/package.json
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"name": "@denotest/css-export",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./index.js",
|
||||
"./dist/*": "./dist/*"
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue