Merge env-standalone to babel-standalone (#10821)
* feat: add babel-preset-env to babel-standalone * chore: copy preset-env-standalone test * polish: tune warning message when babel-preset-env-standalone is loaded
This commit is contained in:
committed by
Nicolò Ribaudo
parent
a1310333f7
commit
405c1aaad8
@@ -110,6 +110,61 @@
|
||||
).toThrow(/Invalid plugin specified in Babel options: "lolfail"/);
|
||||
});
|
||||
|
||||
describe("env preset", () => {
|
||||
it("works w/o targets", () => {
|
||||
const output = Babel.transform("const a = 1;", {
|
||||
sourceType: "script",
|
||||
presets: ["env"],
|
||||
}).code;
|
||||
expect(output).toBe("var a = 1;");
|
||||
});
|
||||
|
||||
it("doesn't transpile `const` with chrome 60", () => {
|
||||
const output = Babel.transform("const a = 1;", {
|
||||
sourceType: "script",
|
||||
presets: [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
targets: {
|
||||
chrome: 60,
|
||||
},
|
||||
},
|
||||
],
|
||||
],
|
||||
}).code;
|
||||
expect(output).toBe("const a = 1;");
|
||||
});
|
||||
|
||||
it("transpiles `const` with chrome 60 and preset-es2015", () => {
|
||||
const output = Babel.transform("const a = 1;", {
|
||||
sourceType: "script",
|
||||
presets: [
|
||||
[
|
||||
"env",
|
||||
{
|
||||
targets: {
|
||||
chrome: 60,
|
||||
},
|
||||
},
|
||||
],
|
||||
"es2015",
|
||||
],
|
||||
}).code;
|
||||
expect(output).toBe("var a = 1;");
|
||||
});
|
||||
|
||||
it("uses transform-new-targets plugin", () => {
|
||||
const output = Babel.transform("function Foo() {new.target}", {
|
||||
sourceType: "script",
|
||||
presets: ["env"],
|
||||
}).code;
|
||||
expect(output).toBe(
|
||||
"function Foo() {\n this instanceof Foo ? this.constructor : void 0;\n}",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("custom plugins and presets", () => {
|
||||
const lolizer = () => ({
|
||||
visitor: {
|
||||
|
||||
Reference in New Issue
Block a user