Inquirer.js
Inquirer.js copied to clipboard
Move to ESM
some reading on this: https://blog.sindresorhus.com/get-ready-for-esm-aa53530b3f77
Hi @mesqueeb! Thank you for notifying us!
Here are my concerns about pure ES Module packages:
- We must use
importto load ES Module, which means the user's package must be ES Module too. - In ESM, we cannot use
__dirnamerelated things anymore, which means some users have to refactor their code for applying our new version.
At last, I agree with pushing our ecosystem forward. We could keep this issue open for a while and let other developers know we plan to do this.
Cheers to ESM!
I don't like the idea of packages forcing it's users to use a specific module system. The community should rather strive to make both systems fully interoperable.
@axelrindle NodeJS already works with import natively. If you want to use legacy NodeJS versions you can simply use an older version of the package you wanna use.
I agree that we should strive towards esm also
ppl stuck with cjs can still import esm only packages using dynamic import('x') the only nit pick is that it needs to be async, everyone don't have to move to esm just b/c we decide to do so
You depend on quite some few packages from @sindresorhus that all been switched to esm-only. so to get new updates it would be great to also switch to esm
PR welcomed to implement ESM modules. It's been out a while, I think it's time to rip the bandaid.
Hi @SBoudrias , I made a Pull Request for this feature. Please check it out when you have time :)
Pinging for ts users. Came here with below error.
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module
.../node_modules/inquirer/lib/inquirer.js
require() of ES modules is not supported.
Seems no other way than givving up using ts-node. switching back to classic enquirer
I answered this over this other thread - please refrain from sharing misinformation out of frustration... This isn't helpful for anyone.
If you want to use ts-node with esm, you need to add this configuration to your ts-config.json https://github.com/SBoudrias/Inquirer.js/blob/master/tsconfig.json#L4-L6 - I've been developing inquirer using ts-node.
I have this line added to my ts-config but i continue to get the same Error [ERR_REQUIRE_ESM]: require() of ES Module error
i fixed it by downgrading to version 8.0.1
I don't understand what's going on here but downgrading to 8.0.1 helped me too.
I'm trying to use ESM modules with TypeScript and Jest. Version 9.1.0 of Inquirer causes Jest to throw:
ReferenceError: You are trying to `import` a file after the Jest environment has been torn down. From src/fileSystem.test.ts.
at async Promise.all (index 1)
Commenting out any code which uses Inquirer and running the test works.
Since the ESM migration was done, I'll close this ticket.
But I've opened this one here https://github.com/SBoudrias/Inquirer.js/issues/1159 to offer a common.js build output too. Help welcome on this task.
i fixed it by downgrading to version 8.0.1
This worked as well thanks!!
i fixed it by downgrading to version 8.0.1
This works, thanks a lot !!
i fixed it by downgrading to version 8.0.1
I mean, could this make us sacrifice in security or features? Can you guys add an option to use BOTH module systems??
Can you guys add an option to use BOTH module systems?
Like I posted, this is tracked in #1159. I'd be happy to review a PR and facilitate a release about this if you're ready to help.
Ok thanks
libraries should be able to support both without needing downgrade versions - if it can't then that's node.js is fault