microsoft / microsoft/just

just-task config.ts should support ESM configs

Open
#572 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

  • #821 by @copilot-swe-agent — closed without merging
Dominant language
TypeScript
Stars
2k
Forks
97
PR merge metrics
No merged PRs in 30d

Description

Right now, just-scripts only works with commonjs configs. Given how the ecosystem is moving to esm, this will become a point of frustration.

If you have a package with type: "module" set right now, you'd expect just.config.js to be an ESM.

just-task will throw:

yarn run v1.22.17
warning package.json: No license field
$ just-scripts build
[5:06:17 PM] x Invalid configuration file: D:\git\cloudpack2\packages\path-utilities\just.config.js
[5:06:17 PM] x Error: Error [ERR_REQUIRE_ESM]: require() of ES Module D:\git\cloudpack2\packages\path-utilities\just.config.js from D:\git\cloudpack2\node_modules\just-task\lib\config.js not supported.
Instead change the require of just.config.js in D:\git\cloudpack2\node_modules\just-task\lib\config.js to a dynamic import() which is available in all CommonJS modules.
    at Object.readConfig (D:\git\cloudpack2\node_modules\just-task\lib\config.js:30:34)
    at Object.<anonymous> (D:\git\cloudpack2\node_modules\just-task\lib\cli.js:37:31)
    at Object.<anonymous> (D:\git\cloudpack2\node_modules\just-scripts\lib\cli.js:3:1)
    at Object.<anonymous> (D:\git\cloudpack2\node_modules\just-scripts\bin\just-scripts.js:2:1)

I think the require statement can change to an async import, but that will also require some shuffling in the CLI to await on results (or Promise chain.) Plus I'm not sure how this will affect importing commonjs results - that will still need testing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with just-task/lib/config.js and its readConfig function, then trace how results flow through just-task/lib/cli.js and just-scripts/lib/cli.js. Verify the CLI can await configuration loading, preserve CommonJS support, and load an ESM just.config.js for packages using type: "module".

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.