mirror of https://github.com/status-im/metro.git
Do not use spread operator in require.js implementation
Reviewed By: jeanlauliac Differential Revision: D8074917 fbshipit-source-id: e7c4dca7955f7aeda8b59d2039e857f79168410b
This commit is contained in:
parent
1b15c47c93
commit
adce40d38d
|
@ -18,17 +18,13 @@ const fs = require('fs');
|
||||||
|
|
||||||
const {transformSync} = require('@babel/core');
|
const {transformSync} = require('@babel/core');
|
||||||
|
|
||||||
// from: metro/packages/metro-babel-register/babel-register.js
|
// Include the external-helpers plugin to be able to detect if they're
|
||||||
|
// needed when transforming the requirejs implementation.
|
||||||
const PLUGINS = [
|
const PLUGINS = ['@babel/plugin-external-helpers'];
|
||||||
'@babel/plugin-transform-flow-strip-types',
|
|
||||||
'@babel/plugin-proposal-object-rest-spread',
|
|
||||||
'@babel/plugin-proposal-class-properties',
|
|
||||||
];
|
|
||||||
|
|
||||||
function createBabelConfig() {
|
function createBabelConfig() {
|
||||||
return {
|
return {
|
||||||
presets: [],
|
presets: [require.resolve('babel-preset-react-native')],
|
||||||
plugins: PLUGINS.map(require),
|
plugins: PLUGINS.map(require),
|
||||||
retainLines: true,
|
retainLines: true,
|
||||||
sourceMaps: 'inline',
|
sourceMaps: 'inline',
|
||||||
|
@ -56,6 +52,12 @@ describe('require', () => {
|
||||||
moduleSystem = {};
|
moduleSystem = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('does not need any babel helper logic', () => {
|
||||||
|
// Super-simple check to validate that no babel helpers are used.
|
||||||
|
// This check will need to be updated if https://fburl.com/6z0y2kf8 changes.
|
||||||
|
expect(moduleSystemCode.includes('babelHelpers')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
it('works with plain bundles', () => {
|
it('works with plain bundles', () => {
|
||||||
createModuleSystem(moduleSystem, false);
|
createModuleSystem(moduleSystem, false);
|
||||||
expect(moduleSystem.require).not.toBeUndefined();
|
expect(moduleSystem.require).not.toBeUndefined();
|
||||||
|
|
|
@ -326,7 +326,7 @@ if (__DEV__) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
parents.push(...inverseDependencies[notAccepted[i]]);
|
parents.push.apply(parents, inverseDependencies[notAccepted[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return parents.length == 0;
|
return parents.length == 0;
|
||||||
|
|
Loading…
Reference in New Issue