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

Move custom options to "ember-cli-babel" options hash #105

Merged
merged 12 commits into from Dec 7, 2016

Conversation

Projects
None yet
3 participants
@Turbo87
Copy link
Contributor

Turbo87 commented Dec 5, 2016

Resolves #102 and unblocks part of the journey to Babel 6

/cc @rwjblue @stefanpenner @nathanhammond

@Turbo87 Turbo87 added the internal label Dec 5, 2016

@nathanhammond

This comment has been minimized.

Copy link

nathanhammond commented Dec 5, 2016

  • Tests? I think we can unit test the invocations to _getBabelOptions and shouldIncludePolyfill.
  • Are there other options we supported for ember-cli-babel under the babel namespace?
@Turbo87

This comment has been minimized.

Copy link
Contributor Author

Turbo87 commented Dec 5, 2016

Are there other options we supported for ember-cli-babel under the babel namespace?

since those are the only two options that ember-cli-babel cares about I don't think there are more

Tests? I think we can unit test the invocations to _getBabelOptions and shouldIncludePolyfill

do we have some sort of test harness for that?

@Turbo87

This comment has been minimized.

Copy link
Contributor Author

Turbo87 commented Dec 5, 2016

@nathanhammond got tests now for the new logic

index.js Outdated
var customOptions = addonOptions['ember-cli-babel'];

