Upgrade to Babel 7
This commit is contained in:
parent
6411342a0f
commit
c52589f96b
4 changed files with 608 additions and 528 deletions
10
.babelrc
10
.babelrc
|
@ -1,7 +1,9 @@
|
||||||
{
|
{
|
||||||
"compact": false,
|
"compact": false,
|
||||||
"retainLines": true,
|
"retainLines": true,
|
||||||
"presets": [],
|
"presets": [
|
||||||
|
"@babel/preset-react"
|
||||||
|
],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"chrome/content/zotero/include.js",
|
"chrome/content/zotero/include.js",
|
||||||
"chrome/content/zotero/xpcom/citeproc.js",
|
"chrome/content/zotero/xpcom/citeproc.js",
|
||||||
|
@ -10,10 +12,8 @@
|
||||||
"test/resource/*.js"
|
"test/resource/*.js"
|
||||||
],
|
],
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"syntax-jsx",
|
"@babel/plugin-proposal-class-properties",
|
||||||
"transform-react-jsx",
|
"@babel/plugin-proposal-object-rest-spread",
|
||||||
"transform-react-display-name",
|
|
||||||
"transform-class-properties",
|
|
||||||
[
|
[
|
||||||
"transform-es2015-modules-commonjs",
|
"transform-es2015-modules-commonjs",
|
||||||
{
|
{
|
||||||
|
|
1098
package-lock.json
generated
1098
package-lock.json
generated
File diff suppressed because it is too large
Load diff
15
package.json
15
package.json
|
@ -23,18 +23,13 @@
|
||||||
"react-intl": "^2.7.2"
|
"react-intl": "^2.7.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.26.3",
|
"@babel/cli": "^7.2.3",
|
||||||
|
"@babel/core": "^7.4.0",
|
||||||
|
"@babel/plugin-proposal-class-properties": "^7.4.0",
|
||||||
|
"@babel/plugin-proposal-object-rest-spread": "^7.4.0",
|
||||||
|
"@babel/preset-react": "^7.0.0",
|
||||||
"babel-eslint": "^10.0.1",
|
"babel-eslint": "^10.0.1",
|
||||||
"babel-plugin-syntax-async-generators": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-decorators": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-do-expressions": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-export-extensions": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-flow": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-jsx": "^6.13.0",
|
|
||||||
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
|
|
||||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
|
||||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
||||||
"babel-preset-react": "^6.16.0",
|
|
||||||
"browserify": "^14.5.0",
|
"browserify": "^14.5.0",
|
||||||
"chai": "^4.1.2",
|
"chai": "^4.1.2",
|
||||||
"chai-as-promised": "^7.1.1",
|
"chai-as-promised": "^7.1.1",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
const babel = require('babel-core');
|
const babel = require('@babel/core');
|
||||||
const multimatch = require('multimatch');
|
const multimatch = require('multimatch');
|
||||||
const options = JSON.parse(fs.readFileSync('.babelrc'));
|
const options = JSON.parse(fs.readFileSync('.babelrc'));
|
||||||
const cluster = require('cluster');
|
const cluster = require('cluster');
|
||||||
|
@ -12,6 +12,9 @@ const cluster = require('cluster');
|
||||||
async function babelWorker(ev) {
|
async function babelWorker(ev) {
|
||||||
const t1 = Date.now();
|
const t1 = Date.now();
|
||||||
const sourcefile = ev.file;
|
const sourcefile = ev.file;
|
||||||
|
const localOptions = {
|
||||||
|
filename: sourcefile
|
||||||
|
};
|
||||||
const outfile = path.join('build', sourcefile.replace('.jsx', '.js'));
|
const outfile = path.join('build', sourcefile.replace('.jsx', '.js'));
|
||||||
const postError = (error) => {
|
const postError = (error) => {
|
||||||
process.send({
|
process.send({
|
||||||
|
@ -40,7 +43,13 @@ async function babelWorker(ev) {
|
||||||
isSkipped = true;
|
isSkipped = true;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
transformed = babel.transform(contents, options).code;
|
({ code: transformed } = await babel.transformAsync(
|
||||||
|
contents,
|
||||||
|
Object.assign(
|
||||||
|
localOptions,
|
||||||
|
options
|
||||||
|
)
|
||||||
|
));
|
||||||
} catch (error) { return postError(`Babel error: ${error}`);}
|
} catch (error) { return postError(`Babel error: ${error}`);}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue