Skip to content

Commit

Permalink
fix(cjs): hotfix babel transformation issue
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Nov 15, 2023
1 parent fa526fe commit 94444df
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/loaders/js.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ export const jsLoader: Loader = async (input, { options }) => {
if (isCjs) {
contents = jiti("")
.transform({ source: contents, retainLines: false })
.replace(/^exports.default = /gm, "module.exports = ");
.replace(/^exports.default = /gm, "module.exports = ")
.replace(/^var _default = exports.default = /gm, "module.exports = ")
.replace("module.exports = void 0;", "");
}

let extension = isCjs ? ".js" : ".mjs";
Expand Down

0 comments on commit 94444df

Please sign in to comment.