question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Backticks in es6 imports/exports and jsx attributes throws error

See original GitHub issue

I 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:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
loganfsmythcommented, Mar 20, 2016

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.

1reaction
Lonelindcommented, Nov 18, 2015

jsx template strings should be wrapped in curly braces: <input type={submit} />.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found