diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index a46551c..dc3d3b7 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -206,7 +206,7 @@ jobs: RUSTUP_IO_THREADS: 1 with: operating_system: freebsd - version: '14.0' + version: '14.1' memory: 8G cpu_count: 3 environment_variables: 'DEBUG RUSTUP_IO_THREADS' @@ -257,6 +257,7 @@ jobs: node: - '18' - '20' + - '22' transform_all: - 'true' - 'false' @@ -307,6 +308,7 @@ jobs: node: - '18' - '20' + - '22' exclude: # too slow - target: aarch64-unknown-linux-gnu diff --git a/packages/core/index.d.ts b/packages/core/index.d.ts index 9455638..2ed11e9 100644 --- a/packages/core/index.d.ts +++ b/packages/core/index.d.ts @@ -23,7 +23,7 @@ export interface LoadContext { /** Export conditions of the relevant `package.json` */ conditions?: Array /** The format optionally supplied by the `resolve` hook chain */ - format: string + format: string | null /** An object whose key-value pairs represent the assertions for the module to import */ importAttributes: Record } diff --git a/src/lib.rs b/src/lib.rs index bea0277..5479c92 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -464,7 +464,7 @@ pub struct LoadContext { /// Export conditions of the relevant `package.json` pub conditions: Option>, /// The format optionally supplied by the `resolve` hook chain - pub format: String, + pub format: Either, /// An object whose key-value pairs represent the assertions for the module to import pub import_attributes: HashMap, } @@ -487,11 +487,12 @@ pub fn load( >, ) -> Result>> { tracing::debug!(url = ?url, context = ?context, "load"); - if url.starts_with("data:") - || context.format == "builtin" - || context.format == "json" - || context.format == "wasm" - { + if url.starts_with("data:") || { + match context.format { + Either::A(ref format) => format == "builtin" || format == "json" || format == "wasm", + _ => true, + } + } { tracing::debug!("short-circuiting load: {}", url); return next_load.call((url, Some(context))); }