From 8c7f5e6313ec8898052bc32e1ef04d40c931696b Mon Sep 17 00:00:00 2001 From: Dylan Piercey Date: Thu, 24 Oct 2019 12:28:30 -0700 Subject: [PATCH] feat: add support for Marko 3 --- package.json | 2 +- src/index.ts | 17 +++++++++-------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 4fc7f40..4853a05 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "license": "MIT", "main": "dist/index.js", "peerDependencies": { - "marko": "^4" + "marko": "^3 || ^4" }, "repository": { "type": "git", diff --git a/src/index.ts b/src/index.ts index c237165..b1d4429 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,14 +23,15 @@ export = { .digest("hex"); }, process(src, filename, config) { - return compiler[config.browser ? "compileForBrowser" : "compile"]( - src, - filename, - { - requireTemplates: true, - sourceOnly: true - } - ); + return compiler[ + config.browser && + compiler.compileForBrowser /** Only Marko 4 supports compileForBrowser, otherwise use compile */ + ? "compileForBrowser" + : "compile" + ](src, filename, { + requireTemplates: true, + sourceOnly: true + }); }, canInstrument: false } as Transformer;