Skip to content

Commit

Permalink
fix: bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander-akait committed Apr 18, 2023
1 parent 98b976e commit 65d1742
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/NormalModuleFactory.js
Expand Up @@ -1022,9 +1022,9 @@ If changing the source code is not an option there is also a resolve options cal

const parsedResult = this._parseResourceWithoutFragment(result);

const type = /\.mjs$/i.test(parsedResult.loader)
const type = /\.mjs$/i.test(parsedResult.path)
? "module"
: /\.cjs$/i.test(parsedResult.loader)
: /\.cjs$/i.test(parsedResult.path)
? "commonjs"
: resolveRequest.descriptionFileData === undefined
? undefined
Expand Down
8 changes: 4 additions & 4 deletions test/cases/loaders/cjs-loader-type/index.js
@@ -1,11 +1,11 @@
it("should pass package.json type to loader", function () {
// expect(require("cjs/loader.js!")).toBe("commonjs");
// expect(require("./loader.js!")).toBe("undefined");
expect(require("cjs/loader.js!")).toBe("commonjs");
expect(require("./loader.js!")).toBe("undefined");
});

it("should pass 'commonjs' type to loader for .cjs", function () {
// expect(require("cjs/loader.cjs!")).toBe("commonjs");
expect(require("./loader.cjs!")).toBe("undefined");
expect(require("cjs/loader.cjs!")).toBe("commonjs");
expect(require("./loader.cjs!")).toBe("commonjs");
// TODO need fix in v8 https://github.com/nodejs/node/issues/35889
// TODO otherwise this test case cause segment fault
// expect(require("esm/loader.cjs!")).toBe("commonjs");
Expand Down

0 comments on commit 65d1742

Please sign in to comment.