Skip to content

compileProject in index.js now accepts the optimize flag, as well as multiple entry points. #331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,28 @@ async function installDependencies(path, options) {
* If you're compiling an application, pass the relative path of the entrypoint as the `target` in the options object.
*
* `path` should be set to the project directory where you wish to execute this command.
* `options` allow you to set environment variables and a timeout. See `execute` for more information.
* `options` allow you to set environment variables and a timeout. `options` can contain all fields taken by `execute`, as well as:
*
* If `options` contains a sourcemaps property that is true, sourcemaps will be generated and inlined into the output.
* * `target`: the module name (or names, if given an array) to compile
* * `sourcemaps`: if sourcemaps should be included in the generated code
* * `optimize`: if code should be generated in optimized mode
*/
async function compileProject(path, options) {
let args = ["make", "--output=/dev/stdout", "--report=json"];
let args = ["make"];
if (Array.isArray(options.target)) {
args = args.concat(options.target);
} else {
args.push(options.target);
}

args.push("--output=/dev/stdout", "--report=json");

if (options.sourcemaps) {
args.push("--sourcemaps");
}

if (options.target) {
args.push(options.target);
if (options.optimize) {
args.push("--optimize");
}

return handleFailableExecution(path, args, options);
Expand Down