Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass "targets" to plugins and presets
- Loading branch information
1 parent
39a0dc9
commit afe0304
Showing
11 changed files
with
95 additions
and
12 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
1 change: 1 addition & 0 deletions
1
packages/babel-core/test/fixtures/plugins/targets/plugin/input.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 @@ | ||
; |
4 changes: 4 additions & 0 deletions
4
packages/babel-core/test/fixtures/plugins/targets/plugin/options.json
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,4 @@ | ||
{ | ||
"targets": ["firefox 64", "node 8"], | ||
"plugins": ["./plugin"] | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-core/test/fixtures/plugins/targets/plugin/output.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,2 @@ | ||
; | ||
"plugin: {\"firefox\":\"64.0.0\",\"node\":\"8.17.0\"}" |
14 changes: 14 additions & 0 deletions
14
packages/babel-core/test/fixtures/plugins/targets/plugin/plugin.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,14 @@ | ||
module.exports = function (api) { | ||
const { types: t } = api; | ||
|
||
const targets = api.targets(); | ||
|
||
return { | ||
visitor: { | ||
Program(path) { | ||
const output = t.stringLiteral(`plugin: ${JSON.stringify(targets)}`); | ||
path.pushContainer("body", output); | ||
}, | ||
}, | ||
}; | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/babel-core/test/fixtures/plugins/targets/preset/input.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 @@ | ||
; |
4 changes: 4 additions & 0 deletions
4
packages/babel-core/test/fixtures/plugins/targets/preset/options.json
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,4 @@ | ||
{ | ||
"targets": ["firefox 64", "node 8"], | ||
"presets": ["./preset"] | ||
} |
2 changes: 2 additions & 0 deletions
2
packages/babel-core/test/fixtures/plugins/targets/preset/output.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,2 @@ | ||
; | ||
"preset: {\"firefox\":\"64.0.0\",\"node\":\"8.17.0\"}" |
18 changes: 18 additions & 0 deletions
18
packages/babel-core/test/fixtures/plugins/targets/preset/preset.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,18 @@ | ||
module.exports = function (api) { | ||
const targets = api.targets(); | ||
|
||
return { | ||
plugins: [plugin], | ||
}; | ||
|
||
function plugin({ types: t }) { | ||
return { | ||
visitor: { | ||
Program(path) { | ||
const output = t.stringLiteral(`preset: ${JSON.stringify(targets)}`); | ||
path.pushContainer("body", output); | ||
}, | ||
}, | ||
}; | ||
} | ||
}; |