Skip to content

Commit

Permalink
preserve querystring in emitDependency
Browse files Browse the repository at this point in the history
  • Loading branch information
lobsterkatie committed Nov 3, 2022
1 parent 428cc8f commit 02170de
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/node-file-trace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ export class Job {
await this.emitFile(asset, 'asset', path);
}),
...[...deps].map(async dep => {
const queryString = dep.split("?")[1]
try {
var resolved = await this.resolve(dep, path, this, !isESM);
}
Expand All @@ -363,15 +364,27 @@ export class Job {
return;
}
if (Array.isArray(resolved)) {
for (const item of resolved) {
for (let item of resolved) {
// ignore builtins
if (item.startsWith('node:')) return;
// Dependencies which differ only by querystring are considered separate dependencies by
// webpack, and therefore need to be treated separately here, too. Resolution can strip
// the querystring off, in which case we need to put it back on to preserve the distinction.
if (queryString && !item.includes(queryString)) {
item += `?${queryString}`
}
await this.emitDependency(item, path);
}
}
else {
// ignore builtins
if (resolved.startsWith('node:')) return;
// Dependencies which differ only by querystring are considered separate dependencies by
// webpack, and therefore need to be treated separately here, too. Resolution can strip
// the querystring off, in which case we need to put it back on to preserve the distinction.
if (queryString && !resolved.includes(queryString)) {
resolved += `?${queryString}`
}
await this.emitDependency(resolved, path);
}
}),
Expand Down

0 comments on commit 02170de

Please sign in to comment.