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

Make .insert{Before,After} work by default when the parent is an eport declaration #7040

Merged

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues?
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature? Yes
Tests Added + Pass? Yes
Documentation PR
Any Dependency Changes?
License MIT

This PR makes declarationPath.insertBefore() and declarationPath.insertAfter() work by default even if declarationPath.parentPath.isExportDeclaration().
Babel already handles it in a similar way when path.parentPath.isLabelledStatement(): https://astexplorer.net/#/gist/192e79a63708ad6195496dffe34b6fd7/35538c7478fe1340c9e8bdb2e6c40f24f5adc40b
As you can see by the diff, we already had to handle insertion before/after exported declarations in different places. Less special cases to think about -> less probability of forgetting about them.

This PR doesn't introduce breaking changes, because it only makes cases that previously threw do what it is actually expected.

@nicolo-ribaudo nicolo-ribaudo added the PR: Internal 🏠 A type of pull request used for our changelog categories label Dec 17, 2017
@babel-bot
Copy link
Collaborator

babel-bot commented Dec 17, 2017

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/6215/

Copy link
Member

@existentialism existentialism left a comment

Choose a reason for hiding this comment

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

👍

@nicolo-ribaudo nicolo-ribaudo merged commit 68476b6 into babel:master Dec 18, 2017
@nicolo-ribaudo nicolo-ribaudo deleted the export-insert-before-after branch December 18, 2017 23:05
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Dec 27, 2017
nicolo-ribaudo added a commit that referenced this pull request Dec 28, 2017
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 5, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 5, 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: Internal 🏠 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants