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 = () => { const createJscOpts = () => {
return { return {
target: env.swc.es, target: env.swc?.es ?? 'es2021',
loose: false, loose: false,
externalHelpers: false, externalHelpers: false,
keepClassNames: true, keepClassNames: true,
@ -19,7 +19,7 @@ module.exports = function(env) {
transform: {}, transform: {},
parser: { parser: {
syntax: 'ecmascript', syntax: 'ecmascript',
jsx: env.swc.jsx !== false, jsx: env.swc?.jsx !== false,
dynamicImport: false, dynamicImport: false,
privateMethod: false, privateMethod: false,
functionBind: false, functionBind: false,
@ -33,7 +33,7 @@ module.exports = function(env) {
transform: { transform: {
react: { react: {
runtime: 'classic', runtime: 'classic',
pragma: env.swc.jsx || '', pragma: env.swc?.jsx ?? '$er',
}, },
}, },
}; };

View file

@ -22,8 +22,8 @@ module.exports = function(env) {
return { return {
process: async (task, vars) => { process: async (task, vars) => {
let { stdout, stderr } = await exec(strtr(env.twig.cmdFormat, { let { stdout, stderr } = await exec(strtr(env.twig?.cmdFormat ?? ':command :path', {
':command': env.twig.cmdPathFull ?? pathJoin(env.root, env.twig.cmdPath), ':command': env.twig?.cmdPathFull ?? pathJoin(env.root, env.twig?.cmdPath ?? 'tools/render-tpl'),
':path': task.source, ':path': task.source,
})); }));

View file

@ -5,24 +5,6 @@ const apTwig = require('./handlers/twig.js');
const apWebManifest = require('./handlers/webmanifest.js'); const apWebManifest = require('./handlers/webmanifest.js');
const { housekeep } = require('./housekeep.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) => { module.exports.process = async (env, tasks) => {
if(typeof env.source !== 'string') if(typeof env.source !== 'string')
throw 'env.source must be a path to the source directories'; 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) if(typeof tasks !== 'object' || tasks === null)
throw 'tasks must be a non-null object'; throw 'tasks must be a non-null object';
env = { ...DEFAULT_ENV, ...env };
const types = { const types = {
js: new apJs(env), js: new apJs(env),
css: new apCss(env), css: new apCss(env),