<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="?attr/actionBarSize"
android:clipToPadding="false"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/itemview"/>
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#1111"
app:title="Hello world"/>
</FrameLayout>
通过使用来自Facebook的This experimental syntax requires enabling the parser plugin: 'exportDefaultFrom'
之类的迁移工具,尝试将整个应用程序从响应v15.6
移至v16.2
时出现上述错误。
答案 0 :(得分:1)
将@ babel / plugin-proposal-export-default-from(https://git.io/vb4yH)添加到Babel配置的“插件”部分,以启用转换。
答案 1 :(得分:0)
我解决了这个问题。
const parser = require('./src/parser');
const jscodeshift = require('jscodeshift').withParser(parser);
./ src / parser:
'use strict';
const babylon = require('babylon');
// These are the options that were the default of the Babel5 parse function
// see https://github.com/babel/babel/blob/5.x/packages/babel/src/api/node.js#L81
const options = {
sourceType: 'module',
allowHashBang: true,
ecmaVersion: Infinity,
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true,
plugins: [
'estree',
'jsx',
'asyncGenerators',
'classProperties',
'doExpressions',
'exportExtensions',
'functionBind',
'functionSent',
'objectRestSpread',
'dynamicImport',
'nullishCoalescingOperator',
'optionalChaining',
'exportDefaultFrom'
],
};
/**
* Wrapper to set default options
*/
exports.parse = function parse (code) {
return babylon.parse(code, options);
};
请在插件中添加“ exportDefaultFrom”。