diff --git a/src/handlers/js.js b/src/handlers/js.js index 70dff10..8f2d29d 100644 --- a/src/handlers/js.js +++ b/src/handlers/js.js @@ -11,7 +11,7 @@ module.exports = function(env) { const createJscOpts = () => { return { - target: env.swc.es, + target: env.swc?.es ?? 'es2021', loose: false, externalHelpers: false, keepClassNames: true, @@ -19,7 +19,7 @@ module.exports = function(env) { transform: {}, parser: { syntax: 'ecmascript', - jsx: env.swc.jsx !== false, + jsx: env.swc?.jsx !== false, dynamicImport: false, privateMethod: false, functionBind: false, @@ -33,7 +33,7 @@ module.exports = function(env) { transform: { react: { runtime: 'classic', - pragma: env.swc.jsx || '', + pragma: env.swc?.jsx ?? '$er', }, }, }; diff --git a/src/handlers/twig.js b/src/handlers/twig.js index 7fccbe3..e491417 100644 --- a/src/handlers/twig.js +++ b/src/handlers/twig.js @@ -22,8 +22,8 @@ module.exports = function(env) { return { process: async (task, vars) => { - let { stdout, stderr } = await exec(strtr(env.twig.cmdFormat, { - ':command': env.twig.cmdPathFull ?? pathJoin(env.root, env.twig.cmdPath), + let { stdout, stderr } = await exec(strtr(env.twig?.cmdFormat ?? ':command :path', { + ':command': env.twig?.cmdPathFull ?? pathJoin(env.root, env.twig?.cmdPath ?? 'tools/render-tpl'), ':path': task.source, })); diff --git a/src/index.js b/src/index.js index 24a5bdb..2f0b737 100644 --- a/src/index.js +++ b/src/index.js @@ -5,24 +5,6 @@ const apTwig = require('./handlers/twig.js'); const apWebManifest = require('./handlers/webmanifest.js'); const { housekeep } = require('./housekeep.js'); -const DEFAULT_ENV = { - debug: false, - source: undefined, - public: undefined, - order: undefined, - vars: undefined, - housekeep: undefined, - swc: { - es: 'es2021', - jsx: '$er', - }, - twig: { - cmdFormat: ':command :path', - cmdPathFull: undefined, - cmdPath: 'tools/render-tpl', - }, -}; - module.exports.process = async (env, tasks) => { if(typeof env.source !== 'string') throw 'env.source must be a path to the source directories'; @@ -32,8 +14,6 @@ module.exports.process = async (env, tasks) => { if(typeof tasks !== 'object' || tasks === null) throw 'tasks must be a non-null object'; - env = { ...DEFAULT_ENV, ...env }; - const types = { js: new apJs(env), css: new apCss(env),