Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(publish): unfurling should always be done with the package json #24435

Merged
merged 6 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix(publish): always use pkg json dep resolution
  • Loading branch information
dsherret committed Jul 4, 2024
commit 44c37de099b045079b08b119d1ab6404730c1cf0
11 changes: 9 additions & 2 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1102,10 1102,17 @@ impl CliOptions {
.workspace
.create_resolver(
CreateResolverOptions {
// todo(dsherret): this should be false for nodeModulesDir: true
pkg_json_dep_resolution: if self.use_byonm() {
pkg_json_dep_resolution: if matches!(
self.flags.subcommand,
DenoSubcommand::Publish(..)
) {
// always use package.json dep resolution when publishing so that the
// unfurler can map dependencies to what's found in a package.json
PackageJsonDepResolution::Enabled
} else if self.use_byonm() {
PackageJsonDepResolution::Disabled
} else {
// todo(dsherret): this should be false for nodeModulesDir: true
PackageJsonDepResolution::Enabled
},
specified_import_map: cli_arg_specified_import_map,
Expand Down
6 changes: 6 additions & 0 deletions cli/tools/registry/unfurl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 148,12 @@ impl<'a> SpecifierUnfurler<'a> {
if relative_resolved == specifier {
None // nothing to unfurl
} else {
log::debug!(
"Unfurled specifier: {} from {} -> {}",
specifier,
referrer,
relative_resolved
);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in the example repo:

deno::tools::registry::unfurl:156 - Unfurled specifier: lodash from file:///.../jsr-publish-fails-repro/src/index.ts -> npm:lodash@^4.17.21

Some(relative_resolved)
}
}
Expand Down
1 change: 1 addition & 0 deletions cli/util/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 41,7 @@ pub fn init(maybe_level: Option<log::Level>) {
// wgpu crates (gfx_backend), have a lot of useless INFO and WARN logs
.filter_module("wgpu", log::LevelFilter::Error)
.filter_module("gfx", log::LevelFilter::Error)
.filter_module("globset", log::LevelFilter::Error)
// used to make available the lsp_debug which is then filtered out at runtime
// in the cli logger
.filter_module("deno::lsp::performance", log::LevelFilter::Debug)
Expand Down
13 changes: 13 additions & 0 deletions tests/specs/publish/byonm_with_package_json/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 1,13 @@
{
"envs": {
"DENO_FUTURE": "1"
},
"tempDir": true,
"steps": [{
"args": "install",
"output": "[WILDCARD]"
}, {
"args": "publish --log-level=debug --dry-run --allow-dirty",
"output": "publish.out"
}]
}
12 changes: 12 additions & 0 deletions tests/specs/publish/byonm_with_package_json/jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 1,12 @@
{
"name": "@scope/package",
"version": "0.0.0",
"exports": {
".": "./src/index.ts"
},
"publish": {
"include": [
"src/**/*"
]
}
}
8 changes: 8 additions & 0 deletions tests/specs/publish/byonm_with_package_json/package.json
Original file line number Diff line number Diff line change
@@ -0,0 1,8 @@
{
"name": "@scope/pkg",
"module": "src/index.ts",
"type": "module",
"dependencies": {
"@denotest/add": "1"
}
}
3 changes: 3 additions & 0 deletions tests/specs/publish/byonm_with_package_json/publish.out
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
[WILDCARD]Unfurled specifier: @denotest/add from file:///V:/deno/tests/specs/publish/byonm_with_package_json/src/index.ts -> npm:@denotest/add@1
[WILDCARD]
Warning Aborting due to --dry-run
3 changes: 3 additions & 0 deletions tests/specs/publish/byonm_with_package_json/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 1,3 @@
import { add } from "@denotest/add";

console.log(add(1, 2));
Loading