Skip to content

Commit

Permalink
fix: add environment variable to disable LWC version mismatch loglines (
Browse files Browse the repository at this point in the history
  • Loading branch information
nrkruk authored Feb 28, 2025
1 parent fa4c927 commit 2937602
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export function checkVersionMismatch(
) {
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
if (!isNull(versionMatcher) && !warned) {
if (process.env.SKIP_LWC_VERSION_MISMATCH_CHECK === 'true') {
warned = true; // skip printing out version mismatch errors when env var is set
return;
}

const version = versionMatcher[1];
if (version !== LWC_VERSION) {
warned = true; // only warn once to avoid flooding the console
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,23 @@ describe('compiler version mismatch', () => {
});

afterEach(() => {
process.env.SKIP_LWC_VERSION_MISMATCH_CHECK = 'false';
detachReportingControlDispatcher();
});

it('skip warning during local dev', () => {
process.env.SKIP_LWC_VERSION_MISMATCH_CHECK = 'true';
function tmpl() {
return [];
/*LWC compiler v123.456.789*/
}

expect(() => {
registerTemplate(tmpl);
}).not.toLogErrorDev(new RegExp(`LWC WARNING:`));
expect(dispatcher).not.toHaveBeenCalled();
});

it('template', () => {
function tmpl() {
return [];
Expand Down

0 comments on commit 2937602

Please sign in to comment.