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

Add shared Promise.resolve() babel transform #27960

Merged
merged 4 commits into from
Apr 25, 2020

Conversation

jridgewell
Copy link
Contributor

Re: #27901

@amp-owners-bot
Copy link

amp-owners-bot bot commented Apr 22, 2020

Hey @erwinmombay, these files were changed:

build-system/babel-plugins/babel-plugin-transform-promise-resolve/index.js
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/argument/input.js
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/argument/options.json
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/argument/output.mjs
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/not-promise-resolve/input.js
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/not-promise-resolve/options.json
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/not-promise-resolve/output.mjs
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/promise-resolve/input.js
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/promise-resolve/options.json
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/promise-resolve/output.mjs
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/relative-importing/input.js
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/relative-importing/options.json
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/fixtures/transform/relative-importing/output.mjs
build-system/babel-plugins/babel-plugin-transform-promise-resolve/test/index.js

Hey @gmajoulet, these files were changed:

extensions/amp-story/0.1/amp-story-info-dialog.js
extensions/amp-story/0.1/media-pool.js
extensions/amp-story/1.0/amp-story-info-dialog.js
extensions/amp-story/1.0/amp-story-page.js
extensions/amp-story/1.0/media-pool.js

Hey @newmuis, these files were changed:

extensions/amp-story/0.1/amp-story-info-dialog.js
extensions/amp-story/0.1/media-pool.js
extensions/amp-story/1.0/amp-story-info-dialog.js
extensions/amp-story/1.0/amp-story-page.js
extensions/amp-story/1.0/media-pool.js

Hey @Enriqe, these files were changed:

extensions/amp-story/0.1/amp-story-info-dialog.js
extensions/amp-story/0.1/media-pool.js
extensions/amp-story/1.0/amp-story-info-dialog.js
extensions/amp-story/1.0/amp-story-page.js
extensions/amp-story/1.0/media-pool.js

Copy link
Member

@samouri samouri left a comment

Choose a reason for hiding this comment

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

I know Babel processing is mainly about transforming files, but does it also have the ability to create new ones? For this transform in particular, it would be neat if it could generate the src/resolved-promise.js file.

All my review comments were nits/questions for my own learning.

LGTM 🚢

module.exports = function (babel, options = {}) {
const {types: t} = babel;
const promiseResolveMatcher = t.buildMatchMemberExpression('Promise.resolve');
const {importFrom = 'src/resolved-promise'} = options;
Copy link
Member

@samouri samouri Apr 23, 2020

Choose a reason for hiding this comment

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

Another way to solve the "transform recursion" issue would be if the transform early-exited when transforming the importFrom module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yah.

@@ -0,0 +1,52 @@
/**
* Copyright 2018 The AMP HTML Authors. All Rights Reserved.
Copy link
Member

Choose a reason for hiding this comment

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

nit: 2020.

Q: does having the correct current year matter? i.e. is this worth the time spent commenting/fixing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really. I end up copy pasting this all the time, and forgetting to update.

@jridgewell jridgewell merged commit f98b66a into ampproject:master Apr 25, 2020
@jridgewell jridgewell deleted the shared-promise-resolve branch April 25, 2020 00:01
ldoroshe pushed a commit to ldoroshe/amphtml that referenced this pull request May 8, 2020
* Add shared Promise.resolve() babel transform

* Fixes

* Add dependency allowList exceptions

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

Successfully merging this pull request may close these issues.

None yet

5 participants