-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Duplicate "use strict"
prologue in the generated output.
#25550
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
TS transformer uses The second const alwaysStrict = getStrictOptionValue(compilerOptions, "alwaysStrict") &&
!(isExternalModule(node) && moduleKind >= ModuleKind.ES2015) &&
!isJsonSourceFile(node); as the result, Does that make sense? What do you think? |
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. |
@weswigham thanks.
Should we remove prologues from prepends or check if prologues exist in some of them and skip adding |
@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. |
@weswigham thanks. For instance, during concatenation, we need to remove "use strict" prologue directly in |
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. |
@weswigham I thought that we could track |
Yeah. Instead you wanna create a scanner and scan the text and check the type of the first token. |
@a-tarasyuk are you interested in sending a PR for this? |
Duplicate
"use strict"
prologue in the generated output.See https://raw.githubusercontent.com/Microsoft/TypeScript/master/lib/tsc.js
The text was updated successfully, but these errors were encountered: