jsverse / transloco

🚀 😍 The internationalization (i18n) library for Angular

Home Page:https://jsverse.github.io/transloco/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

remove unused dependencies from @ngneat/transloco package

FabienDehopre opened this issue · comments

The @ngneat/transloco package have several unused dependencies that may cause conflicts with the same dependencies in different version:

  • fs-extra
  • glob
  • replace-in-file
  • ora
  • lodash.kebabcase
  • @ngneat/transloco-utils

I propose to remove them to reduce the package install size and any conflicts they may cause when install @ngneat/transloco package in project/workspace with complex dependencies installed.

I will provide a PR to remove the unused dependencies from the package.json (an ng-packagr.json).

@FabienDehopre These dependecies are used by the schematics, they need to be there

@shaharkazaz ok... but then, why does the schematics live in a separated project (transloco-schematics)? Can't they be deployed/released in separated package (as @ngneat/transloco-schematics)?

I created this issue and the related PR because the version 5.x of transloco completely breaks my workspace because of the glob dependency which, in transloco, is >= 10.0.0. In my work space, I had to pin it to 9.3.5 because version 10 broke the compatibility with nx (at least on my workspace) for some unknown reason.

@shaharkazaz another possibility would be to move those dependencies to peerDependencies and mark them as optional. So, those who need to use the schematics should also install those optional peer dependencies.

They are in a different lib for development convenience.
I need to check if releasing them in a different package is doable.

Adding them as optional peers is not an option from my end as this will result in a bad DX IMO, this should be seamless to anyone using Transloco.

Figuring out why glob isn't working as expected on your end is also a solution 🙂 I've worked with several NX workspaces but didn't encounter any issue related to glob.

I think you can close the PR as removing these dependencies won't be the solution, I need to think about how I want to handle this.

@shaharkazaz Ok... I closed the PR and will also close this issue.
FYI, here is the error I get once I install the @ngneat/transloco library:

C:\Projects\my-nx-workspace\node_modules\yargs\node_modules\cliui\build\index.cjs:293
const wrap = require('wrap-ansi');
             ^

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\Projects\my-nx-workspace\node_modules\wrap-ansi\index.js from C:\Projects\my-nx-workspace\node_modules\yargs\node_modules\cliui\build\index.cjs not supported.
Instead change the require of index.js in C:\Projects\my-nx-workspace\node_modules\yargs\node_modules\cliui\build\index.cjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\yargs\node_modules\cliui\build\index.cjs:293:14)
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\yargs\build\index.cjs:1:60678)
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\yargs\index.cjs:5:30)
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\nx\src\command-line\nx-commands.js:5:15)
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\nx\bin\init-local.js:7:23)
    at Object.<anonymous> (C:\Projects\my-nx-workspace\node_modules\nx\bin\nx.js:7:22) {
  code: 'ERR_REQUIRE_ESM'
}

Maybe you already saw this issue before and/or have an idea what may cause it.

PS: I replaced the name of the project with "my-nx-workspace" because of NDA at my work place.

@FabienDehopre You need to understand where this dependency is coming from and maybe upgrade whatever is using it as well.
I don't have any solution at the top of my head.

@shaharkazaz I finally succeeded to solve my issue by adding a resolution for the warp-ansi package.

Glad to hear!

Thanks a lot.... This helped:

{
  "resolutions": {
    "wrap-ansi": "^7.0.0"
  }
}

This is just sad that we now need to add a resolution for the wrap-ansi package in all projects using transloco v5 :'(

@FabienDehopre can you provide information on why you need to add it?
Which library is using the outdated version?
I think that generally I can set the dependency to a lower version, but let's understand the root cause and not just be sad about it :)

Indeed, it's cliui which still depends on version ^7.0.0 of wrap-ansi which is not ESM compatible.
If I'm not mistaken, there is a fork of cliui called @isaacs/cliui which depends on wrap-ansi version ^8.0.0 which is ESM compatible.
https://github.com/isaacs/cliui/blob/aa397fedbd0550c9925af6b62f970de663285641/package.json#L56