|
| 1 | +const chromeManifest = require('../react-devtools-extensions/chrome/manifest.json'); |
| 2 | +const firefoxManifest = require('../react-devtools-extensions/firefox/manifest.json'); |
| 3 | + |
| 4 | +const minChromeVersion = parseInt(chromeManifest.minimum_chrome_version, 10); |
| 5 | +const minFirefoxVersion = parseInt( |
| 6 | + firefoxManifest.applications.gecko.strict_min_version, |
| 7 | + 10, |
| 8 | +); |
| 9 | +validateVersion(minChromeVersion); |
| 10 | +validateVersion(minFirefoxVersion); |
| 11 | + |
| 12 | +function validateVersion(version) { |
| 13 | + if (version > 0 && version < 200) { |
| 14 | + return; |
| 15 | + } |
| 16 | + throw new Error('Suspicious browser version in manifest: ' + version); |
| 17 | +} |
| 18 | + |
1 | 19 | module.exports = api => {
|
2 | 20 | const isTest = api.env('test');
|
3 |
| - |
| 21 | + const targets = {}; |
| 22 | + if (isTest) { |
| 23 | + targets.node = 'current'; |
| 24 | + } else { |
| 25 | + targets.chrome = minChromeVersion.toString(); |
| 26 | + targets.firefox = minFirefoxVersion.toString(); |
| 27 | + // We won't support IE because that'll double profile import times. |
| 28 | + } |
4 | 29 | const plugins = [
|
5 | 30 | ['@babel/plugin-transform-flow-strip-types'],
|
6 | 31 | ['@babel/plugin-proposal-class-properties', {loose: false}],
|
7 |
| - |
8 |
| - // The plugins below fix compilation errors on Webpack 4. |
9 |
| - // See: https://github.com/webpack/webpack/issues/10227 |
10 |
| - // TODO: Remove once we're on Webpack 5. |
11 |
| - ['@babel/plugin-proposal-optional-chaining'], |
12 |
| - ['@babel/plugin-proposal-nullish-coalescing-operator'], |
13 | 32 | ];
|
14 | 33 | if (process.env.NODE_ENV !== 'production') {
|
15 | 34 | plugins.push(['@babel/plugin-transform-react-jsx-source']);
|
16 | 35 | }
|
17 |
| - |
18 | 36 | return {
|
19 | 37 | plugins,
|
20 | 38 | presets: [
|
21 |
| - [ |
22 |
| - '@babel/preset-env', |
23 |
| - { |
24 |
| - targets: isTest |
25 |
| - ? {node: 'current'} |
26 |
| - : 'last 2 Chrome versions, last 2 Firefox versions', |
27 |
| - }, |
28 |
| - ], |
| 39 | + ['@babel/preset-env', {targets}], |
29 | 40 | '@babel/preset-react',
|
30 | 41 | '@babel/preset-flow',
|
31 | 42 | ],
|
|
0 commit comments