Parcel: Fails to reexport property at build time

Created on 22 Mar 2020  ยท  5Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

Using @sentry/browser fails at build time with Error: node_modules/@sentry/utils/esm/index.js does not export 'timestampWithMs'.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

See https://github.com/garthenweb/parcel-bug-report-examples/tree/bug/sentry-does-not-export-timestampWithMs

๐Ÿค” Expected Behavior

Should create a proper build that is executable in the browser.

๐Ÿ˜ฏ Current Behavior

Fails with Error: node_modules/@sentry/utils/esm/index.js does not export 'timestampWithMs'. See https://github.com/garthenweb/parcel-bug-report-examples/tree/bug/sentry-does-not-export-timestampWithMs for more.

๐Ÿ’ Possible Solution

timestampWithMs is exported correctly in node_modules\@sentry\utils\esm\misc.js which is reexported in node_modules/@sentry/utils/esm/index.js.

timestampWithMs uses another export called crossPlatformPerformance, maybe this is the source of the issue?

Maybe related to https://github.com/parcel-bundler/parcel/issues/4216 but the error is different.

Works without scope hoisting.

๐Ÿ’ป Code Sample

See https://github.com/garthenweb/parcel-bug-report-examples/tree/bug/sentry-does-not-export-timestampWithMs

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-nightly.163
| Node | v12.8.1
| npm | v6.14.3
| Operating System | Windows (WSL v1/ Ubuntu Bash)

Bug Confirmed Bug โœจ Parcel 2 ๐ŸŒณ Tree Shaking

Most helpful comment

I've identified the problem, will be fixed after the refactoring in https://github.com/parcel-bundler/parcel/pull/4411 landed.

(Note to my future self: tests and an ugly fix can be found in https://github.com/parcel-bundler/parcel/tree/resolveSymbol-wrapped-reexport)

All 5 comments

I've identified the problem, will be fixed after the refactoring in https://github.com/parcel-bundler/parcel/pull/4411 landed.

(Note to my future self: tests and an ugly fix can be found in https://github.com/parcel-bundler/parcel/tree/resolveSymbol-wrapped-reexport)

@mischnic Are these fixes ever going to make it into 1.x? If not, could one avoid tree shaking this particular module only?

No, also because Parcel 2's scope hoisting implementation has diverged (improved) too much at this point.

If not, could one avoid tree shaking this particular module only?

That isn't possible.

@xtrinch fwiw (in the sort term) pinning@sentry/browser to version "5.9.1" resolved this issue for me in 1.x

Thanks @drewsynan, wish there was a better fix, but that works for me!

Was this page helpful?
0 / 5 - 0 ratings