Skip to content

Commit

Permalink
fix: pass type to loader for .mjs / .cjs
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanprobst committed Jan 21, 2022
1 parent 908712a commit c021294
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/NormalModuleFactory.js
Expand Up @@ -1018,12 +1018,18 @@ If changing the source code is not an option there is also a resolve options cal
if (err) return callback(err);

const parsedResult = identToLoaderRequest(result);

const type = /\.mjs$/i.test(parsedResult.loader)
? "module"
: /\.cjs$/i.test(parsedResult.loader)
? "commonjs"
: resolveRequest.descriptionFileData === undefined
? undefined
: resolveRequest.descriptionFileData.type;

const resolved = {
loader: parsedResult.loader,
type:
resolveRequest.descriptionFileData === undefined
? undefined
: resolveRequest.descriptionFileData.type,
type,
options:
item.options === undefined
? parsedResult.options
Expand Down

0 comments on commit c021294

Please sign in to comment.