simplyhexagonal / short-unique-id

Short Unique ID (UUID) generation library. Available in NPM.

Home Page:https://www.npmjs.com/package/short-unique-id

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Webpack is issuing is critical warning against this

sambhav-gore opened this issue ยท comments

I am using this in a NextJS app and I see the following warning in the console:

warn  - ./node_modules/short-unique-id/lib/short-unique-id.js
Critical dependency: the request of a dependency is an expression

I believe it is because of a dynamic import / require used in the file, but not sure about it.
should I be concerned with this warning ?

Hi @sambhav-gore , thanks for the report ๐Ÿ™‚

Short Unique ID has no external dependencies, so I think it has to do with the fact that it depends on a version.js file (which is only there to provide the current packaged version) but when the source gets transpiled from TypeScript it requires the version file dynamically due to commonjs compatibility polyfills.

You can dismiss the warning ๐Ÿ‘

Is there any way to fix this? I feel like suppressing warnings might not be a sustainable solution.

@jeanlescure I use short-unique-id in another npm package and now the consumer of my library will see the warning. I don't think ignoring warnings is a good idea, so I strongly believe that this should be fixed.

Maybe remove the version.js, its maybe not that valueble

Hi @macrozone, we're already in talks of version 4, and one of the points was to simplify packaging including the way we consume the version.

Now, since you do have an immediate need for this, rather than wait for v4 (which is still at least couple of months away), I will look into issuing a patch with this specific change ASAP.

Thanks for the feedback ๐Ÿ‘

@jeanlescure could you already look into the issue?

happy new year!

Hi @macrozone , happy new year as well!

I've indeed looked into the issue. Unfortunately, because of the way we implemented this lib to be "Deno first" and then transpiled as needed, performing the change is non-trivial.

The good news is that this issue has sped up our work on v4, soon we will have an RC ready and will deprecate previous short-unique-id versions.

I'll keep this issue updated as progress is made.

Cheers

@jeanlescure hi, wanted to ask if you have any update to share. Maybe having a big v4 is too much for now, can't we just remove the version string that causes this issue? I don't think that this is that important to have

It's great that you are working on a v4, but issues like this seems crucial to fix before reworking a whole package?

I'm going to try out nanoid in the meantime.

@sambhav-gore @tskarhed @macrozone @PaulPCIO

We have published v4 (the Rust rework has been pushed to 2022 as v5).

Short Unique ID is now a more traditional Typescript/JS package which I would hope plays better with Webpack and the likes.

I'll keep this issue open for a bit hoping to get your feedback as to whether the critical warning has gone away or not.

Cheers ๐Ÿฅ‚

Closing this issue due to lack of activity.