Skip to content

CPLAT-11281 Only include propTypes in DDC output#258

Merged
greglittlefield-wf merged 8 commits into
masterfrom
proptypes-only-in-ddc
Sep 8, 2020
Merged

CPLAT-11281 Only include propTypes in DDC output#258
greglittlefield-wf merged 8 commits into
masterfrom
proptypes-only-in-ddc

Conversation

@aaronlademann-wf
Copy link
Copy Markdown
Collaborator

@aaronlademann-wf aaronlademann-wf commented Jun 3, 2020

NOTE: We need to coordinate the release of these changes with updates to the logsPropError* matchers in over_react_test so that consumer tests asserting propTypes logging running in dart2js don't start to fail.

Problem

propTypes are a dev-only tool that do nothing when react_dom_with_react_dom_prod.js is utilized. That production build of react is most commonly used alongside a production deploy of Dart code compiled with dart2js.

Currently, the propTypes maps remain in the dart2js output - adding unnecessary bulk to consumer module(s).

Solution

Wrap the access to Component2.propTypes in an assert() so that they are included in JS compiled using DDC, but not dart2js.

Boy Scoutin'

  • Deprecated registerComponent. This should have been deprecated when Component was - but we missed it.

propTypes are a dev-only tool, so they should not be present in the compiled dart2js output sent to production.
+ This one slipped through the cracks.  Should have been deprecated with the release of Component2
@aaronlademann-wf aaronlademann-wf marked this pull request as ready for review June 10, 2020 14:43
Copy link
Copy Markdown

@willdrach-wk willdrach-wk left a comment

Choose a reason for hiding this comment

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

lgtm, obviously would like someone else with more expertise to take a look

Comment thread test/lifecycle_test.dart
if (isDDC()) {
test('', () {
expect(consoleErrorCalled, isTrue, reason: 'should have outputted a warning');
expect(consoleErrorMessage, contains(expectedWarningPrefix));
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

[nit] could this be a startsWith?

# Conflicts:
#	lib/react_client.dart
@aaronlademann-wf aaronlademann-wf changed the base branch from master to 5.5.0-wip August 7, 2020 14:14
@aaronlademann-wf aaronlademann-wf changed the base branch from 5.5.0-wip to master August 7, 2020 14:21
# Conflicts:
#	lib/react.dart
#	lib/react_client.dart
#	test/util.dart
@aaronlademann-wf aaronlademann-wf changed the base branch from master to 5.5.0-wip August 7, 2020 14:26
@aaronlademann-wf aaronlademann-wf added this to the 5.5.0 milestone Aug 7, 2020
@aaronlademann-wf aaronlademann-wf removed this from the 5.5.0 milestone Aug 7, 2020
@aaronlademann-wf aaronlademann-wf changed the base branch from 5.5.0-wip to master August 7, 2020 22:22
@aaronlademann-wf
Copy link
Copy Markdown
Collaborator Author

Just FYI - the dev SDK travis build is failing e'where - it is unrelated to the changes in this PR.

Comment thread test/util.dart Outdated
Copy link
Copy Markdown
Collaborator

@greglittlefield-wf greglittlefield-wf left a comment

Choose a reason for hiding this comment

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

+10

@greglittlefield-wf greglittlefield-wf merged commit 7509aad into master Sep 8, 2020
@greglittlefield-wf greglittlefield-wf deleted the proptypes-only-in-ddc branch February 16, 2022 21:53
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.

4 participants