Skip to content

Commit 5df4f05

Browse files
author
Noah Negin-Ulster
committed
fix: give precedence to pnp over node_modules, close #288
1 parent f08fe3f commit 5df4f05

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

lib/ResolverFactory.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -399,14 +399,14 @@ exports.createResolver = function (options) {
399399
});
400400
modules.forEach(item => {
401401
if (Array.isArray(item)) {
402-
plugins.push(
403-
new ModulesInHierachicDirectoriesPlugin("raw-module", item, "module")
404-
);
405402
if (item.includes("node_modules") && pnpApi) {
406403
plugins.push(
407404
new PnpPlugin("raw-module", pnpApi, "undescribed-resolve-in-package")
408405
);
409406
}
407+
plugins.push(
408+
new ModulesInHierachicDirectoriesPlugin("raw-module", item, "module")
409+
);
410410
} else {
411411
plugins.push(new ModulesInRootPlugin("raw-module", item, "module"));
412412
}

test/pnp.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,17 +172,16 @@ describe("pnp", () => {
172172
}
173173
);
174174
});
175-
it("should prefer normal modules over pnp resolves", done => {
175+
it("should prefer pnp resolves over normal modules", done => {
176176
pnpApi.mocks.set("m1", path.resolve(fixture, "pkg"));
177177
resolver.resolve(
178178
{},
179179
path.resolve(__dirname, "fixtures"),
180180
"m1/a.js",
181181
{},
182-
(err, result) => {
183-
if (err) return done(err);
184-
result.should.equal(path.resolve(fixture, "../node_modules/m1/a.js"));
185-
done();
182+
err => {
183+
if (err) return done();
184+
done(new Error("Resolved by normal modules"));
186185
}
187186
);
188187
});

0 commit comments

Comments
 (0)