1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

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

Supports publishing an npm workspace with a directory structure similar
to the following:

- workspace
  - package.json
  - package-a
    - package.json
    - jsr.json
  - package-b
    - package.json
    - jsr.json

deno_config PR: https://github.com/denoland/deno_config/pull/77

Closes https://github.com/denoland/deno/issues/23638
This commit is contained in:
David Sherret 2024-07-10 14:46:09 -04:00 committed by GitHub
parent 69afa8718f
commit 4d2d764816
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 62 additions and 13 deletions

4
Cargo.lock generated
View file

@ -1308,9 +1308,9 @@ dependencies = [
[[package]] [[package]]
name = "deno_config" name = "deno_config"
version = "0.20.4" version = "0.21.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96119386ea33783e2a35a3f0c5a960f88edda53f34df9594c9bb8017dcae2367" checksum = "47d457bbaff2200897ab1f635863c477f10524412a1f568535ea26763b96d5c9"
dependencies = [ dependencies = [
"anyhow", "anyhow",
"deno_semver", "deno_semver",

View file

@ -101,7 +101,7 @@ console_static_text = "=0.8.1"
data-encoding = "2.3.3" data-encoding = "2.3.3"
data-url = "=0.3.0" data-url = "=0.3.0"
deno_cache_dir = "=0.10.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" dlopen2 = "0.6.1"
ecb = "=0.1.2" ecb = "=0.1.2"
elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] } elliptic-curve = { version = "0.13.4", features = ["alloc", "arithmetic", "ecdh", "std", "pem"] }

View file

@ -1297,15 +1297,18 @@ impl CliOptions {
pub fn to_compiler_option_types( pub fn to_compiler_option_types(
&self, &self,
) -> Result<Vec<deno_graph::ReferrerImports>, AnyError> { ) -> Result<Vec<deno_graph::ReferrerImports>, AnyError> {
self.workspace.to_maybe_imports().map(|maybe_imports| { self
maybe_imports .workspace
.into_iter() .to_compiler_option_types()
.map(|(referrer, imports)| deno_graph::ReferrerImports { .map(|maybe_imports| {
referrer, maybe_imports
imports, .into_iter()
}) .map(|(referrer, imports)| deno_graph::ReferrerImports {
.collect() referrer,
}) imports,
})
.collect()
})
} }
pub fn npmrc(&self) -> &Arc<ResolvedNpmRc> { pub fn npmrc(&self) -> &Arc<ResolvedNpmRc> {

View file

@ -115,7 +115,7 @@ impl LspScopeResolver {
let npm_graph_resolver = graph_resolver.create_graph_npm_resolver(); let npm_graph_resolver = graph_resolver.create_graph_npm_resolver();
let graph_imports = config_data let graph_imports = config_data
.and_then(|d| d.config_file.as_ref()) .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| { .map(|imports| {
Arc::new( Arc::new(
imports imports

View file

@ -0,0 +1,4 @@
{
"args": "publish --dry-run",
"output": "publish.out"
}

View file

@ -0,0 +1,3 @@
export function add(a: number, b: number): number {
return a + b;
}

View file

@ -0,0 +1,5 @@
{
"name": "@scope/add",
"version": "1.0.0",
"exports": "./index.ts"
}

View file

@ -0,0 +1,4 @@
{
"name": "add",
"version": "1.0.0"
}

View file

@ -0,0 +1,3 @@
{
"workspaces": ["./add", "./subtract"]
}

View file

@ -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

View file

@ -0,0 +1,3 @@
export function subtract(a: number, b: number): number {
return a - b;
}

View file

@ -0,0 +1,5 @@
{
"name": "@scope/subtract",
"version": "1.0.0",
"exports": "./index.ts"
}

View file

@ -0,0 +1,4 @@
{
"name": "subtract",
"version": "1.0.0"
}