Skip to content

just-task config.ts should support ESM configs #572

@dzearing

Description

@dzearing

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions