Skip to content
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

adding babel plugin for IS_DEV and IS_MINIFIED transformation #19690

Merged
merged 15 commits into from Dec 14, 2018

Conversation

prateekbh
Copy link
Member

@prateekbh prateekbh commented Dec 6, 2018

Fixes #19618

  • Adds a babel transform which sets IS_DEV to false and IS_MINIFIED to true if --isfortesting is not present

* @param {Object} babelTypes
*/
module.exports = function(babelTypes) {
const {types: t} = babelTypes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: inline this into the parameter

const {id, init} = path.node;
if (t.isIdentifier(id, {name: 'IS_DEV'})
&& t.isBooleanLiteral(init, {value: true})) {
path.replaceWith(
Copy link
Contributor

Choose a reason for hiding this comment

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

Just replace the init.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually tried doing that...
can you please explain why line 73 is still true after this transform

https://astexplorer.net/#/gist/e39e874a4c808c16842a259c850df995/87476cd3629dc264148bd0b40a2daa95b83bce3d

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

done thanks

@prateekbh prateekbh merged commit 36f31e0 into ampproject:master Dec 14, 2018
@prateekbh prateekbh deleted the remo-amp-custom-runner-part1 branch December 14, 2018 05:23
cathyxz pushed a commit to cathyxz/amphtml that referenced this pull request Dec 17, 2018
…pproject#19690)

* adding babel plugin for const transformation

* adding test for transformer

* fixing the is fortesting condition

* fixing lints

* fixing lints

* fixing `is_minified` always true condition

* lint fixes

* fixing babel transformer

* fixes copyrights
noranazmy pushed a commit to noranazmy/amphtml that referenced this pull request Mar 22, 2019
…pproject#19690)

* adding babel plugin for const transformation

* adding test for transformer

* fixing the is fortesting condition

* fixing lints

* fixing lints

* fixing `is_minified` always true condition

* lint fixes

* fixing babel transformer

* fixes copyrights
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants