Removed DEFAULT_ENV, can't be bothered to figure out deep merging.

This commit is contained in:
flash 2024-06-10 02:48:35 +00:00
parent 6c9b658860
commit 5b9d5c8cc5
3 changed files with 5 additions and 25 deletions

View file

@ -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',
},
},
};

View file

@ -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,
}));

View file

@ -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),