@storm-software/workspace-tools
Version:
Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.
86 lines (73 loc) • 4.08 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 _chunkP6PFHXHQjs = require('./chunk-P6PFHXHQ.js');
var _chunkSKMT7WD5js = require('./chunk-SKMT7WD5.js');
var _chunkJTAXCQX6js = require('./chunk-JTAXCQX6.js');
var _chunk3GQAWCBQjs = require('./chunk-3GQAWCBQ.js');
// src/executors/unbuild/executor.ts
var _defu = require('defu');
var _jiti = require('jiti');
async function unbuildExecutorFn(options, context, config) {
_chunkSKMT7WD5js.writeInfo.call(void 0, "\u{1F4E6} Running Storm Unbuild executor on the workspace", config);
if (!_optionalChain([context, 'access', _ => _.projectsConfigurations, 'optionalAccess', _2 => _2.projects]) || !context.projectName || !context.projectsConfigurations.projects[context.projectName]) {
throw new Error("The Build process failed because the context is not valid. Please run this command from a workspace root directory.");
}
if (!context.projectsConfigurations.projects[context.projectName].root) {
throw new Error("The Build process failed because the project root is not valid. Please run this command from a workspace root directory.");
}
if (!context.projectsConfigurations.projects[context.projectName].sourceRoot) {
throw new Error("The Build process failed because the project's source root is not valid. Please run this command from a workspace root directory.");
}
const jiti = _jiti.createJiti.call(void 0, config.workspaceRoot, {
fsCache: config.skipCache ? false : _chunkJTAXCQX6js.joinPaths.call(void 0, config.workspaceRoot, config.directories.cache || "node_modules/.cache/storm", "jiti"),
interopDefault: true
});
const stormUnbuild = await jiti.import(jiti.esmResolve("@storm-software/unbuild/build"));
await stormUnbuild.build(_defu.defu.call(void 0, {
...options,
projectRoot: context.projectsConfigurations.projects[context.projectName].root,
projectName: context.projectName,
sourceRoot: context.projectsConfigurations.projects[context.projectName].sourceRoot,
platform: options.platform
}, {
stubOptions: {
jiti: {
fsCache: config.skipCache ? false : _chunkJTAXCQX6js.joinPaths.call(void 0, config.workspaceRoot, config.directories.cache || "node_modules/.cache/storm", "jiti")
}
},
rollup: {
emitCJS: true,
watch: false,
dts: {
respectExternal: true
},
esbuild: {
target: options.target,
format: "esm",
platform: options.platform,
minify: _nullishCoalesce(options.minify, () => ( !options.debug)),
sourcemap: _nullishCoalesce(options.sourcemap, () => ( options.debug)),
treeShaking: options.treeShaking
}
}
}));
return {
success: true
};
}
_chunk3GQAWCBQjs.__name.call(void 0, unbuildExecutorFn, "unbuildExecutorFn");
var executor_default = _chunkP6PFHXHQjs.withRunExecutor.call(void 0, "TypeScript Unbuild build", unbuildExecutorFn, {
skipReadingConfig: false,
hooks: {
applyDefaultOptions: /* @__PURE__ */ _chunk3GQAWCBQjs.__name.call(void 0, async (options, config) => {
options.debug ??= false;
options.treeShaking ??= true;
options.platform ??= "neutral";
options.entry ??= [
"{sourceRoot}"
];
options.tsconfig ??= "{projectRoot}/tsconfig.json";
return options;
}, "applyDefaultOptions")
}
});
exports.unbuildExecutorFn = unbuildExecutorFn; exports.executor_default = executor_default;