Repository navigation
fix(webpack): keep a newline before downleveled native classes - #11683
NathanWalker merged 2 commits into
Conversation
|
✅ All contributors on this pull request have satisfied the NativeScript CLA. |
ts.transpileModule drops the snippet's leading newline, so a statement without a semicolon before a native class ran into the downleveled code. Closes NativeScript#11681
f107128 to
a5b21ed
Compare
|
I have read the CLA and I hereby sign the CLA |
|
Thanks @mrichtsfeld — your signature on this PR satisfies the CLA check, and you'll be recorded on the |
NathanWalker
left a comment
There was a problem hiding this comment.
Thanks for the fix and the regression test! Verified locally: the loader specs pass, the new spec fails without the newline, and the sourcemap spec fails without the leadingLines bump, so both halves are covered. Also checked class-at-file-start, export class, back-to-back classes, CRLF, and the full @NativeClass() strip-loader flow — all parse and map correctly. I pushed a one-line comment update noting the separator newline in leadingLines.
|
Thanks for approving and merging it so quickly. My pleasure to fix it. |
ts.transpileModule drops the snippet's leading newline, so a statement without a semicolon before a native class ran into the downleveled code.
Closes #11681
PR Checklist
I have read the CLA and I hereby sign the CLA).What is the current behavior?
native-class-downlevel-loadersplices each downleveled/*__NativeClass__*/class back at the class's full start, butts.transpileModuledrops the snippet's leading newline. When the statement before the class has no semicolon, the downleveled code runs into it:becomes
and the module no longer parses.
What is the new behavior?
The downleveled code starts with a newline, so the preceding statement stays separate. The newline is counted in
leadingLines, so the source-map offsets from #11647 stay correct; the existingnative-class-sourcemapspec fails if that count is missing.#11588 (TypeScript 6) strips a
"use strict"prologue from the same output. The newline is still missing after that strip, so both changes are needed.A new spec in
native-class-loaders.spec.tscovers the case; it fails without the fix.Closes #11681.