Remove .babelrc to simplify React Native support

React Native's module bundler (aka packager) has its default Babel
preset - react-native/babel-preset - which it uses in the absence of a
custom .babelrc. Unfortunately, the default may be tripped by the
presence of a .babelrc in dependencies. Additionally, if the default
does not get tripped, the npm install of lib-jitsi-meet as a dependency
may fall into a recursion in which Babel attempts to transpile
react-native/babel-preset. To reduce the risks of stumbling upon such
problems, move Babel's configuration inside the Webpack configuration
file.
This commit is contained in:
Lyubomir Marinov 2016-10-11 09:08:21 -05:00
parent d55e0f70d9
commit 1edebf83ae
3 changed files with 32 additions and 36 deletions

View File

@ -1,8 +0,0 @@
{
"plugins": [
"transform-object-rest-spread"
],
"presets": [
"es2015"
]
}

View File

@ -38,10 +38,8 @@
"devDependencies": { "devDependencies": {
"babel-core": "*", "babel-core": "*",
"babel-loader": "*", "babel-loader": "*",
"babel-plugin-transform-object-rest-spread": "*",
"babel-polyfill": "*", "babel-polyfill": "*",
"babel-preset-es2015": "6.14.0", "babel-preset-es2015": "6.14.0",
"babel-register": "*",
"clean-css": "*", "clean-css": "*",
"css-loader": "*", "css-loader": "*",
"eslint": "*", "eslint": "*",

View File

@ -1,16 +1,18 @@
/* global __dirname */ /* global __dirname */
import process from 'process'; require('babel-polyfill'); // Define Object.assign() from ES6 in ES5.
const aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/'; var process = require('process');
const minimize
var aui_css = __dirname + '/node_modules/@atlassian/aui/dist/aui/css/';
var minimize
= process.argv.indexOf('-p') != -1 = process.argv.indexOf('-p') != -1
|| process.argv.indexOf('--optimize-minimize') != -1; || process.argv.indexOf('--optimize-minimize') != -1;
const strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/; var strophe = /\/node_modules\/strophe(js-plugins)?\/.*\.js$/;
// The base Webpack configuration to bundle the JavaScript artifacts of // The base Webpack configuration to bundle the JavaScript artifacts of
// jitsi-meet such as app.bundle.js and external_api.js. // jitsi-meet such as app.bundle.js and external_api.js.
const config = { var config = {
devtool: 'source-map', devtool: 'source-map',
module: { module: {
loaders: [{ loaders: [{
@ -18,6 +20,11 @@ const config = {
exclude: __dirname + '/node_modules/', exclude: __dirname + '/node_modules/',
loader: 'babel', loader: 'babel',
query: {
presets: [
'es2015'
]
},
test: /\.js$/ test: /\.js$/
},{ },{
// Expose jquery as the globals $ and jQuery because it is expected // Expose jquery as the globals $ and jQuery because it is expected
@ -91,27 +98,26 @@ const config = {
} }
}; };
export default [{ module.exports = [
// The Webpack configuration to bundle app.bundle.js (aka APP).
...config, // The Webpack configuration to bundle app.bundle.js (aka APP).
Object.assign({}, config, {
entry: { entry: {
'app.bundle': './app.js' 'app.bundle': './app.js'
}, },
output: { output: Object.assign({}, config.output, {
...config.output,
library: 'APP' library: 'APP'
} })
}, { }),
// The Webpack configuration to bundle external_api.js (aka // The Webpack configuration to bundle external_api.js (aka
// JitsiMeetExternalAPI). // JitsiMeetExternalAPI).
Object.assign({}, config, {
...config,
entry: { entry: {
'external_api': './modules/API/external/external_api.js' 'external_api': './modules/API/external/external_api.js'
}, },
output: { output: Object.assign({}, config.output, {
...config.output,
library: 'JitsiMeetExternalAPI' library: 'JitsiMeetExternalAPI'
} })
}]; })
];