Uncaught SyntaxError: Invalid or unexpected token using forceAllTransforms preset
See original GitHub issueBug Report
- I would like to work on a fix!
Current behavior
- Manually transpiling using babel.transform() with forceAllTransforms preset
- After viewing the result, I got the “Uncaught SyntaxError: Invalid or unexpected token” error in console
Input Code
babel.transform(code, {
comments: false,
compact: true,
minified: true,
presets: [
[
"@babel/preset-env",
{
targets: {
chrome: 59,
edge: 13,
firefox: 50,
},
// for uglifyjs...
forceAllTransforms: true,
},
],
],
}, (err, result) => {
...
});
Environment
- Babel version(s): 7.12.3
- Node/npm version: Node 14.15.3 / npm 6.14.4
- OS: Windows 10
- Monorepo: yes
- How you are using Babel: webpack
Possible Solution
Removing the “\n” characters from generated line below, solves the issue
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Uncaught SyntaxError: Invalid or unexpected token
I am a beginner so I get stuck in syntax a lot. If it is that then please help me out. javascript ·...
Read more >SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >Uncaught Syntaxerror: Invalid Or Unexpected Token For New ...
The JavaScript exception illegal character occurs when there is an invalid or unexpected token that doesn't belong at this position in the code....
Read more >SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: Having a <script /> tag that points to an HTML file instead of a...
Read more >Uncaught SyntaxError: Invalid or unexpected token
You should try to exclude the file from being minified in Performance>Minify>Css>Never minify following css files save all settings and purge the case,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m trying to create a clean repo in order to make it easy to find the issue as the problem has been found on a big (an private) repo I cannot share
Since this issue has been inactive for a long time, I will close it for now, feel free to reopen it if the issue persists.