mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
47 lines
1.3 KiB
JavaScript
47 lines
1.3 KiB
JavaScript
const chromeManifest = require('../react-devtools-extensions/chrome/manifest.json');
|
|
const firefoxManifest = require('../react-devtools-extensions/firefox/manifest.json');
|
|
|
|
const minChromeVersion = parseInt(chromeManifest.minimum_chrome_version, 10);
|
|
const minFirefoxVersion = parseInt(
|
|
firefoxManifest.applications.gecko.strict_min_version,
|
|
10,
|
|
);
|
|
validateVersion(minChromeVersion);
|
|
validateVersion(minFirefoxVersion);
|
|
|
|
function validateVersion(version) {
|
|
if (version > 0 && version < 200) {
|
|
return;
|
|
}
|
|
throw new Error('Suspicious browser version in manifest: ' + version);
|
|
}
|
|
|
|
module.exports = api => {
|
|
const isTest = api.env('test');
|
|
const targets = {};
|
|
if (isTest) {
|
|
targets.node = 'current';
|
|
} else {
|
|
targets.chrome = minChromeVersion.toString();
|
|
targets.firefox = minFirefoxVersion.toString();
|
|
|
|
// This targets RN/Hermes.
|
|
targets.ie = '11';
|
|
}
|
|
const plugins = [
|
|
['@babel/plugin-transform-flow-strip-types'],
|
|
['@babel/plugin-proposal-class-properties', {loose: false}],
|
|
];
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
plugins.push(['@babel/plugin-transform-react-jsx-source']);
|
|
}
|
|
return {
|
|
plugins,
|
|
presets: [
|
|
['@babel/preset-env', {targets}],
|
|
'@babel/preset-react',
|
|
'@babel/preset-flow',
|
|
],
|
|
};
|
|
};
|