Skip to content
This repository has been archived by the owner on Sep 1, 2024. It is now read-only.

Optimize #268

Closed
wants to merge 2 commits into from
Closed

Optimize #268

wants to merge 2 commits into from

Conversation

noscripter
Copy link
Contributor

@noscripter noscripter commented Apr 11, 2019

  • [x] extract process.env.NODE_ENV
  • more intuitive createChainableTypeChecker condition
  • use loose-envify as a devDependency

@TrySound
Copy link

@noscripter NODE_ENV is replaced statically with bundler for browsers. It should not be extracted.

@noscripter
Copy link
Contributor Author

noscripter commented Apr 11, 2019

@noscripter NODE_ENV is replaced statically with bundler for browsers. It should not be extracted.

Thanks for that info, can you provide more detail for me to dive into?

@TrySound
Copy link

This convention is shared across many packages (especially react ones)
https://github.com/rollup/rollup-plugin-replace
https://webpack.js.org/guides/production/#specify-the-mode

@noscripter
Copy link
Contributor Author

This convention is shared across many packages (especially react ones)
https://github.com/rollup/rollup-plugin-replace
https://webpack.js.org/guides/production/#specify-the-mode

Coool, thanks.

@@ -206,7 +206,8 @@ module.exports = function(isValidElement, throwOnDirectAccess) {
}
}
}
if (props[propName] == null) {
// undefined == null and null == null are true
if (props[propName] === null || props[propName] === undefined) {
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this a better change? == null is more reliable, since undefined can be redefined.

Copy link
Contributor Author

@noscripter noscripter Apr 12, 2019

Choose a reason for hiding this comment

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

why is this a better change? == null is more reliable, since undefined can be redefined.

Thanks @ljharb I found this question on stackoverflow, it looks like a problem related to legacy browsers only, but your review did make sense.

Copy link
Contributor Author

@noscripter noscripter Apr 12, 2019

Choose a reason for hiding this comment

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

Also according to MDN, undefined should be un-writable but it's not a reserved word, so in some context it may be redefined as well.

(function() { var undefined = 'foo'; console.log(undefined, typeof undefined); })();

@@ -47,6 +46,7 @@
"eslint": "^5.13.0",
"in-publish": "^2.0.0",
"jest": "^19.0.2",
"loose-envify": "^1.4.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

this must be a runtime dependency, otherwise #203 (comment) breaks people.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this must be a runtime dependency, otherwise #203 (comment) breaks people.

Got it, I thought it was only used for build in the first place.

@noscripter noscripter closed this Apr 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants