Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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') {
Copy link
Contributor

Choose a reason for hiding this comment

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

process?.env
Are we expecting to encounter a scenario where the process variable is declared but null/undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was just being extra cautious - I didn't know how things were compiled (and what is shipped to the browser vs whats available in server side engine). Didn't want to unintentionally break something for this one usecase.

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,27 @@ 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: current engine is v${process.env.LWC_VERSION}, but template was compiled with v123.456.789`
)
);
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
}).not.toLogErrorDev(
new RegExp(
`LWC WARNING: current engine is v${process.env.LWC_VERSION}, but template was compiled with v123.456.789`
)
);
}).not.toLogErrorDev(/v123\.456\.789/);

Checking that we're not logging such a long message feels easy to get an accidental false positive, if the error text ever changes. We should just check for keywords to be more flexible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure I can make it more generic

expect(dispatcher).not.toHaveBeenCalled();
});

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