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

Use babel-plugin-transform-react-remove-prop-types for build:node task #463

Merged
merged 1 commit into from Jul 19, 2017

Conversation

2 participants
@oigewan

oigewan commented Jul 19, 2017

Feature:
Fixes #462

This will wrap all assignments to the propTypes property of a React component class in a process.env.NODE_ENV !== "production", which will allow npm module consumers to remove prop types for their production build. This will allow for smaller deployables for consumers.

Known Issue:
This will require users to inject the value for process.env.NODE_ENV. Consumers can do this via webpack's Environment Plugin or rollup's Replace Plugin.

Changes:
Add transform-react-remove-prop-types to the .babelrc file with the mode set to "wrap". Output will end up looking like this:

exports.default = Caption;
Caption.propTypes = process.env.NODE_ENV !== "production" ? {
  date: _propTypes2.default.instanceOf(Date),
  months: _propTypes2.default.arrayOf(_propTypes2.default.string),
  locale: _propTypes2.default.string,
  localeUtils: _propTypes2.default.object,
  onClick: _propTypes2.default.func,
  classNames: _propTypes2.default.shape({
    caption: _propTypes2.default.string.isRequired
  }).isRequired
} : {};

cc: @gpbl

@codecov

This comment has been minimized.

Show comment
Hide comment
@codecov

codecov bot Jul 19, 2017

Codecov Report

Merging #463 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #463   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          15     15           
  Lines         527    527           
  Branches      109    109           
=====================================
  Hits          527    527

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a05d673...f732f1e. Read the comment docs.

codecov bot commented Jul 19, 2017

Codecov Report

Merging #463 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #463   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          15     15           
  Lines         527    527           
  Branches      109    109           
=====================================
  Hits          527    527

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a05d673...f732f1e. Read the comment docs.

@gpbl gpbl merged commit fce0368 into gpbl:master Jul 19, 2017

3 checks passed

ci/circleci: checkout-and-test Your tests passed on CircleCI!
Details
codecov/patch Coverage not affected when comparing a05d673...f732f1e
Details
codecov/project 100% remains the same compared to a05d673
Details
@gpbl

This comment has been minimized.

Show comment
Hide comment
@gpbl

gpbl Jul 19, 2017

Owner

thanks!

Owner

gpbl commented Jul 19, 2017

thanks!

@gpbl gpbl added this to the v6.1.1 milestone Jul 19, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment