From 707d0b076f1bc6b6a4b3af1bf7a4d103243cc04f Mon Sep 17 00:00:00 2001 From: Katie Byers Date: Mon, 14 Nov 2022 09:21:34 -0800 Subject: [PATCH] restore querystring when making recursive `analyzeAndEmitDependency` call in `maybeEmitDep` --- src/node-file-trace.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/node-file-trace.ts b/src/node-file-trace.ts index 0869485f..41e0e31c 100644 --- a/src/node-file-trace.ts +++ b/src/node-file-trace.ts @@ -268,9 +268,16 @@ export class Job { // For simplicity, force `resolved` to be an array resolved = Array.isArray(resolved) ? resolved : [resolved]; - for (const item of resolved) { - // ignore builtins + for (let item of resolved) { + // ignore builtins for the purposes of both tracing and querystring handling (neither Node + // nor Webpack can handle querystrings on `node:xxx` imports). if (item.startsWith('node:')) return; + + // If querystring was stripped during resolution, restore it + if (queryString && !item.endsWith(queryString)) { + item += queryString; + } + await this.analyzeAndEmitDependency(item, path, cjsResolve); } }