Compare commits

...

3 commits

Author SHA1 Message Date
b07c088ab7 Vars target from #vars decl. 2024-06-10 03:28:38 +00:00
47bd2fab87 0.12.0 2024-06-10 03:25:23 +00:00
99b8f4919b Altered vars handling. 2024-06-10 03:25:20 +00:00
5 changed files with 8 additions and 11 deletions

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "@flashwave/assproc",
"version": "0.11.0",
"version": "0.12.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "@flashwave/assproc",
"version": "0.11.0",
"version": "0.12.0",
"license": "BSD-3-Clause",
"dependencies": {
"@swc/core": "^1.5.25",

View file

@ -1,6 +1,6 @@
{
"name": "@flashwave/assproc",
"version": "0.11.0",
"version": "0.12.0",
"description": "Personal frontend asset processing tool",
"main": "./src/index.js",
"scripts": {

View file

@ -57,6 +57,7 @@ module.exports.folder = async (root, options) => {
if(typeof options.vars !== 'object' || options.vars === null)
break;
const bvTarget = args.shift();
const bvSourceName = trimEnd(args.join(' '), ';');
const bvSource = options.vars[bvSourceName];
if(typeof bvSource !== 'objects' || bvSource === null)
@ -67,7 +68,7 @@ module.exports.folder = async (root, options) => {
bvProps.push(`${bvName}: { value: ${JSON.stringify(bvSource[bvName])} }`);
if(Object.keys(bvProps).length > 0)
output += `Object.defineProperties(${options.varsTarget}, { ${bvProps.join(', ')} });\n`;
output += `Object.defineProperties(${bvTarget}, { ${bvProps.join(', ')} });\n`;
break;
default:

View file

@ -7,7 +7,6 @@ const { strtr, shortHash, writeFile } = require('../utils.js');
module.exports = function(env) {
const PREFIX = '#';
const DEFAULT_ENTRY = 'main.js';
const DEFAULT_VARS_TARGET = 'window';
const createJscOpts = () => {
return {
@ -50,7 +49,6 @@ module.exports = function(env) {
prefix: PREFIX,
entry: task.entry ?? DEFAULT_ENTRY,
vars: vars,
varsTarget: task.varsTarget ?? DEFAULT_VARS_TARGET,
}), {
filename: task.source,
sourceMaps: false,

View file

@ -33,9 +33,6 @@ module.exports.process = async (env, tasks) => {
const files = {};
for(const type of order) {
if(!types.hasOwnProperty(type))
continue;
if(!(type in types))
throw `${type} is not a supported build task type`;
@ -54,8 +51,9 @@ module.exports.process = async (env, tasks) => {
console.info(` => ${task.source}...`);
const path = await handler.process(task, vars);
if(typeof task.varsName === 'string')
vars[task.varsGroup ?? ''][task.varsName] = path;
if(typeof task.vars === 'object' && task.vars !== null)
for(const varsGroup in task.vars)
vars[varsGroup][task.vars[varsGroup] === ':source' ? task.source : task.vars[varsGroup]] = path;
files[task.source] = path;
}