Skip to content

Commit

Permalink
Merge pull request embroider-build#1391 from void-mAlex/self-package-…
Browse files Browse the repository at this point in the history
…loop-detection

only rehome a request if it would resolve in a different package
  • Loading branch information
ef4 committed May 2, 2023
2 parents e2cd385 + 340ef7d commit e35628d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/core/src/module-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ class NodeModuleRequest implements ModuleRequest {
return new NodeModuleRequest(specifier, this.fromFile) as this;
}
rehome(fromFile: string): this {
return new NodeModuleRequest(this.specifier, fromFile) as this;
if (this.fromFile === fromFile) {
return this;
} else {
return new NodeModuleRequest(this.specifier, fromFile) as this;
}
}
virtualize(filename: string) {
return new NodeModuleRequest(filename, this.fromFile, true) as this;
Expand Down
10 changes: 7 additions & 3 deletions packages/webpack/src/webpack-resolver-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,13 @@ class WebpackModuleRequest implements ModuleRequest {
return new WebpackModuleRequest(this.babelLoaderPrefix, this.state) as this;
}
rehome(newFromFile: string) {
this.state.contextInfo.issuer = newFromFile;
this.state.context = dirname(newFromFile);
return new WebpackModuleRequest(this.babelLoaderPrefix, this.state) as this;
if (this.fromFile === newFromFile) {
return this;
} else {
this.state.contextInfo.issuer = newFromFile;
this.state.context = dirname(newFromFile);
return new WebpackModuleRequest(this.babelLoaderPrefix, this.state) as this;
}
}
virtualize(filename: string) {
let next = this.alias(`${this.babelLoaderPrefix}${virtualLoaderName}?${filename}!`);
Expand Down

0 comments on commit e35628d

Please sign in to comment.