You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate "use strict" prologue in the generated output. #25550
The second "use strict"TS transformer adds in the method visitSourceFile because the following condition does not check "use strict" definition in the node.prepends
Yep, that's exactly the problem. To fix it, we need to instantiate a scanner and scan the first of the prepends to see if it already has a use strict statement.
Actually, we should scan all of them and remove any prologues we find and unify them/move them to the top. That has interesting implications for souremapping, too.
Actually, we should scan all of them and remove any prologues we find and unify them/move them to the top. That has interesting implications for souremapping, too.
Should we remove prologues from prepends or check if prologues exist in some of them and skip adding "use strict" later? Why I ask, because "compiler.js" has "use strict", and in my opinion, it is right, because "compiler.js" independent file and it should contain "use strict"., just need to skip adding addition prologues later
Oleksandr Tarasiuk (@a-tarasyuk) Keeping them in the intermediate outputs is fine (heck, we should probably even error if they don't all have the same set of prologues - concating a loose file to a strict one could be bad!) - we just need to remove them when concatenating and fixup the resulting concatenated sourcemaps.
Wesley Wigham (@weswigham) thanks. For instance, during concatenation, we need to remove "use strict" prologue directly in javascriptText(string representation). is it true? I just want to fix and make PR, if you don't mind. :)
I don't think we can remove it on load - since we need to track what we remove to update the sourcemap positions - it should probably just be elided during concatenation itself.
Activity
a-tarasyuk commentedon Jul 12, 2018
Mohamed Hegazy (@mhegazy) Wesley Wigham (@weswigham)
TS transformer uses
node.prepends, which includesbuild/local/compiler.js(createInputFiles,node.javascriptText).compiler.jshas own"use strict"definition - it is the first"use strict"The second
"use strict"TS transformer adds in the methodvisitSourceFilebecause the following condition does not check"use strict"definition in thenode.prependsas the result,
tsc.jscontains"use strict";"use strict";Does that make sense? What do you think?
weswigham commentedon Jul 12, 2018
Yep, that's exactly the problem. To fix it, we need to instantiate a scanner and scan the first of the prepends to see if it already has a use strict statement.
weswigham commentedon Jul 12, 2018
Actually, we should scan all of them and remove any prologues we find and unify them/move them to the top. That has interesting implications for souremapping, too.
a-tarasyuk commentedon Jul 13, 2018
Wesley Wigham (@weswigham) thanks.
Should we remove prologues from prepends or check if prologues exist in some of them and skip adding
"use strict"later? Why I ask, because"compiler.js"has"use strict", and in my opinion, it is right, because"compiler.js"independent file and it should contain"use strict"., just need to skip adding addition prologues laterweswigham commentedon Jul 17, 2018
Oleksandr Tarasiuk (@a-tarasyuk) Keeping them in the intermediate outputs is fine (heck, we should probably even error if they don't all have the same set of prologues - concating a loose file to a strict one could be bad!) - we just need to remove them when concatenating and fixup the resulting concatenated sourcemaps.
a-tarasyuk commentedon Jul 17, 2018
Wesley Wigham (@weswigham) thanks. For instance, during concatenation, we need to remove "use strict" prologue directly in
javascriptText(string representation). is it true? I just want to fix and make PR, if you don't mind. :)weswigham commentedon Jul 17, 2018
I don't think we can remove it on load - since we need to track what we remove to update the sourcemap positions - it should probably just be elided during concatenation itself.
a-tarasyuk commentedon Jul 18, 2018
Wesley Wigham (@weswigham) I thought that we could track
"use strict";prologue when the compiler buildsprepends-getPrependNodes, however, it is not true.weswigham commentedon Jul 18, 2018
Yeah. Instead you wanna create a scanner and scan the text and check the type of the first token.
DanielRosenwasser commentedon Oct 30, 2018
Oleksandr Tarasiuk (@a-tarasyuk) are you interested in sending a PR for this?