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
[WIP] Babel Autoinstall #1772
[WIP] Babel Autoinstall #1772
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can probably move some babel dependencies to devDeps, like the react transform. As now we can lazyload them (install when needed).
The security issues I had with this are pretty much the same as regular autoinstall, I just figured code-transforming plugins could potentially cause more harm than a regular dependency.
And move the autoinstall to just before the return statement, as than it will not install filtered out plugins and will install the react ones if necessary.
Would also be cool if this would support adding the babel-polyfill if needed, but that might be a seperate PR.
Move to parcel/src/transforms/babel.js Lines 58 to 60 in 871ffc7
|
Duplicate install bug? That shouldn't be happening, every install gets sent to the master process. Ending up in that one queue. Perhaps this queue doesn't prevent installing the same module? Perhaps you could keep a seperate list like this: let waiting = {
folder: [...modules],
anotherFolder: [...modules]
}
function checkAlreadyInQueue(module, folder) {
if (folder.includes(module)) {
return true;
}
if (folder !== rootDir) {
return checkAlreadyInQueue(module, path.dirname(folder));
}
}
addToQueue(modules.filter(module => !checkAlreadyInQueue(module, folder)));
// Should probably also have some logic that when a module install is called in a folder above one in the queue the queued module gets moved to the most upperlevel folder And you should probably filter out any non node module babel plugins and presets, as you can use relative babel plugins |
Included as part of the babel 7 upgrade: #1955 |
How do you flag this off? |
Probably quicker answer in the linked PR. |
Based on this twitter thread and point #3 of my comment on the auto install part 2 RFC
The idea is to automatically install any missing babel preset/plugins by
localrequire
ing them.localrequire
will automatically handle resolving the modules and installing anything that's missing, so adding this feature is relatively trivial.I didn't have too much time to finish everything so I'm opening this up as a WIP PR so we can discuss in the meantime.
@DeMoorJasper You mentioned in your tweet that you had some concerns about security... Just wondering what you meant by that, because this should pretty much come with the same exact security side problems as the normal auto install we have now (which we try to improve btw, but that's a separate issue). Is there anything about Babel plugins/presets in particular that could be a cause for concern?
Progress