if (customOptions && 'includePolyfill' in customOptions) {
return customOptions.includePolyfill === true;

This comment has been minimized.

@nathanhammond

nathanhammond Dec 5, 2016

Can we check to see if it is in both places here as well and writeDeprecateLine?

This comment has been minimized.

@rwjblue

rwjblue Dec 6, 2016

Member

FYI - we can't rely on writeDeprecateLine as far back as this lib supports

This comment has been minimized.

@nathanhammond

nathanhammond Dec 6, 2016

@rwjblue And I was proud of knowing this because of recent spelunking: #105 (comment)

It turns out that having an in-built ecosystem mental model is absurdly valuable...

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

@rwjblue since the deprecation will only be triggered in recent CLIs we can just use writeDeprecateLine here

@nathanhammond I'll move the deprecation check in front of everything

This comment has been minimized.

@rwjblue

rwjblue Dec 6, 2016

Member

Good point RE, newer CLI's only doing the deprecation. Maybe you can leave an inline comment (so future selves don't see it's use here as an excuse to use it for other ember-CLI deprecations)? I don't feel strongly either way though...

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

done

index.js Outdated
} else {
ui.writeLine(message, 'ERROR');
_getAddonOptions: function() {
return (this.parent && this.parent.options) || (this.app && this.app.options) || {};

This comment has been minimized.

@nathanhammond

nathanhammond Dec 5, 2016

That second check shouldn't be required unless we're going way back in support. (Before 0.2.0.)

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

@nathanhammond that is pretty much the original code and not modified by me (see

var baseOptions = (addonContext.parent && addonContext.parent.options) || (addonContext.app && addonContext.app.options);
)

index.js Outdated
var customOptions = addonOptions['ember-cli-babel'];

if (customOptions && 'compileModules' in customOptions) {
return customOptions.compileModules === true;

This comment has been minimized.

@nathanhammond

nathanhammond Dec 5, 2016

Same story: can we check to see if it is in both places here as well and writeDeprecateLine?

}
_getBabelOptions: function() {
var addonOptions = this._getAddonOptions();
var options = clone(addonOptions.babel || {});

This comment has been minimized.

@nathanhammond

nathanhammond Dec 5, 2016

Can we name options a bit more clearly? I had to look at this multiple times to figure out what it was supposed to be.

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

options was the original name. I kept it to try to keep the diff smaller.

This comment has been minimized.

@nathanhammond
index.js Outdated
options.blacklist.push('es6.modules');

if (compileModules) {
if (options.blacklist.indexOf('es6.modules') >= 0) {

This comment has been minimized.

@nathanhammond

nathanhammond Dec 5, 2016

Let's save this off, you use it three times.

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

again: this existed already before this PR (see

ember-cli-babel/index.js

Lines 125 to 135 in b9a0dc2

if (options.compileModules === true) {
if (options.blacklist.indexOf('es6.modules') >= 0) {
options.blacklist.splice(options.blacklist.indexOf('es6.modules'), 1);
}
delete options.compileModules;
} else {
if (options.blacklist.indexOf('es6.modules') < 0) {
options.blacklist.push('es6.modules');
}
}
)

This comment has been minimized.

@nathanhammond

nathanhammond Dec 6, 2016

Yes, but you already modify those lines, so let's address this one.

This comment has been minimized.

@Turbo87

Turbo87 Dec 7, 2016

Author Contributor

done

@nathanhammond

This comment has been minimized.

Copy link

nathanhammond commented Dec 5, 2016

After these changes I'm pretty sure it's good to go. Would like a bonus confirmation from @rwjblue.

index.js Outdated
@@ -16,6 +17,7 @@ module.exports = {
var dep = checker.for('ember-cli', 'npm');

this._shouldSetupRegistryInIncluded = !dep.satisfies('>=0.2.0');
this._shouldShowBabelDeprecations = !dep.lt('2.11.0-beta.1');

This comment has been minimized.

@rwjblue

rwjblue Dec 6, 2016

Member

I think this should be < 2.11.0-beta.2 since 2.11.0-beta.1 didn't include the code to prevent deprecations...?

This comment has been minimized.

@Turbo87

Turbo87 Dec 6, 2016

Author Contributor

@rwjblue I'm fine with either

@rwjblue

This comment has been minimized.

Copy link
Member

rwjblue commented Dec 6, 2016

Agreed, I am 👍 once the current round of requests are resolved. We should followup with updates in ember-cli's beta branch ASAP though...

@rwjblue rwjblue referenced this pull request Dec 6, 2016

Merged

Prevent running babel twice. #6530

5 of 6 tasks complete
@Turbo87

This comment has been minimized.

Copy link
Contributor Author

Turbo87 commented Dec 6, 2016

@rwjblue @nathanhammond addressed your requests

homu added a commit to ember-cli/ember-cli that referenced this pull request Dec 7, 2016

Auto merge of #6530 - ember-cli:avoid-two-pass-babel, r=rwjblue
Prevent running babel twice.

We currently transpile the output of all addon's `addon/` trees twice.  Once inside the addon's `treeForAddon` step (this one excludes module transpilation by adding `es6.modules` to babel's blacklist) and the second time in [lib/broccoli/ember-app.js](https://github.com/ember-cli/ember-cli/blob/2df251ce018fd12570bdce72c167ff14a427fa74/lib/broccoli/ember-app.js#L929).

This was originally done because we didn't require that addon's include their own preprocessors for JS (mostly due to performance reasons IIRC).  In the time since that decision was made, we have swapped from a few different systems `es6-module-transpiler` -> `esperanto` -> `babel`.  Now that our module transpilation step is using the same thing as we recommend addon's use (`ember-cli-babel`) what we are doing seems pretty whacky.

This PR removes the double processing of addon's `addon/` files through babel, and includes a deprecation message for the scenario that originally prompted the second pass (where an addon didn't include a module transpiling preprocessor).

TODO:

- [x] Confirm that we have tests that already confirm this is working properly (I believe that our existing nested addon tests cover these changes, but I'd like to confirm).
- [ ] Consider / discuss backporting the deprecation message for addons that do not have a transpiler and are relying on the global processing step.
- [X] Add helpful error if an addon overrides `this.options.babel.compileModules`
- [X] Implement logic to avoid deprecation being added in babel/ember-cli-babel#105.
- [X] Split out `findAddonByName` into a utility method to be shared
- [ ] r?

Addresses parts of #5015

@Turbo87 Turbo87 merged commit ae220d2 into babel:master Dec 7, 2016

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Turbo87 Turbo87 deleted the Turbo87:custom-options branch Dec 7, 2016

homu added a commit to ember-cli/ember-cli that referenced this pull request Dec 7, 2016

Auto merge of #6537 - rwjblue:use-ember-cli-babel-config, r=rwjblue
Prevent deprecation from `ember-cli-babel` config options.

Future versions of ember-cli-babel will be moving the location for its own configuration options out of `babel` and will be issuing a deprecation if used in the older way.

This changes things around to detect the correct (undeprecated) options location, and use it when possible.  Otherwise it falls back to `babel` (which is backwards compatible without a deprecation and forwards compatible with a deprecation).

/cc @Turbo87

Reference: babel/ember-cli-babel#105
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment