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

chore: fix deno_resolver non-sync build #27824

Merged
merged 5 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
20 changes: 20 additions & 0 deletions .github/workflows/ci.generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,26 @@ const ci = {
},
]),
},
wasm: {
name: "build wasm32",
needs: ["pre_build"],
if: "${{ needs.pre_build.outputs.skip_build != 'true' }}",
"runs-on": ubuntuX86Runner,
"timeout-minutes": 30,
steps: skipJobsIfPrAndMarkedSkip([
...cloneRepoStep,
installRustStep,
{
name: "Install wasm target",
run: "rustup target add wasm32-unknown-unknown",
},
{
name: "Cargo build",
// we want this crate to be wasm compatible
run: "cargo build --target wasm32-unknown-unknown -p deno_resolver",
},
]),
},
"publish-canary": {
name: "publish canary",
"runs-on": ubuntuX86Runner,
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,33 @@ jobs:
!./target/*/*.zip
!./target/*/*.tar.gz
key: '37-cargo-target-${{ matrix.os }}-${{ matrix.arch }}-${{ matrix.profile }}-${{ matrix.job }}-${{ github.sha }}'
wasm:
name: build wasm32
needs:
- pre_build
if: '${{ needs.pre_build.outputs.skip_build != ''true'' }}'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Configure git
run: |-
git config --global core.symlinks true
git config --global fetch.parallel 32
if: '!(matrix.skip)'
- name: Clone repository
uses: actions/checkout@v4
with:
fetch-depth: 5
submodules: false
if: '!(matrix.skip)'
- uses: dsherret/rust-toolchain-file@v1
if: '!(matrix.skip)'
- name: Install wasm target
run: rustup target add wasm32-unknown-unknown
if: '!(matrix.skip)'
- name: Cargo build
run: cargo build --target wasm32-unknown-unknown -p deno_resolver
if: '!(matrix.skip)'
publish-canary:
name: publish canary
runs-on: ubuntu-24.04
Expand Down
1 change: 0 additions & 1 deletion Cargo.lock

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

1 change: 0 additions & 1 deletion resolvers/node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ serde.workspace = true
serde_json.workspace = true
sys_traits.workspace = true
thiserror.workspace = true
tokio.workspace = true
url.workspace = true
29 changes: 24 additions & 5 deletions resolvers/node/package_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,31 @@ use url::Url;
use crate::errors::ClosestPkgJsonError;
use crate::errors::PackageJsonLoadError;

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<
dyn deno_package_json::PackageJsonCache
pub trait NodePackageJsonCache:
deno_package_json::PackageJsonCache
+ crate::sync::MaybeSend
+ crate::sync::MaybeSync
{
fn as_deno_package_json_cache(
&self,
) -> &dyn deno_package_json::PackageJsonCache;
}

impl<T> NodePackageJsonCache for T
where
T: deno_package_json::PackageJsonCache
+ crate::sync::MaybeSend
+ crate::sync::MaybeSync,
Copy link
Member Author

Choose a reason for hiding this comment

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

Error was:

  --> V:\deno\resolvers\node\package_json.rs:20:7
   |
19 |   dyn deno_package_json::PackageJsonCache
   |       ----------------------------------- first non-auto trait
20 |     + crate::sync::MaybeSend
   |       ^^^^^^^^^^^^^^^^^^^^^^ additional non-auto trait

>;
{
fn as_deno_package_json_cache(
&self,
) -> &dyn deno_package_json::PackageJsonCache {
self
}
}
dsherret marked this conversation as resolved.
Show resolved Hide resolved

#[allow(clippy::disallowed_types)]
pub type PackageJsonCacheRc = crate::sync::MaybeArc<dyn NodePackageJsonCache>;

thread_local! {
static CACHE: RefCell<HashMap<PathBuf, PackageJsonRc>> = RefCell::new(HashMap::new());
Expand Down Expand Up @@ -93,7 +112,7 @@ impl<TSys: FsRead> PackageJsonResolver<TSys> {
self
.loader_cache
.as_deref()
.map(|cache| cache as &dyn deno_package_json::PackageJsonCache),
.map(|cache| cache.as_deno_package_json_cache()),
path,
);
match result {
Expand Down
Loading