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

feat(jsr): support publishing jsr packages in npm workspaces #24507

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ console_static_text = "=0.8.1"
data-encoding = "2.3.3"
data-url = "=0.3.0"
deno_cache_dir = "=0.10.0"
deno_config = { version = "=0.20.4", default-features = false }
deno_config = { version = "=0.21.0", default-features = false }
dlopen2 = "0.6.1"
ecb = "=0.1.2"
elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] }
Expand Down
21 changes: 12 additions & 9 deletions cli/args/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1297,15 +1297,18 @@ impl CliOptions {
pub fn to_compiler_option_types(
&self,
) -> Result<Vec<deno_graph::ReferrerImports>, AnyError> {
self.workspace.to_maybe_imports().map(|maybe_imports| {
maybe_imports
.into_iter()
.map(|(referrer, imports)| deno_graph::ReferrerImports {
referrer,
imports,
})
.collect()
})
self
.workspace
.to_compiler_option_types()
.map(|maybe_imports| {
maybe_imports
.into_iter()
.map(|(referrer, imports)| deno_graph::ReferrerImports {
referrer,
imports,
})
.collect()
})
}

pub fn npmrc(&self) -> &Arc<ResolvedNpmRc> {
Expand Down
2 changes: 1 addition & 1 deletion cli/lsp/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ impl LspScopeResolver {
let npm_graph_resolver = graph_resolver.create_graph_npm_resolver();
let graph_imports = config_data
.and_then(|d| d.config_file.as_ref())
.and_then(|cf| cf.to_maybe_imports().ok())
.and_then(|cf| cf.to_compiler_option_types().ok())
.map(|imports| {
Arc::new(
imports
Expand Down
4 changes: 4 additions & 0 deletions tests/specs/publish/npm_workspace/__test__.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"args": "publish --dry-run",
"output": "publish.out"
}
3 changes: 3 additions & 0 deletions tests/specs/publish/npm_workspace/add/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function add(a: number, b: number): number {
return a + b;
}
5 changes: 5 additions & 0 deletions tests/specs/publish/npm_workspace/add/jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@scope/add",
"version": "1.0.0",
"exports": "./index.ts"
}
4 changes: 4 additions & 0 deletions tests/specs/publish/npm_workspace/add/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "add",
"version": "1.0.0"
}
3 changes: 3 additions & 0 deletions tests/specs/publish/npm_workspace/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"workspaces": ["./add", "./subtract"]
}
15 changes: 15 additions & 0 deletions tests/specs/publish/npm_workspace/publish.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Publishing a workspace...
Check file:///[WILDLINE]/npm_workspace/add/index.ts
Check file:///[WILDLINE]/npm_workspace/subtract/index.ts
Checking for slow types in the public API...
Check file:///[WILDLINE]/npm_workspace/add/index.ts
Check file:///[WILDLINE]/npm_workspace/subtract/index.ts
Simulating publish of @scope/add@1.0.0 with files:
file:///[WILDLINE]/npm_workspace/add/index.ts ([WILDLINE])
file:///[WILDLINE]/npm_workspace/add/jsr.json ([WILDLINE])
file:///[WILDLINE]/npm_workspace/add/package.json ([WILDLINE])
Simulating publish of @scope/subtract@1.0.0 with files:
file:///[WILDLINE]/npm_workspace/subtract/index.ts ([WILDLINE])
file:///[WILDLINE]/npm_workspace/subtract/jsr.json ([WILDLINE])
file:///[WILDLINE]/npm_workspace/subtract/package.json ([WILDLINE])
Warning Aborting due to --dry-run
3 changes: 3 additions & 0 deletions tests/specs/publish/npm_workspace/subtract/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export function subtract(a: number, b: number): number {
return a - b;
}
5 changes: 5 additions & 0 deletions tests/specs/publish/npm_workspace/subtract/jsr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "@scope/subtract",
"version": "1.0.0",
"exports": "./index.ts"
}
4 changes: 4 additions & 0 deletions tests/specs/publish/npm_workspace/subtract/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "subtract",
"version": "1.0.0"
}
Loading