Skip to content

Commit 1fbbaad

Browse files
authored
Merge branch 'main' into renovate/pnpm-package-manager
2 parents ebbb0a6 + 0e6217d commit 1fbbaad

17 files changed

Lines changed: 527 additions & 139 deletions

File tree

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,15 @@ jobs:
209209
- run: cargo test --all-features
210210
env:
211211
RUST_MIN_STACK: 8388608
212-
- name: Test Node Bindings
212+
- name: Build Node Bindings
213+
run: npm run build:binding:debug
214+
- name: Test
215+
run: npm test
216+
- name: Git status check
213217
run: |
214-
npm run build:binding:debug
215-
npm test
218+
npm run format
219+
if [[ -n "$(git status --porcelain)" ]]; then
220+
echo "Working tree is dirty after tests/build. Please commit or revert the following changes:"
221+
git status --short
222+
exit 1
223+
fi

.husky/pre-commit

100644100755
File mode changed.

benches/resolver.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use std::{
2+
alloc::{GlobalAlloc, Layout, System},
23
env, fs,
34
fs::read_to_string,
45
future::Future,
@@ -7,6 +8,24 @@ use std::{
78
sync::Arc,
89
};
910

11+
#[global_allocator]
12+
static GLOBAL: NeverGrowInPlaceAllocator = NeverGrowInPlaceAllocator;
13+
14+
/// Delegates `alloc`/`dealloc` to [`System`] but omits [`GlobalAlloc::realloc`],
15+
/// forcing the default "alloc-new + copy + dealloc-old" path so that benchmarks
16+
/// never benefit from non-deterministic in-place growth provided by `libc::realloc`.
17+
struct NeverGrowInPlaceAllocator;
18+
19+
unsafe impl GlobalAlloc for NeverGrowInPlaceAllocator {
20+
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
21+
unsafe { System.alloc(layout) }
22+
}
23+
24+
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
25+
unsafe { System.dealloc(ptr, layout) }
26+
}
27+
}
28+
1029
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
1130
use rspack_resolver::{FileSystemOptions, FileSystemOs, ResolveOptions, Resolver};
1231
use serde_json::Value;

fixtures/enhanced_resolve/test/fixtures/imports-field/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"version": "1.0.0",
44
"exports": "./a.js",
55
"imports": {
6+
"#/*": "./src/*.js",
67
"#imports-field": "./b.js",
78
"#b": "../b.js",
89
"#ccc/": "c/",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = "foo";

napi/index.d.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ export interface NapiResolveOptions {
194194
* Default `false`
195195
*/
196196
enablePnp?: boolean;
197+
/**
198+
* Whether to enable `NODE_PATH` support
199+
*
200+
* Default `false`
201+
*/
202+
nodePath?: boolean;
197203
}
198204

199205
export interface ResolveResult {

napi/index.js

Lines changed: 58 additions & 54 deletions
Large diffs are not rendered by default.

napi/resolver.wasi.cjs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ if (__nodeFs.existsSync(__wasmDebugFilePath)) {
4242
__wasmFilePath = __wasmDebugFilePath;
4343
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
4444
try {
45-
__wasmFilePath = __nodePath.resolve("@rspack/resolver-binding-wasm32-wasi");
45+
__wasmFilePath =
46+
require.resolve("@rspack/resolver-binding-wasm32-wasi/resolver.wasm32-wasi.wasm");
4647
} catch {
4748
throw new Error(
4849
"Cannot find resolver.wasm32-wasi.wasm file, and @rspack/resolver-binding-wasm32-wasi package is not installed."

napi/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ impl ResolverFactory {
215215
symlinks: op.symlinks.unwrap_or(default.symlinks),
216216
builtin_modules: op.builtin_modules.unwrap_or(default.builtin_modules),
217217
enable_pnp: op.enable_pnp.unwrap_or_default(),
218+
node_path: op.node_path.unwrap_or_default(),
218219
}
219220
}
220221
}

0 commit comments

Comments
 (0)