radashi-helper
Version:
Help with managing your own Radashi
35 lines (27 loc) • 1.73 kB
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
var _chunk3KDGKCY3cjs = require('./chunk-3KDGKCY3.cjs');
var _chunkZP624W2Acjs = require('./chunk-ZP624W2A.cjs');
// src/esbuild/plugin.ts
var _promises = require('fs/promises');
function esbuildRadashi(options) {
const env = _nullishCoalesce(_optionalChain([options, 'optionalAccess', _ => _.env]), () => ( _chunkZP624W2Acjs.getEnv.call(void 0, _optionalChain([options, 'optionalAccess', _2 => _2.root]))));
return {
name: "esbuild-radashi",
setup(build) {
build.onLoad({ filter: /\/mod\.ts$/, namespace: "file" }, async (args) => {
if (args.path === env.modPath) {
const code = await _chunk3KDGKCY3cjs.generateUmbrella.call(void 0, env);
await _promises.writeFile.call(void 0,
args.path,
"// BEWARE: This file is *generated* by the esbuild-radashi plugin. Do not edit directly!\n\n" + code
);
return {
loader: "ts",
contents: code
};
}
});
}
};
}
exports.esbuildRadashi = esbuildRadashi;