Skip to content

Conversation

@rax-it
Copy link
Contributor

@rax-it rax-it commented Oct 21, 2025

Details

This change introduces a transformOption: experimentalErrorRecoveryMode which also sets babel parsers errorRecovery flag.
This changes lwc compilers, specifically babel-plugin-component behavior from

Throw at FIRST Error --> Collect as MANY errors as we can in a single invocation

While in theory we might still get errors in subsequent compile requests as some validation paths were skipped because we couldn't continue in a meaningful way.

These errors are then put in-to a bag of errors, {metadata: { lwcErrors: CompilerError[]}}, upon completion of the transform process our transformer looks for presence of these errors and throws an AggregateError.

Currently, only scriptTransformer is updated to utilize this behavior with other transformers (html, css) to follow suit.
experimentalErrorRecoveryMode defaults to false hence there should be no observable changes in current compilation scenarios.

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

GUS work item

W-19992686

@rax-it rax-it marked this pull request as ready for review October 23, 2025 19:56
@rax-it rax-it requested a review from a team as a code owner October 23, 2025 19:56

expect(() => {
transformSync(actual, 'foo.js', TRANSFORM_OPTIONS);
}).toThrowAggregateError(['LWC1107: Invalid property name "dataInvalidProperty".']);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
}).toThrowAggregateError(['LWC1107: Invalid property name "dataInvalidProperty".']);
}).toThrow(aggregatErrorMatcher(['LWC1107: Invalid property name "dataInvalidProperty".']));

We can use asymmetric matchers to avoid having to a whole new thing.

function aggregateErrorMatcher(messages: string[]) {
    return expect.objectContaining({
        name: 'AggregateError',
        message: 'Multiple errors occurred during compilation.',
        errors: messages.map((msg) => {
            return expect.objectContaining({
                name: 'Error',
                message: expect.stringContaining(msg),
            });
        }),
    });
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants