Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: pass browserslistEnv to resolveTargets
- Loading branch information
Showing
7 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
packages/babel-helper-compilation-targets/test/browserslist-extends/.browserslistrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[custom] | ||
extends @babel/browserslist-config | ||
chrome >= 71 |
44 changes: 44 additions & 0 deletions
44
...s/babel-helper-compilation-targets/test/browserslist-extends/browserslist-extends.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { join, dirname } from "path"; | ||
import { promises } from "fs"; | ||
import rimraf from "rimraf"; | ||
import { fileURLToPath } from "url"; | ||
import getTargets from "../.."; | ||
|
||
const currentDir = dirname(fileURLToPath(import.meta.url)); | ||
let mocked = []; | ||
|
||
async function mock(name, exports) { | ||
const dir = join( | ||
fileURLToPath(import.meta.url), | ||
"..", | ||
"..", | ||
"..", | ||
"node_modules", | ||
name, | ||
); | ||
mocked.push(dir); | ||
await promises.mkdir(dir, { recursive: true }); | ||
const content = "module.exports = " + JSON.stringify(exports); | ||
await promises.writeFile(join(dir, "index.js"), content); | ||
} | ||
|
||
afterEach(() => { | ||
mocked.map(dir => rimraf.sync(dir)); | ||
mocked = []; | ||
}); | ||
|
||
it("pass env to configs used with extends", async () => { | ||
await mock("@babel/browserslist-config", { | ||
custom: ["firefox >= 75"], | ||
defaults: ["chrome >= 5"], | ||
}); | ||
const actual = getTargets( | ||
{}, | ||
{ | ||
configPath: currentDir, | ||
browserslistEnv: "custom", | ||
}, | ||
); | ||
|
||
expect(actual).toEqual({ chrome: "71.0.0", firefox: "75.0.0" }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters