Closed anran758 closed 8 months ago
I understood why the CommonJS example in import-esm-in-typescript-examples works correctly, as the tsconfig.json is set to transform CommonJS syntax into ESModule syntax.
While attempting to address the import issue, I also came across other developers facing similar challenges in the issues section of inquirer.js. Is there a suitable solution available?
I got it. The issue was due to my use of nodeExternals, which by default marks inquirer-autocomplete-standalone as external, leading to the compiled code being converted to require when executed by node.
nodeExternals({ allowlist: ['inquirer-autocomplete-standalone'] }),
However, when I excluded inquirer-autocomplete-standalone from nodeExternals, it started working properly. The downside is that the size of the dist increases (since it bundles the third-party library together), and I'm not sure if this is the expected behavior for packaging a CLI.
now Inquirer#1267 support it.
Hi, I've encountered some issues while using inquirer-autocomplete-standalone.
My Node.js project is built with Webpack and TypeScript. When using Webpack, setting the target to 'node' automatically converts import syntax to require syntax. I've also looked at the examples provided, but due to Webpack, dynamic imports don't seem to work either.
Currently, my project already depends on @inquirer/prompts, and it would be redundant to downgrade and install inquirer and inquirer-autocomplete-prompt again. How can I use inquirer-autocomplete-standalone with Webpack packaging?
webpack.config.js
tsconfig.json
package.json