Skip to content
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

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

Open
dzearing opened this issue Feb 1, 2022 · 4 comments
Open

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

dzearing opened this issue Feb 1, 2022 · 4 comments

Comments

@dzearing
Copy link
Member

dzearing commented Feb 1, 2022

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.

@dzearing dzearing changed the title just-task config.ts should use a dynamic import() to load the config just-task config.ts should support ESM configs Feb 1, 2022
@dzearing
Copy link
Member Author

dzearing commented Feb 1, 2022

This is not an issue if you use TS with a commonjs module output, but I've been trying to remove cjs output in new code.

@kaiyoma
Copy link

kaiyoma commented Mar 29, 2023

Any word here? I'm also running into this, and would like to use Just with ESM pretty soon. We have a big monorepo that uses Just everywhere, and we'll eventually need to convert to ESM.

@Hotell
Copy link

Hotell commented Feb 22, 2024

we are also running into this ATM

I managed to make it work with these simple tweaks, it might be more complicated than that ... would be great to ship this.

image

https://github.com/microsoft/fluentui/pull/30582/files#r1499133479

@spookyuser
Copy link

we are also running into this ATM

I managed to make it work with these simple tweaks, it might be more complicated than that ... would be great to ship this.

image [microsoft/fluentui#30582 (files)](https://github.com/microsoft/fluentui/pull/30582/files#r1499133479)

Thank you so much that worked, here is a pnpm patch file if anyone wants to add this to their repo fast https://gist.github.com/spookyuser/c295d14654004d2ca7b735dce4e012e9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants