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

[7.0] Remove bc code from preset handling and preset-es2015 #5128

Merged
merged 4 commits into from Feb 22, 2017
Merged

[7.0] Remove bc code from preset handling and preset-es2015 #5128

merged 4 commits into from Feb 22, 2017

Conversation

danez
Copy link
Member

@danez danez commented Jan 15, 2017

Q A
Patch: Bug Fix? n
Major: Breaking Change? y
Minor: New Feature? n
Deprecations? y
Spec Compliancy? n
Tests Added/Pass? y
Fixed Tickets
License MIT
Dependency Changes

For bc we supported exporting an object + function (as buildPreset) at the same time. This now removes the bc and a preset needs to export either an object or a function as default export or module.export.

@danez danez added the PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release label Jan 15, 2017
@danez danez added this to the Babel 7 milestone Jan 15, 2017
@mention-bot
Copy link

@danez, thanks for your PR! By analyzing the history of the files in this pull request, we identified @loganfsmyth, @motiz88 and @hzoo to be potential reviewers.

@codecov-io
Copy link

codecov-io commented Jan 15, 2017

Codecov Report

Merging #5128 into 7.0 will increase coverage by 0.04%.
The diff coverage is 95.23%.

@@            Coverage Diff             @@
##              7.0    #5128      +/-   ##
==========================================
+ Coverage   90.38%   90.43%   +0.04%     
==========================================
  Files         200      208       +8     
  Lines        9925     9938      +13     
  Branches     2697     2695       -2     
==========================================
+ Hits         8971     8987      +16     
+ Misses        954      951       -3
Impacted Files Coverage Δ
packages/babel-preset-es2015/src/index.js 94.73% <100%> (-0.51%)
packages/babel-preset-flow/src/index.js 100% <100%> (ø)
packages/babel-preset-es2017/src/index.js 100% <100%> (ø)
packages/babel-preset-react/src/index.js 100% <100%> (ø)
packages/babel-preset-stage-0/src/index.js 100% <100%> (ø)
packages/babel-preset-stage-1/src/index.js 100% <100%> (ø)
packages/babel-preset-latest/src/index.js 100% <100%> (ø)
packages/babel-preset-stage-2/src/index.js 100% <100%> (ø)
packages/babel-preset-stage-3/src/index.js 100% <100%> (ø)
packages/babel-preset-es2016/src/index.js 100% <100%> (ø)
... and 9 more

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 d9f01cb...274db46. Read the comment docs.

@danez danez changed the base branch from master to 7.0 January 15, 2017 19:39
if (typeof val !== "function" && options !== undefined) {
throw new Error(`Options ${JSON.stringify(options)} passed to ` +
(presetLoc || "a preset") + " which does not accept options.");
if (typeof val === "function") {
Copy link
Member

Choose a reason for hiding this comment

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

Should we standardize and require presets to be functions, and drop Object support too?

Copy link
Member Author

@danez danez Jan 16, 2017

Choose a reason for hiding this comment

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

That would make it even simpler. And 3rd-party presets could still be bc down to 6.13 as functions are supported since then anyway.

What do you think? @hzoo, @DrewML, @xtuc

Copy link
Member

Choose a reason for hiding this comment

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

If we can simply the logic (this code is the worst and so many hacks) then ok 👍 just want to make sure its easy to change it. We can write a migration guide + even try a codemod if that's useful.

Copy link
Member

Choose a reason for hiding this comment

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

👍

Copy link
Member

Choose a reason for hiding this comment

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

👍 for keeping stuff as simple as possible.

@danez
Copy link
Member Author

danez commented Jan 16, 2017

Okay, I made all the changes.

With this changes we don't have a way currently to detect if the preset supports options or not. I tried Function.length but that wasn't working for functions with default params. Maybe after 7.0 we can add some option-schema like eslint has. That would solve this.

This case will now not throw a specific message like before but rather : Unsupported preset format: object. Expected preset to return a function.

{
   "preset": [{ option: true }],
}

@xtuc
Copy link
Member

xtuc commented Jan 17, 2017

Just an idea but I think that codeframes helps a lot new users.

The error would be like:

Error: Unsupported preset format: object. Expected preset to return a function
{
   "preset": [{ option: true }],
                ^^^^^^^^^^^^
}

Could also be applied to parse errors.

What do you think?

@danez
Copy link
Member Author

danez commented Jan 17, 2017

Yes, but could also be done post-7.

@hzoo
Copy link
Member

hzoo commented Jan 21, 2017

any reviews for this?

@hzoo
Copy link
Member

hzoo commented Jan 23, 2017

Only allow functions for presets

Is it possible to write a codemod for this for any easy presets? Otherwise just needs to be in the migration guide for users

@xtuc
Copy link
Member

xtuc commented Jan 24, 2017

👍 The migration guide. I have this as todo in the guide. I don't exactly know how to write it.

@hzoo
Copy link
Member

hzoo commented Jan 26, 2017

Maybe after 7.0 we can add some option-schema like eslint has.

Yeah we should probably do this otherwise we get typos issues.

@danez
Copy link
Member Author

danez commented Feb 20, 2017

What should we do here? Do we want to merge this? I can rebase if so

@hzoo
Copy link
Member

hzoo commented Feb 20, 2017

I don't anyone was opposed so yea!

@danez danez merged commit 87ca615 into babel:7.0 Feb 22, 2017
@danez danez deleted the remove-bc-from-presets branch February 22, 2017 13:58
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants