Backticks in es6 imports/exports and jsx attributes throws error
See original GitHub issueI don’t know if this is by intention, but this throws exception:
Module build failed: SyntaxError: /Users/al/projects/js/account-cycle/src/index.js: Unexpected token (1:18)
> 1 | import Cycle from `@cycle/core`
Same for jsx attributes like <input type=
submit />
.
I think that template strings (especially one-liners without any interpolation) shouldn’t throw. Am I missing something?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Getting Unexpected Token Export - javascript - Stack Overflow
This error is suggesting that either webpack or babel are not working correctly, as export is only available in ES6, and those modules...
Read more >Diff - 402e1b6e55e9041dfd1a93580e45e5c5dba1db55^!
init fix checklicenses.py errors add OWNERS automatically rename ... VanSchooten) +* Fix: jsx-quotes exception for attributes without value ...
Read more >The JavaScript Skills You Need For React (+ ... - freeCodeCamp
In React, components are defined with both JavaScript functions and classes. But unlike JavaScript functions, React components return JSX ...
Read more >The JavaScript Skills You Need For React - DevPress - CSDN
With the addition of ES6, we were given a newer form of string called a template literal, which consists of two back ticks...
Read more >fluid-eslint | Yarn - Package Manager
bda5de5 Fix: Remove default parser from CLIEngine options (fixes #6182) (#6183) (alberto); e59e5a0 Docs: Describe options in rules under Possible Errors ...
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 Free
Top 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
For the JSX case, the answer is “because that is what the spec says”, if you want support for them you would need to bring that up with Facebook.
For the import case, the answer is that they code must be statically-readable. An environment must be able to know exactly which paths a file depends on before executing the files, and template strings, in the general case, require evaluation before knowing what the path is. That could technically be special-cased to disallow interpolation, but at that point it’s easier and avoids spec complexity to just require normal strings.
jsx template strings should be wrapped in curly braces:
<input type={
submit} />
.