Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected keyword "export", when importing Sentry #1270

Closed
spiffytech opened this issue Sep 21, 2022 · 4 comments · Fixed by #2312
Closed

Unexpected keyword "export", when importing Sentry #1270

spiffytech opened this issue Sep 21, 2022 · 4 comments · Fixed by #2312
Labels
bug Something isn't working transpiler parser || printer

Comments

@spiffytech
Copy link

spiffytech commented Sep 21, 2022

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
@spiffytech spiffytech added bug Something isn't working needs repro Needs an example to reproduce labels Sep 21, 2022
@Electroid Electroid removed the needs repro Needs an example to reproduce label Nov 3, 2022
@Electroid Electroid added the transpiler parser || printer label Jan 18, 2023
@bnussman
Copy link

bnussman commented Feb 9, 2023

Also seeing this issue! Might be the only thing from keeping me from deploying bun to prod 🥺

@bnussman
Copy link

bnussman commented Apr 8, 2023

thank you daddy @Jarred-Sumner

@drazisil
Copy link

@Jarred-Sumner Is this issue resolved? The merged PR, #2312 says it's not complete, and I'm still seeing this error in 0.5.9.

@Jarred-Sumner
Copy link
Collaborator

Bun's new bundler is in canary build and will be in v0.6.0, not released yet

It should be solved after bundling, but please leave a comment if it's not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working transpiler parser || printer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants