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 the filename option, as exposed to the plugins, consistently relative to the working directory #7956

Merged
merged 1 commit into from
May 22, 2018

Conversation

loganfsmyth
Copy link
Member

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

Currently the opts.filename value exposed to plugins is just whatever the user passed. While it could be relative to the working directory, if Babel was passed an absolute URL, it'll be absolute.

This PR explicitly ensures the filename is a relative path based on the working directory. This also exposes an officially endorsed API for reading the working directory path.

@loganfsmyth loganfsmyth added PR: Breaking Change 💥 A type of pull request used for our changelog categories for next major release PR: Bug Fix 🐛 A type of pull request used for our changelog categories labels May 17, 2018
@babel-bot
Copy link
Collaborator

babel-bot commented May 17, 2018

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

@loganfsmyth loganfsmyth merged commit 69cca41 into babel:master May 22, 2018
@loganfsmyth loganfsmyth deleted the consistent-filename branch May 22, 2018 00:11
@rtsao
Copy link
Contributor

rtsao commented May 25, 2018

I think it's worth noting that babel-loader seems to always pass an absolute path to thefilename option (I think this.resourcePath in the webpack loader API yields an absolute path).

This change may cause specialized plugins that only run in the context of babel-loader to break if they had assumptions about this. Of course, this wasn't part of the official public API, but it was an invariant for this use case, so that assumption is not entirely unreasonable.

@loganfsmyth
Copy link
Member Author

I went back and forth about whether it made sense to default to relative or absolute and I think both are entirely possible.

I ended up going with relative, but in all honesty I'd be happy to change it if people feel it'd be easier to manage. I just want it to be consistent.

@KevinGrandon
Copy link

Consistency is awesome, so thanks for working on this. I think changing it to absolute would fix our use-case, as well as other folks who use babel-loader. It would be awesome if you're up for changing it to that. Happy to test out a beta/alpha version if it would help.

@loganfsmyth
Copy link
Member Author

Alright, I've made a PR to make it absolute instead: #8044

@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 4, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 4, 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 PR: Bug Fix 🐛 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

6 participants