Skip to content

Commit

Permalink
chore: fix deno_resolver non-sync build (#27824)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jan 27, 2025
1 parent 4e655e5 commit 48e86c7
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 10 deletions.
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
5 changes: 2 additions & 3 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 @@ -128,7 +128,7 @@ data-encoding = "2.3.3"
data-url = "=0.3.1"
deno_cache_dir = "=0.17.0"
deno_error = "=0.5.5"
deno_package_json = { version = "=0.4.1", default-features = false }
deno_package_json = { version = "=0.4.2", default-features = false }
deno_unsync = "0.4.2"
dlopen2 = "0.6.1"
ecb = "=0.1.2"
Expand Down
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
31 changes: 26 additions & 5 deletions resolvers/node/package_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,33 @@ 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
+ std::fmt::Debug
+ 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
+ std::fmt::Debug
+ crate::sync::MaybeSend
+ crate::sync::MaybeSync,
>;
{
fn as_deno_package_json_cache(
&self,
) -> &dyn deno_package_json::PackageJsonCache {
self
}
}

#[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 +114,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

0 comments on commit 48e86c7

Please sign in to comment.