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
Extract targets parser and compat data from preset-env #10899
Extract targets parser and compat data from preset-env #10899
Conversation
I swear at this point we should just append a random UUID to every filename except |
Did you see #10850? 😛 |
Hah, nope! Had no idea that was a thing Node allowed! |
b842a7c
to
fad046a
Compare
@@ -7,7 +7,7 @@ const flattenDeep = require("lodash/flattenDeep"); | |||
const isEqual = require("lodash/isEqual"); | |||
const mapValues = require("lodash/mapValues"); | |||
const pickBy = require("lodash/pickBy"); | |||
const unreleasedLabels = require("../data/unreleased-labels"); | |||
const { unreleasedLabels } = require("../../babel-helper-compilation-targets"); |
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.
Can we just require @babel/helper-compilation-targets
?
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.
Good catch; I'll update it. Note that this file isn't published to npm so it isn't a problem, but using @babel/helper-compilation-targets
is more clear.
"version": "0.0.0", | ||
"author": "The Babel Team (https://babeljs.io/team)", | ||
"license": "MIT", | ||
"description": "", |
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.
Maybe "Engine compat data used in @babel/preset-env"?
Any reason to not also move In fact, erring on the side of less packages to maintain, can we just have one package that exports isRequired(
name: string,
targetEnvironments: Targets,
options: {
compatData?: { [key in string]: Targets }
// ...
}
) { ... } This seems like a key use-case (as both vue/ember use it), and would allow anyone to pass their own mappings in, if they wanted. |
Maybe I forgot it, I'll check.
I don't think that this should be a goal? The maintenance cost of 2 packages in a monorepo is exactly the same as 1 package. I created two separate packages because, if we are going to disable sub-package imports in Babel 8.0.0, |
import type { Targets } from "./types"; | ||
import { isUnreleasedVersion, semverify } from "./utils"; | ||
|
||
export function isItemRequired(supportedEnvironments: Targets, item: Targets) { |
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.
Oh, I already extracted it. I called it isItemRequired
because it's not just used for plugins, but also for polyfills. Maybe I should choose another name?
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.
Ah missed that. I think the name is fine.
457871b
to
ef4edea
Compare
Whops I accidentally deleted my comment. I wrote that I agree that the proposed Also, do you think that |
I'm not sure I agree with that... perhaps mechanically, but I think we should always consider the balance between a package's public API vs. adding more packages.
I think we can go with just plugins data for now. |
06652c9
to
58d6106
Compare
@existentialism I ended up not exporting |
58d6106
to
4fd4151
Compare
This is PR only moves code around, to expose as public packages internal API which are already used by some Babel integrations:
Otherwise, they will have problems in Babel 8 with Disable submodule exports #10850.
I created two new packages:
@babel/compat-data
and@babel/helper-compilation-targets
.I wasn't sure about where to put the info about overlapping plugins which will be useful for
preset-modules
(I put it in@babel/compat-data
) and about the mappings from transform plugins to syntax plugins (I left it in@babel/preset-env
).