Skip to content

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

Merged
merged 15 commits into from
Jun 6, 2019
Merged

feat(common): Add dev-mode sanity check for mismatched versions of cdk and material #15395

merged 15 commits into from
Jun 6, 2019

Conversation

macjohnny
Copy link
Contributor

Add dev-mode sanity check for mismatched versions of cdk and material and show console warning if versions don't match.

Fixes #15387

@googlebot googlebot added the cla: yes PR author has agreed to Google's Contributor License Agreement label Mar 6, 2019
…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
@macjohnny
Copy link
Contributor Author

macjohnny commented Mar 6, 2019

@jelbourn the bazel builds fail due to the @angular/cdk index file not being exported in some test configurations and in
src/lib/core/common-behaviors/common-module.ts I import the cdk version as follows:

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) {
Copy link
Member

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

Copy link
Contributor Author

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))?

Copy link
Contributor Author

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.

Copy link
Member

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?

Copy link
Member

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)

Copy link
Contributor Author

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?

macjohnny added 10 commits March 7, 2019 07:21
…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

refactor version export
…s of cdk and material

fix linting, fix prerender build
'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
Copy link
Member

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.

Copy link
Contributor Author

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
Copy link
Member

@devversion devversion left a 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.

@macjohnny
Copy link
Contributor Author

@devversion the various tsconf mappings are necessary for

  • the IDE during development
  • running the tests
  • running the prerender
    Removing any will cause at least one test/build to fail

@devversion
Copy link
Member

devversion commented Mar 11, 2019

@macjohnny It's okay having these configs. Though I initially wasn't sure why it would be necessary in the universal-app since nothing explicitly imports from the @angular/cdk primary entry-point.

For later reference: This is because of some SSR workaround, which requires us to copy the release output into the dist/ and build everything from there (therefore the typings need the path mapping)

Copy link
Member

@jelbourn jelbourn left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@jelbourn jelbourn added action: merge The PR is ready for merge by the caretaker target: minor This PR is targeted for the next minor release labels Mar 27, 2019
@mmalerba mmalerba added the aaa label Apr 25, 2019
@mmalerba mmalerba removed the aaa label Apr 25, 2019
@macjohnny
Copy link
Contributor Author

@jelbourn will this make it into the v8 release?

@jelbourn
Copy link
Member

Probably will be 8.1 at this point

@andrewseguin andrewseguin added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label May 30, 2019
@josephperrott josephperrott added action: merge The PR is ready for merge by the caretaker and removed action: merge The PR is ready for merge by the caretaker labels Jun 5, 2019
@josephperrott josephperrott merged commit ffad004 into angular:master Jun 6, 2019
RudolfFrederiksen pushed a commit to RudolfFrederiksen/material2 that referenced this pull request Jun 21, 2019
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes PR author has agreed to Google's Contributor License Agreement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent target: minor This PR is targeted for the next minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add dev-mode sanity check for mismatched versions of cdk and material
8 participants