{"id":13412,"library":"just-task","title":"just-task Build Task Definition Library","description":"just-task is a robust, lightweight library for defining and orchestrating build tasks in JavaScript and TypeScript projects. It functions as the foundational task definition layer within the broader `Just` ecosystem developed by Microsoft, which also includes `just-scripts` for higher-level, opinionated build presets. Currently at version 1.13.0, just-task provides core primitives such as `task`, `series`, and `parallel` for structuring complex build flows. Its release cadence is generally stable, with updates focusing on refinements and bug fixes rather than frequent breaking changes within the 1.x major version. A key differentiator is its unopinionated nature regarding specific tools (e.g., Webpack, Jest, TypeScript compiler), allowing developers to integrate their preferred tools seamlessly. It targets Node.js environments version 14 and above, offering both CommonJS and ES Module compatibility for task definitions. This library emphasizes clear, programmatic task definition, providing a flexible alternative to more configuration-heavy or tightly coupled build systems.","status":"active","version":"1.13.0","language":"javascript","source_language":"en","source_url":"https://github.com/microsoft/just","tags":["javascript"],"install":[{"cmd":"npm install just-task","lang":"bash","label":"npm"},{"cmd":"yarn add just-task","lang":"bash","label":"yarn"},{"cmd":"pnpm add just-task","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"ESM imports are preferred for modern Node.js environments (v14+). CommonJS `require` is also supported, typically in `just.config.js`.","wrong":"const { task, series, parallel } = require('just-task');","symbol":"task, series, parallel","correct":"import { task, series, parallel } from 'just-task';"},{"note":"Import `TaskFunction` as a type only for type annotations in TypeScript projects to avoid runtime issues.","wrong":"import { TaskFunction } from 'just-task';","symbol":"TaskFunction","correct":"import type { TaskFunction } from 'just-task';"},{"note":"For programmatic invocation of the `just` CLI functionality (e.g., from a custom script), the entry point is under `lib/cli`. Most users interact with the `just` CLI package directly.","wrong":"import { cli } from 'just-task';","symbol":"cli","correct":"import { cli } from 'just-task/lib/cli';"}],"quickstart":{"code":"// just.config.ts (or just.config.js)\nimport { task, series, parallel } from 'just-task';\n\ntask('clean', () => {\n  console.log('Cleaning build artifacts...');\n  // Simulate an async operation\n  return new Promise(resolve => setTimeout(resolve, 200));\n});\n\ntask('lint', () => {\n  console.log('Linting source files...');\n  return new Promise(resolve => setTimeout(resolve, 300));\n});\n\ntask('build', () => {\n  console.log('Compiling code...');\n  return new Promise(resolve => setTimeout(resolve, 500));\n});\n\ntask('test', () => {\n  console.log('Running unit tests...');\n  return new Promise(resolve => setTimeout(resolve, 400));\n});\n\n// Define a default task for running from CLI without arguments\ntask('default', series('clean', 'lint', 'build', 'test'));\n\n// Define a complex task orchestrating others\ntask('ci', series('clean', parallel('lint', 'build'), 'test'));\n\n// To run these tasks, install the `just` CLI globally (`npm install -g just`)\n// or locally (`npm install just` and then use `npx just <task_name>`).\n// Example: `npx just default` or `npx just ci`","lang":"typescript","description":"Demonstrates how to define a series of asynchronous tasks and combine them into complex build flows using `just-task`."},"warnings":[{"fix":"Modify your task function to return a Promise (e.g., `return new Promise(...)`) or declare it as `async function() { /* await ... */ }`.","message":"When defining asynchronous tasks, always ensure the task function explicitly returns a Promise or is an `async` function. If a Promise is not returned, `just-task` will treat the task as synchronous and may proceed before async operations genuinely complete.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Evaluate if `just-scripts` better suits your project's needs for standard build configurations, or continue with `just-task` for full customization.","message":"`just-task` provides low-level task definition APIs. For common build scenarios involving tools like TypeScript, Webpack, or Jest, consider using `just-scripts`, which offers pre-configured and opinionated build flows built on top of `just-task`.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Review the `just-task` release notes on GitHub or the official documentation (microsoft.github.io/just/) before upgrading, particularly for any non-trivial version changes.","message":"While the 1.x major version aims for stability, minor API adjustments or behavioral changes can occur in patch or minor releases. Always consult the official documentation or release notes when upgrading to prevent unexpected behavior.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Ensure your configuration file is named `just.config.ts` or `just.config.js` and is located in the root directory of your project, or explicitly specify its path using the `--config` flag with the `just` CLI.","message":"The `just` CLI expects your task definitions in `just.config.ts` (or `.js`) in the project root. Incorrect file naming or placement is a common cause for tasks not being discovered.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Double-check the task name for typos. Verify that your `just.config.ts` (or `.js`) file is correctly named and located in the project root, or specify its path with `npx just --config ./path/to/my.config.ts myTask`.","cause":"The task name specified in the CLI command does not match any defined task in `just.config.ts/js`, or the configuration file was not loaded by the `just` CLI.","error":"Task 'myTask' not found"},{"fix":"Ensure your asynchronous task function explicitly returns a Promise (e.g., `return new Promise(resolve => { /* ... */ resolve(); });`) or use the `async` keyword: `task('myAsync', async () => { await someAsyncOperation(); });`","cause":"An asynchronous task function was defined without returning a Promise, or it was not declared as an `async` function, leading `just-task` to misinterpret its completion.","error":"Error: A task must return a Promise or be synchronous"},{"fix":"Verify that you are using the correct import syntax for your file's module type (ESM `import { task } from 'just-task';` or CommonJS `const { task } = require('just-task');`) and that the exports are correctly destructured.","cause":"This usually indicates an incorrect import statement, such as attempting to use CommonJS `require` syntax in an ES Module context, or incorrect destructuring of named exports.","error":"TypeError: Cannot read properties of undefined (reading 'task')"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"just","cli_version":null}