Repository navigation
fix(webpack,vite): downlevel nested native classes and keep them on their own line - #11686
Merged
Merged
Conversation
The nested path spliced the inner class first and then the outer class at its original end offset, which no longer matched the edited text, leaving fragments of the inner class behind and an unparseable module. Only the outermost marked classes are collected now: transpiling the outer class to ES5 already downlevels every class inside it. All markers in the snippet are stripped, and nested files get the same source map path as everything else.
… line Edits were computed against the original text and applied back to front, so a native class nested in another left the outer edit with a stale end offset and produced broken output. Only the outermost marked class is edited now; its ES5 transpile covers the inner one. transpileModule also drops the snippet's leading newline, so a statement without a semicolon before a native class ran into the downleveled code (same as #11681 for webpack). The edit now starts with a newline.
|
View your CI Pipeline Execution ↗ for commit 00d7f82
💡 With Ultracache enabled, Nx Cloud learns each task's file inputs in CI and uses them on later runs. Turn on Ultracache in workspace settings ↗ · Read docs ↗ ☁️ Nx Cloud last updated this comment at |
commit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Checklist
What is the current behavior?
Nested native classes break the module (webpack and Vite). When a
@NativeClass()class is declared inside another native class, e.g.both bundlers downlevel the inner class first, then splice the outer class back in using its original end offset. That offset no longer matches the edited text, so fragments of the inner class are left behind (
__extends(B);, a dangling}(NSObject));, …) and the module fails to parse.Vite also has #11681's missing newline.
ts.transpileModuledrops the snippet's leading newline, so a statement without a semicolon before a native class runs into it:const a = 1var Foo = …. #11683 fixed this for webpack only.What is the new behavior?
enumerable: truerewrite covers the whole output.New specs (all fail without the fix):
packages/webpack5/__tests__/loaders/native-class-loaders.spec.ts: nested native classpackages/vite/helpers/nativeclass-transformer.spec.ts: nested native class; statement without semicolon before a native classVerification: webpack loader specs 23/23, full Vite suite 1967/1967,
tsc --noEmitfor both packages. The full webpack5 jest run has the same 16 failures in__tests__/configuration/*.spec.tsasmaindoes; they are unrelated to this change.