-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(common): Add dev-mode sanity check for mismatched versions of cdk and material #15395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(common): Add dev-mode sanity check for mismatched versions of cdk and material #15395
Conversation
…k and material Add dev-mode sanity check for mismatched versions of cdk and material and show console warning if versions don't match. Fixes #15387
@jelbourn the bazel builds fail due to the import {VERSION as CDK_VERSION} from '@angular/cdk'; it would be much easier to export the cdk version in a secondary entry point, too, e.g. import {VERSION as CDK_VERSION} from '@angular/cdk/bidi'; would you accept that? the same applies to the material version... or could you give me a hand fixing the remaining bazel configurations that are failing? |
…s of cdk and material fix version comparison
@@ -104,6 +107,18 @@ export class MatCommonModule { | |||
this._document.body.removeChild(testElement); | |||
} | |||
|
|||
/** Checks whether the material version matches the cdk version */ | |||
private _checkCdkVersionMatch(): void { | |||
if (VERSION.major !== CDK_VERSION.major && VERSION.minor !== CDK_VERSION.minor) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually want to go so far as to say that the versions have to exactly match. You could do this by comparing VERSION.full !== CDK_VERSION.full
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jelbourn I updated the PR to compare the full version. could you please tell me how you want me to proceed concerning the test-build issues (see my comment above: #15395 (comment))?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I exported an additional symbol export const ɵVERSION
in the @angular/cdk/bidi
module and added another non-exportet VERSION
symbol in the common-module.ts
, otherwise it would be necessary to adapt various build configs to allow accessing the VERSION
symbol from @angular/material
and @angular/cdk
.
The build and tests now work without failures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be necessary. @devversion could you advise on the build issue here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@macjohnny Yeah. You should be able to import the version from @angular/material
and @angular/cdk
. In order to allow this, we need to adjust the tsconfig path mapping (like you already did with your initial commit).
Also for Bazel, you need to update the ng_module
definition here. Just add //src/cdk
there (before //src/cdk/a11y
).
Though it will be a bit more difficult for the version from Material. We don't want core
to depend on the @angular/material
primary entry-point which transitively depends on all Material secondary entry-points (e.g. slide-toggle
, list
etc.)
Maybe the best would be to just use the version placeholder in core
(like it's done right now) with a proper comment. Eventually we can remove this once the Material primary entry-point no longer re-exports all secondary entry-points (see how the CDK entry-point works)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devversion @jelbourn I updated the PR according to your suggestions. the build now works without additionally exporting the VERSION
symbol. could you have a look at it again?
…versions of cdk and material fix version comparison
…atched versions of cdk and material export version in secondary entry point to avoid testing issues
…or mismatched versions of cdk and material fix testing / build issues
…s of cdk and material fix build issues
…s of cdk and material fix build issues
…s of cdk and material fix upgrade issues
…s of cdk and material refactor version export
…ode-cdk-material-version-check
…s of cdk and material fix linting, fix prerender build
…s of cdk and material code cleanup
'The Angular Material version ' + VERSION.full + ' does not match ' + | ||
'the Angular CDK version ' + (CDK_VERSION ? CDK_VERSION.full : '') + '.\n' + | ||
'Please install Angular CDK ' + VERSION.full + ': ' + | ||
'npm install @angular/cdk@' + VERSION.full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would tweak the message to be:
The Angular Material version (xxx) does not match the Angular CDK version (yyy). Please
ensure the versions of these two packages exactly match.
Since people might want to keep their cdk version and change material. Also people might be using yarn
, so I would avoid giving an actual command.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated the message accordingly
…s of cdk and material change warning message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tsconfig mapping should be only necessary for the src/lib/tsconfig-build.json
, but it doesn't hurt.
LGTM from my side.
@devversion the various tsconf mappings are necessary for
|
@macjohnny It's okay having these configs. Though I initially wasn't sure why it would be necessary in the For later reference: This is because of some SSR workaround, which requires us to copy the release output into the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
…ode-cdk-material-version-check
@jelbourn will this make it into the v8 release? |
Probably will be 8.1 at this point |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Add dev-mode sanity check for mismatched versions of cdk and material and show console warning if versions don't match.
Fixes #15387