Skip to content

Commit

Permalink
feat: add Marko 5 support
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed Mar 11, 2020
1 parent 9266029 commit 2c3fe61
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"lint": "tsc --noEmit && tslint -t codeFrame -c tslint.json '{src,test}/**/*.ts'",
"prepublishOnly": "npm run build",
"release": "standard-version",
"test": "jest"
"test": "npm run build && jest"
},
"types": "dist/index.d.ts"
}
19 changes: 17 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,30 @@ export = {
.digest("hex");
},
process(src, filename, config) {
return compiler[
const result = compiler[
config.browser &&
compiler.compileForBrowser /** Only Marko 4 supports compileForBrowser, otherwise use compile */
? "compileForBrowser"
: "compile"
](src, filename, {
writeVersionComment: false,
requireTemplates: true,
sourceOnly: true
writeToDisk: false,
sourceOnly: false,
sourceMaps: true
});

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

if (!map) {
return code;
}

return {
code,
map
};
},
canInstrument: false
} as Transformer;

0 comments on commit 2c3fe61

Please sign in to comment.