`(plugin commonjs) SyntaxError: Unexpected token typeof`
- Rollup Plugin Name:
commonjs - Rollup Plugin Version:
21.0.1 - Rollup Version:
2.61.1 - Operating System (or Browser): MacOS 11.6
- Node Version:
16.13.0 - Link to reproduction (⚠️ read below): https://github.com/razorpay/blade/pull/391
Steps to reproduce:
- Clone the repository
- Checkout this branch
- Run
yarnat the repo root
Expected Behavior
After I upgraded the babel packages from versions 7.14.x to 7.16.x my rollup builds starts failing. Specifically the @rollup/plugin-commonjs. It starts throwing below error
[!] (plugin commonjs) SyntaxError: Unexpected token (14:7) in /home/runner/work/blade/blade/packages/blade/node_modules/react-native/index.js
node_modules/react-native/index.js (14:7)
12:
13: // Components
14: import typeof AccessibilityInfo from './Libraries/Components/AccessibilityInfo/AccessibilityInfo';
Here's the github action link to see the exact error details
While upgrading I also upgraded the commons plugin version to 21.x and then again tried reverting that but seems like there's something which commonjs plugin is not liking and it's difficult to identify from the logs what exactly is going wrong.
Although the project is running absolutely fine, the tests are passing too which means it's not necessarily the problem with babel?
Actual Behavior
The plugin shall transform and build successfully.
Additional Information
Here's my rollup.config.js. There's no change in the rollup config, just the packages have been upgraded.
Thanks for opening an issue. Citing the issue template:
🚨 Issues WITHOUT a valid reproduction WILL BE CLOSED!
Please provide one by:
- Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
- Provide a minimal repository link (Read https://git.io/fNzHA for instructions). Please use NPM for installing dependencies! These may take more time to triage than the other options.
- Using the Rollup REPL at https://rollupjs.org/repl/
⚠️ ZIP Files are unsafe and maintainers will NOT download them.
We cannot make this any clearer. Please add a reproduction and we'll be happy to triage further.
Hey @shellscape I linked to a repro branch in the description with steps to reproduce the issue as well. 🤔
Putting the branch here again - https://github.com/razorpay/blade/tree/add-storybook
@kamleshchandnani we have three options for a valid reproduction. See my reply above. What you've provided doesn't match any of our accepted options. It's not the maintainer's job here to wade through complex repositories. Please choose one of the options we accept so that your issue is isolated, and we'll be happy to reopen the issue for triage.
@kamleshchandnani Did you fix that? I have a same problem in my project.
Same problem here, any fix ? @kamleshchandnani @SixiCat
Same issue on ubuntu
Please do not reply with "same," "me too," or +1. Please use the reaction buttons on the issue instead.
To clarify I have this problem on Ubuntu same config works on MacOS 10.15 for me. So it's not exactly the same issue.
OK thanks for clarifying