bun
bun copied to clipboard
`Unexpected keyword "export"`, when importing Sentry
Version
v0.1.13 (canary e94e6d8d)
Platform
Linux spiffytop 5.19.8-1-default #1 SMP PREEMPT_DYNAMIC Thu Sep 8 10:26:47 UTC 2022 (0330383) x86_64 x86_64 x86_64 GNU/Linux
What steps will reproduce the bug?
sentry-test.js
import Sentry from '@sentry/node';
console.log(Sentry);
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
Successful import
What do you see instead?
$ bun run sentry-test.js
[0.05ms] ".env"
1 | export { _asyncNullishCoalesce } from './_asyncNullishCoalesce.js';
2 | export { _asyncOptionalChain } from './_asyncOptionalChain.js';
3 | export { _asyncOptionalChainDelete } from './_asyncOptionalChainDelete.js';
4 | export { _createNamedExportFrom } from './_createNamedExportFrom.js';
^
TypeError: Unexpected keyword 'export' while parsing module "/home/spiffytech/Documents/bootspoon/impermalink/node_modules/@sentry/utils/esm/buildPolyfills/_createNamedExportFrom.js"
at /home/spiffytech/Documents/bootspoon/impermalink/node_modules/@sentry/utils/esm/buildPolyfills/index.js:4:0
at /home/spiffytech/Documents/bootspoon/impermalink/node_modules/@sentry/utils/esm/index.js:5:0
at /home/spiffytech/Documents/bootspoon/impermalink/node_modules/@sentry/core/esm/integrations/index.js:1:0
Additional information
Jarred's remarks from Discord:
There's a few reasons why this module wouldn't work but it is interesting that this is happening at the top-level of this file
bun hasn't implemented the module for async local storage
which Sentry likely depends on
this particular bug though looks like it did an esm -> cjs transform but for some reason there was leftover export statements
this is the kind of code that breaks the most in bun's transpiler right now -- other transpilers
$ cat /home/spiffytech/Documents/bootspoon/impermalink/node_modules/@sentry/utils/esm/buildPolyfills/_createNamedExportFrom.js
/**
* Copy a property from the given object into `exports`, under the given name.
*
* Adapted from Sucrase (https://github.com/alangpierce/sucrase)
*
* @param obj The object containing the property to copy.
* @param localName The name under which to export the property
* @param importedName The name under which the property lives in `obj`
*/
function _createNamedExportFrom(obj, localName, importedName) {
exports[localName] = obj[importedName];
}
// Sucrase version:
// function _createNamedExportFrom(obj, localName, importedName) {
// Object.defineProperty(exports, localName, {enumerable: true, get: () => obj[importedName]});
// }
export { _createNamedExportFrom };
//# sourceMappingURL=_createNamedExportFrom.js.map