Upgrade to Babel 7

This commit is contained in:
Dan Stillman 2019-03-21 20:05:07 -04:00
parent 6411342a0f
commit c52589f96b
4 changed files with 608 additions and 528 deletions

View file

@ -1,7 +1,9 @@
{
"compact": false,
"retainLines": true,
"presets": [],
"presets": [
"@babel/preset-react"
],
"ignore": [
"chrome/content/zotero/include.js",
"chrome/content/zotero/xpcom/citeproc.js",
@ -10,10 +12,8 @@
"test/resource/*.js"
],
"plugins": [
"syntax-jsx",
"transform-react-jsx",
"transform-react-display-name",
"transform-class-properties",
"@babel/plugin-proposal-class-properties",
"@babel/plugin-proposal-object-rest-spread",
[
"transform-es2015-modules-commonjs",
{

1098
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -23,18 +23,13 @@
"react-intl": "^2.7.2"
},
"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-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-preset-react": "^6.16.0",
"browserify": "^14.5.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",

View file

@ -3,7 +3,7 @@
const fs = require('fs-extra');
const path = require('path');
const babel = require('babel-core');
const babel = require('@babel/core');
const multimatch = require('multimatch');
const options = JSON.parse(fs.readFileSync('.babelrc'));
const cluster = require('cluster');
@ -12,6 +12,9 @@ const cluster = require('cluster');
async function babelWorker(ev) {
const t1 = Date.now();
const sourcefile = ev.file;
const localOptions = {
filename: sourcefile
};
const outfile = path.join('build', sourcefile.replace('.jsx', '.js'));
const postError = (error) => {
process.send({
@ -40,7 +43,13 @@ async function babelWorker(ev) {
isSkipped = true;
} else {
try {
transformed = babel.transform(contents, options).code;
({ code: transformed } = await babel.transformAsync(
contents,
Object.assign(
localOptions,
options
)
));
} catch (error) { return postError(`Babel error: ${error}`);}
}