imsnif / synp

Convert yarn.lock to package-lock.json and vice versa
MIT License
745 stars 41 forks source link

Workspace mode - yarn.lock conversion fails with invalid package.json in tests #101

Open rafsawicki opened 10 months ago

rafsawicki commented 10 months ago

Issue description:

In workspace mode, it seems like synp tries to read all package.json files in the node_modules, even if they are not the main package.json file for the package. We're trying to convert yarn.lock to package-lock.json and one of our sub-dependencies is resolve package, which includes a bunch of invalid package.json files in their test suite. This causes the conversion to fail with Unexpected end of JSON input error.

Are you reporting a conversion error? Please include a link to yarn.lock / package-lock.json:

Cannot link to the whole yarn.lock, but the relevant parts are

ts-node-dev@^1.1.8:
  version "1.1.8"
  resolved "https://registry.yarnpkg.com/ts-node-dev/-/ts-node-dev-1.1.8.tgz#95520d8ab9d45fffa854d6668e2f8f9286241066"
  integrity sha512-Q/m3vEwzYwLZKmV6/0VlFxcZzVV/xcgOt+Tx/VjaaRHyiBcFlV0541yrT09QjzzCxlDZ34OzKjrFAynlmtflEg==
  dependencies:
    chokidar "^3.5.1"
    dynamic-dedupe "^0.3.0"
    minimist "^1.2.5"
    mkdirp "^1.0.4"
    resolve "^1.0.0"
    rimraf "^2.6.1"
    source-map-support "^0.5.12"
    tree-kill "^1.2.2"
    ts-node "^9.0.0"
    tsconfig "^7.0.0"

resolve@^1.0.0, resolve@^1.1.6, resolve@^1.1.7, resolve@^1.10.0, resolve@^1.11.1, resolve@^1.12.0, resolve@^1.14.2, resolve@^1.15.1, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.3.2, resolve@^1.8.1:
  version "1.22.1"
  resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
  integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
  dependencies:
    is-core-module "^2.9.0"
    path-parse "^1.0.7"
    supports-preserve-symlinks-flag "^1.0.0"

Are you reporting a conversion error? Please also include a link to your package.json:

antongolub commented 10 months ago

@rafsawicki

I'm afraid this a side effect of how nmtree works. But we are experimenting on trees generation (depgraph, deptree, nmtree) without fs projections. The PoC is in early stages, but looks promising.