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

[Bug]: 7.0.8+ "Uncaught SyntaxError: Unexpected token 'export'" if "type" is "commonjs" in package.json #22511

Closed
hailwood opened this issue May 10, 2023 · 6 comments · Fixed by #24534

Comments

@hailwood
Copy link

hailwood commented May 10, 2023

Describe the bug

Build runs fine but on page load we get a white screen with "Uncaught SyntaxError: Unexpected token 'export'" from each of the addons.

Talking with @JReinhold and we think it is likely #22247 that is the culprit.

The error only occurs if the type is explicitly "commonjs".
If it is missing or set to "module" then it does not occur.

To Reproduce

https://stackblitz.com/edit/github-3zs2je?file=package.json

System

Environment Info:

  System:
    OS: Linux 6.2 Ubuntu 23.04 23.04 (Lunar Lobster)
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  Binaries:
    Node: 19.4.0 - /run/user/1000/fnm_multishells/1690392_1683750957209/bin/node
    npm: 9.3.0 - /run/user/1000/fnm_multishells/1690392_1683750957209/bin/npm
  Browsers:
    Chrome: 113.0.5672.92
    Firefox: 112.0.2

Additional context

Original Discord thread

@DustinJSilk
Copy link

Experiencing this as well, works up until 7.0.7

@jimmynotjim
Copy link

I just ran into this while migrating from v6 to v7 in my project. I can confirm that changing the type field in package.json from commonjs to module stops the error and storybook is able to load. (though I'm facing other problems I'm hoping are just issues with our existing setup)

(Sorry for the dupe comment SB team, I just realized I left this on the original PR and not this open issue)

nickgros added a commit to nickgros/synapse-web-monorepo that referenced this issue May 24, 2023
synapse-react-client
- Fix storybook (see storybookjs/storybook#22511)
@umer4ik
Copy link

umer4ik commented Jun 8, 2023

Confirm it in 7.0.20, and changing to "type": "module" in package.json fixes the issue, but this is not suitable for me, because tests stop working

Removing "type" totally fixes the issue too and tests start to work again 🤷

@jimmynotjim
Copy link

jimmynotjim commented Jul 28, 2023

In case anyone else is tempted by the recent releases, I can confirm this is still an issue in 7.1.1 and 7.2.0. I have one project I was able to remove the type but another where it causes other issues so that one is pinned to 7.0.7

@VelizarDemirev
Copy link

Still not working with version 7.4.1. Since commonjs is the default value for type its safe atm to remove it from package.json, but its also reasonable to leave it since defaults can change. Would be nice to see a fix here.

@towry
Copy link

towry commented Oct 20, 2023

Still is an issue in 7.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

9 participants