@storm-software/workspace-tools
Version:
Tools for managing a Storm workspace, including various Nx generators and executors for common development tasks.
106 lines (95 loc) • 4.18 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 _chunkWCTC7R27js = require('./chunk-WCTC7R27.js');
var _chunkIHMF6RANjs = require('./chunk-IHMF6RAN.js');
var _chunkCQDBLKPFjs = require('./chunk-CQDBLKPF.js');
// src/executors/unbuild/executor.ts
var _defu = require('defu');
var _jiti = require('jiti');
async function unbuildExecutorFn(options, context, config) {
_chunkIHMF6RANjs.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 : _chunkCQDBLKPFjs.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 : _chunkCQDBLKPFjs.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
};
}
var executor_default = _chunkWCTC7R27js.withRunExecutor.call(void 0,
"TypeScript Unbuild build",
unbuildExecutorFn,
{
skipReadingConfig: false,
hooks: {
applyDefaultOptions: async (options, config) => {
options.debug ??= false;
options.treeShaking ??= true;
options.buildOnly ??= false;
options.platform ??= "neutral";
options.entry ??= ["{sourceRoot}"];
options.tsconfig ??= "{projectRoot}/tsconfig.json";
return options;
}
}
}
);
exports.unbuildExecutorFn = unbuildExecutorFn; exports.executor_default = executor_default;