From 376658cee86a4f7ee4c4bdeed48589f3856c7e27 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Wed, 28 Feb 2024 12:49:52 +0100 Subject: [PATCH] fix(options): add `unwasm` condition when `experimental.wasm` is enabled --- src/options.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/options.ts b/src/options.ts index a152b51b75..b02720412d 100644 --- a/src/options.ts +++ b/src/options.ts @@ -378,7 +378,7 @@ export async function loadOptions( // Export conditions options.exportConditions = _resolveExportConditions( options.exportConditions, - { dev: options.dev, node: options.node } + { dev: options.dev, node: options.node, wasm: options.experimental.wasm } ); // Add open-api endpoint @@ -524,7 +524,7 @@ export function normalizeRouteRules( function _resolveExportConditions( conditions: string[] = [], - opts: { dev: boolean; node: boolean } + opts: { dev: boolean; node: boolean; wasm: boolean } ) { const resolvedConditions: string[] = []; @@ -553,7 +553,12 @@ function _resolveExportConditions( ); } - // 4. Add default conditions + // 4. Add unwasm conditions + if (opts.wasm) { + resolvedConditions.push("wasm", "unwasm"); + } + + // 5. Add default conditions resolvedConditions.push("import", "default"); // Dedup with preserving order