SBoudrias / Inquirer.js

A collection of common interactive command line user interfaces.
MIT License
20.09k stars 1.3k forks source link

Version 9.3.2 released to npm does not work #1456

Closed Choppel closed 3 months ago

Choppel commented 3 months ago

As stated in the title, version 9.3.2 released to npm does not work properly. An import like import Separator from 'inquirer/lib/objects/separator.js'; which worked prior to 9.3.2 now throws ERR_MODULE_NOT_FOUND.

Weirdly enough, I couldn't find this version on the releases page of GitHub.

SBoudrias commented 3 months ago

Ohh, I didn't expect people to rely on the internal files structure to the package.

You should import { Separator } from 'inquirer' and rely on documented interface.

Choppel commented 3 months ago

Did you test this?

import { Separator } from 'inquirer' throws TS2614: Module 'inquirer' has no exported member Separator. Did you mean to use import Separator from "inquirer" instead? for me.

SBoudrias commented 3 months ago

We do have integration tests for some of the exports, though not the Separator. This is the legacy package I don't work with too often. I'll take a look, thanks for the report.

SBoudrias commented 3 months ago

Alright, so went to verify and the documented syntax is as follow:

import inquirer from 'inquirer';

new inquirer.Separator();

I double-checked the documentation and direct file access isn't documented. So while I agree it's 9.3.2 comes with an implicit breaking change, I don't think it's a reasonable expectation that the folder/file structure from a project to not change. Node project shouldn't import from undocumented direct file access to package internals.

I'm open to revisiting this issue if multiple users run into this issue somehow; so please post below if you've also encountered this issue. But in all cases, a future safe solution is to rely on inquirer.Separator.

Choppel commented 3 months ago

Hello @SBoudrias, this works now. Thanks.

I guess other users are also running into this issue. Because inquirer-autocomplete-prompt does not work anymore with inquirer@9.3.2 seemingly because of the changed project structure. See https://github.com/mokkabonna/inquirer-autocomplete-prompt/issues/159

But maybe it's the way of importing is also a misconception by the creator of the plugin. I am going to let them know.

SBoudrias commented 3 months ago

Ohhh, that's a bit more of an issue. There's so many plugins and they might access internals... Ugh, I'll work out a solution to maintain that (maybe defining an exports field in the package.json)

SBoudrias commented 3 months ago

inquirer@9.3.3 is out and should fix all this. Thanks for the report!

Choppel commented 3 months ago

Works. Thanks for the quick reply.

deot commented 3 months ago

This seems a bit bloated. Would it be better to notify other authors to modify it in the next major version?

SBoudrias commented 3 months ago

It would, but that's the unfortunate reality of old projects (>10 years old) with large adoption. Breaking change risk leaving large chunks of the ecosystem behind.

But anyhow, the true fix is for plugins to migrate to @inquirer/core. I'm just trying to smooth the migration away with inquirer.

Choppel commented 3 months ago

Oh. I didn't notice that you are rewriting inquirer. Maybe add a notice to the legacy inquirer project during install/update. I am going to rewrite my code based on the new @inquirer classes.