Skip to content

Commit

Permalink
fix: prefer cjs output in Marko 5
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Aug 18, 2020
1 parent c8a62dd commit 44cd2fd
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/transform/create-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ import compiler from "marko/compiler";
import ConcatMap from "concat-with-sourcemaps";
import { Transformer } from "@jest/transform";
const THIS_FILE = fs.readFileSync(__filename);
const MARKO_OPTIONS = {
writeVersionComment: false,
requireTemplates: true,
writeToDisk: false,
sourceOnly: false,
sourceMaps: true,
modules: "cjs"
};

export = ({ browser }: { browser: boolean }) =>
({
Expand All @@ -30,13 +38,7 @@ export = ({ browser }: { browser: boolean }) =>
compiler.compileForBrowser /** Only Marko 4 supports compileForBrowser, otherwise use compile */
? "compileForBrowser"
: "compile"
](src, filename, {
writeVersionComment: false,
requireTemplates: true,
writeToDisk: false,
sourceOnly: false,
sourceMaps: true
});
](src, filename, MARKO_OPTIONS);

let code = typeof result === "string" ? result : result.code; // Marko 3 does not support sourceOnly: false
let map = result.map;
Expand Down

0 comments on commit 44cd2fd

Please sign in to comment.