codesandbox / codesandbox-client

An online IDE for rapid web development
https://codesandbox.io
Other
13.03k stars 2.27k forks source link

Excess package duplication #1257

Closed justinfagnani closed 5 years ago

justinfagnani commented 5 years ago

🐛 bug report

Description of the problem

When depending on a package, and one of its transitive dependencies directly, I'm getting package duplication that causes errors in my program.

  "dependencies": {
    "@polymer/lit-element": "^0.6.2",
    "lit-html": "^0.12.0"
  },

How has this issue affected you? What are you trying to accomplish?

instanceof and other branding checks (module-scoped WeakMaps) are failing because of two versions of the same package. This breaks rendering.

Link to sandbox: [https://codesandbox.io/s/oqoowy8q89]()

justinfagnani commented 5 years ago

One problem here is that I can't inspect the node_modules folder to directly see any duplication, nor can I use paths into node_modules for imports to try to work around the problem. Imports like ../node_modules/@polymer/lit-element/node_modules/lit-html/lit-html.js seem like they are being re-written to strip the leading ../node_modules/.

CompuIves commented 5 years ago

Hmmm that's interesting, when looking at the sandbox there doesn't seem to be duplication. A trick to see all files in the sandbox is opening your devtools, pointing to the frame and use the fs API:

BrowserFS.BFSRequire('fs').readdirSync('/node_modules')

You can also inspect the files by doing the same but checking the manager, which is global:

manager.transpiledModules

or

manager.manifest

Do you have a reproducible error I can look into?

justinfagnani commented 5 years ago

Oops, I was using a not-yet-released API, and the result happened to look like what also happens when we get package duplication. Sorry!

Thanks for the BrowserFS tip though!