Comments (2)
This seems to be the cause of rollup/rollup-plugin-buble#2
from buble.
It looks like there is an issue in nested TemplateLiteral
with adding the +
prefix. The call to code.overwrite
in the second TemplateLiteral
seems to replace some of the output from the first TemplateLiteral
. I've been experimenting with ways of fixing this, but I'm not familiar with the intricacies of how the MagicString
code
is constructed over the Node
objects.
code.overwrite( lastIndex, node.end, prefix + JSON.stringify( node.value.cooked ) );
I added some logging to demonstrate.
TemplateLiteral#transpile|debug|0 {
"code": "var string = `foo${`${bar}`}`"
}
TemplateLiteral#transpile|debug|1.1 {
"prefix": "",
"node.value.cooked": "foo",
"content": "\"foo\"",
"lastIndex": 13,
"node.end": 17,
"code.slice(lastIndex, node.end)": "`foo"
}
TemplateLiteral#transpile|debug|2 { lastIndex: 17, code: 'var string = "foo"${`${bar}`}`' }
TemplateLiteral#transpile|debug|1.2 { prefix: ' + (',
code: 'var string = "foo" + (`${bar}`)}`',
parenthesise: true }
TemplateLiteral#transpile|debug|2 { lastIndex: 27, code: 'var string = "foo" + (`${bar}`)}`' }
TemplateLiteral#transpile|debug|0 {
"code": "var string = \"foo\" + ((`${bar}`)"
}
TemplateLiteral#transpile|debug|1.1 {
"prefix": "(",
"node.value.cooked": "",
"content": "(\"\"",
"lastIndex": 19,
"node.end": 20,
"code.slice(lastIndex, node.end)": " + ((`"
}
TemplateLiteral#transpile|debug|2 { lastIndex: 20, code: 'var string = "foo"(""${bar}`)' }
TemplateLiteral#transpile|debug|1.2 { prefix: ' + ',
code: 'var string = "foo"("" + bar}`)',
parenthesise: false }
TemplateLiteral#transpile|debug|2 { lastIndex: 25, code: 'var string = "foo"("" + bar}`)' }
from buble.
Related Issues (20)
- Please update acorn to 5.7.4, 6.4.1, or 7.1.1 to resolve vulnerability in acorn HOT 2
- class extends expression not transpiled HOT 1
- Number range expression is not compiled accordingly HOT 1
- Add support for Vue render functions
- compile error with for...of HOT 2
- Function declarations within blocks are transpiled into code that breaks on some pre-ES2015 targets
- A bug when destructuring in a for .. of loop HOT 1
- super relies on name of base class HOT 5
- async/await -> using array method yields error
- Invalid output when a computed property follows a property with an arrow function as value
- Mutated variables in pseudo-block-scope loops aren't written back when using `continue`
- Must call super constructor in derived class before accessing 'this' or returning from derived constructor
- Support optional chaining. HOT 5
- Security policy questions
- Jsx convertion has some problem HOT 1
- Wrong variable name in block scope
- Remove unicode regexp support and reduce50%+ bundle size.
- Make Buble ignore JSX?
- Please support setPrototypeOf instead of __proto__ HOT 1
- 11 failing tests due to mocha timeout of 2000ms HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buble.