Skip to content

Use dagMap to improve plugin ordering - #5814

Merged
hzoo merged 9 commits into
babel:plugin-orderingfrom
sarupbanskota:enhancement/improve_plugin_ordering
Jun 6, 2017
Merged

hzoo merged 9 commits into
babel:plugin-orderingfrom
sarupbanskota:enhancement/improve_plugin_ordering

Conversation

@sarupbanskota

@sarupbanskota sarupbanskota commented Jun 2, 2017 •

Copy link
Copy Markdown
Contributor

Works towards #5623, Improving #5735

(Thanks to Nathan for providing me much needed guidance!)

Q A
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? yes
Deprecations?
Spec Compliancy?
Tests Added/Pass?
Fixed Tickets Towards fixing #5623, Improves #5735
License MIT
Doc PR
Dependency Changes yes

@mention-bot

Copy link
Copy Markdown

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

@xtuc xtuc added the PR: New Feature 🚀 A type of pull request used for our changelog categories label Jun 2, 2017
@xtuc

xtuc commented Jun 2, 2017

Copy link
Copy Markdown
Member

At first glance it looks awesome, thanks for this PR 👍

Going to look in more detail later on.

Comment thread package.json Outdated
"instrument": false
},
"dependencies": {
"dag-map": "^2.0.2"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This would need to go into babel-core since it's being used there. The top level package.json doesn't apply to any specific package and used for devDeps

@hzoo

hzoo commented Jun 2, 2017

Copy link
Copy Markdown
Member

You can also just target my PR instead of targeting 7.0

@sarupbanskota

Copy link
Copy Markdown
Contributor Author

Sure - I'll be back at this later tonight! Need to look at why the tests broke too - strange

@hzoo

hzoo commented Jun 2, 2017

Copy link
Copy Markdown
Member

@sarupbanskota
sarupbanskota changed the base branch from 7.0 to plugin-ordering June 3, 2017 01:53
@sarupbanskota

Copy link
Copy Markdown
Contributor Author

@hzoo I think you can pull this in, sounds like ncantelmi will have a PR to fix broken tests on this PR, and better dependency handling

@hzoo

hzoo commented Jun 3, 2017

Copy link
Copy Markdown
Member

Can you look at my branch again? I removed the error check https://github.com/babel/babel/compare/plugin-ordering...plugin-ordering-2?expand=1 and the dag-map dependency is in the incorrect place

@sarupbanskota sarupbanskota changed the title [WIP] Enhancement/improve plugin ordering Use dagMap to improve plugin ordering Jun 3, 2017
@nathanhammond

Copy link
Copy Markdown

I removed the error check -@hzoo

Removing that error check hides cyclic dependencies:

1 = { capabilities: [A, B] }
2 = { capabilities: [A], dependencies: [B, C] }
3 = { capabilities: [B], dependencies: [A] }
4 = { capabilities: [C], dependencies: [A] }

A: 2
B: 3
C: 4

graph.add(1)
graph.add(2, [3,4])
graph.add(3, [2])
graph.add(4, [2])

This is otherwise resolveable, but we have lost the metadata to properly sort 1. Getting a valid result here is not possible to guarantee for all scenarios even with "stability" guarantees in the topological sort because math (trivial examples like this look solvable with stability, but I assure you that real-world graphs are impossible).

In other words, you can't have multiple plugins provide the same capability. Given that, retaining the error is correct.

return accumulator;
}, {});

plugins = sortPlugins(Object.values(uniquePlugins));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Failing in less than Node 6 because of Object.values.

@hzoo
hzoo requested a review from loganfsmyth June 4, 2017 03:40
@codecov

codecov Bot commented Jun 4, 2017 •

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (plugin-ordering@667a714). Click here to learn what that means.
The diff coverage is 92.85%.

Impacted file tree graph

@@                Coverage Diff                 @@
##             plugin-ordering    #5814   +/-   ##
==================================================
  Coverage                   ?   84.58%           
==================================================
  Files                      ?      282           
  Lines                      ?     9892           
  Branches                   ?     2767           
==================================================
  Hits                       ?     8367           
  Misses                     ?     1007           
  Partials                   ?      518
Impacted Files Coverage Δ
...bel-plugin-transform-class-properties/src/index.js 94.59% <ø> (ø)
packages/babel-core/src/config/index.js 50% <ø> (ø)
packages/babel-core/src/config/option-manager.js 78.12% <92%> (ø)
...ckages/babel-core/src/transformation/file/index.js 87.2% <95%> (ø)

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 667a714...42e2721. Read the comment docs.

node_modules are required to exists so that flow can inference the types
@hzoo
hzoo merged commit bf6fdbb into babel:plugin-ordering Jun 6, 2017
@sarupbanskota
sarupbanskota deleted the enhancement/improve_plugin_ordering branch June 8, 2017 19:13
@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: New Feature 🚀 A type of pull request used for our changelog categories

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants