Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Fix sourcemap support once and for all #879

Closed
krzkaczor opened this issue Mar 21, 2021 · 5 comments
Closed

Fix sourcemap support once and for all #879

krzkaczor opened this issue Mar 21, 2021 · 5 comments
Assignees
Milestone

Comments

@krzkaczor
Copy link

Problem:

  1. ganache-core requires source-map-support/register at top module scope.
  2. Loading source-map-support multiple times in different versions leads to broken source map support: Activating source-map-support several times leads to issues evanw/node-source-map-support#200
  3. This caused a lot of different issues in the Ethereum ecosystem:

Quick workaround:

source-map-support is able to ąvoid re-registering if one particular version is registered multiple times so a reasonable workaround is to force install only one particular version. To do this add in package.json:

"resolutions": {
    "source-map-support": "0.5.19"
  }

Real solution:

I see few solutions to this problem:

  1. Not to import source-map-support in this library at all. source-map-support was designed not to be included in other libraries. I believe that it should be importing in some kind of executors like ganache-cli

  2. Import it only when not in tests as celo did in their fork: celo-org/ganache-core@3dbc32b - I am not sure about this solution.

  3. Try to push a fix to source-map-support to detect multiple registers across different versions. Fix seems to be easy to create but the library doesn't seem to be maintained anymore.

@gnidan I am linking past discussion with @sz-piotr: trufflesuite/truffle#3432

Let me know how can I help to get this fixed.

@davidmurdoch
Copy link
Member

davidmurdoch commented Mar 21, 2021

The next version of ganache core will handle source-map-support properly (via # 1), and truffle will soon as well: trufflesuite/truffle#3929

p.s., resolutions is a yarn-only feature.

@krzkaczor
Copy link
Author

That's perfect @davidmurdoch. Should I close this now or when it gets merged?

@alcuadrado
Copy link
Contributor

alcuadrado commented Mar 21, 2021

The next version of ganache core will handle source-map-support properly (via # 1)

This is awesome news! Thanks @davidmurdoch!

@davidmurdoch davidmurdoch changed the title Fix surcemap support once and for all Fix sourcemap support once and for all Mar 23, 2021
@davidmurdoch
Copy link
Member

@krzkaczor no need to close it. We'll handle it once 7.0 goes out.

@hayesgm
Copy link

hayesgm commented Apr 8, 2021

For anyone looking for a really quick fix (read: hack), this worked for me in the meanwhile:

package.json

"scripts": {
    "postinstall": "cat /dev/null > node_modules/source-map-support/register.js",
}

Resolutions, themselves, did not fix the issue for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants