Fix sourcemap support once and for all
See original GitHub issueProblem:
ganache-core
requiressource-map-support/register
at top module scope.- Loading
source-map-support
multiple times in different versions leads to broken source map support: https://github.com/evanw/node-source-map-support/issues/200 - This caused a lot of different issues in the Ethereum ecosystem:
- Hardhat- https://github.com/EthWorks/Waffle/issues/281
- Optimism - https://github.com/ethereum-optimism/plugins/issues/29
- Jest integrations
- probably more to come
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:
-
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 likeganache-cli
-
Import it only when not in tests as celo did in their fork: https://github.com/celo-org/ganache-core/commit/3dbc32b214b3bb8f0dda2bfd909850a752a73a55 - I am not sure about this solution.
-
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: https://github.com/trufflesuite/truffle/issues/3432
Let me know how can I help to get this fixed.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5 (3 by maintainers)
Top GitHub Comments
That’s perfect @davidmurdoch. Should I close this now or when it gets merged?
The next version of ganache core will handle source-map-support properly (via # 1), and truffle will soon as well: https://github.com/trufflesuite/truffle/pull/3929
p.s.,
resolutions
is a yarn-only feature.