babel preset-env with electron&应对

时间:2017-05-24 14:33:51

标签: babeljs

创造电子&反应应用我正在使用反应和node7呈现如下(其工作)

  "babel": {
    "sourceMaps": "inline",
    "presets": [
      "react",
      "node7"
    ]
  },

但是我想提供一些更具未来性的证据,所以我尝试了预设-env

  "babel": {
    "sourceMaps": "inline",
    "presets": [
      [
        "env",
        {
          "targets": {
            "electron": "1.6.7"
          },
          "debug": true,
          "useBuiltIns": true
        }
      ]
    ]
  },

然而,这对我不起作用。似乎没有找到es7对象传播,并且有反应JSX的问题。我错过了什么简单的事情?

babel-preset-env: `DEBUG` option

Using targets:
{
  "electron": "1.6.7"
}

Modules transform: commonjs

Using plugins:
  syntax-trailing-function-commas {"electron":"1.6.7"}

Using polyfills:
  es7.string.pad-start {"electron":"1.6.7"}
  es7.string.pad-end {"electron":"1.6.7"}
  web.timers {"electron":"1.6.7"}
  web.immediate {"electron":"1.6.7"}
  web.dom.iterable {"electron":"1.6.7"}
src\dash\actions.js -> dist\dash\actions.js
src\dash\actionTypes.js -> dist\dash\actionTypes.js
SyntaxError: src/dash/dash.js: Unexpected token (29:18)
  27 |     let stats = remote.getGlobal('DASH').stats
  28 |     //stats.jobStats = (stats.jobStats == "") ? "0" : stats.jobStats  -- we only needed this if the folder was m
issing
> 29 |     let state = { ...STORE.getState().ServerStats }
     |                   ^
  30 |     let original = { ...state }
  31 |     state.WatsonInstalled = (state.WatsonInstalled != stats.watsonInstalled) ? stats.watsonInstalled : state.Wat
sonInstalled
  32 |     state.WatsonRunning = (state.WatsonRunning != stats.watsonRunning) ? stats.watsonRunning : state.WatsonRunni
ng
SyntaxError: src/dash/reducers.js: Unexpected token (18:25)
  16 |     switch (action.type) {
  17 |         case A.SetUpdating:
> 18 |             newState = { ...state, isUpdating: action.payload }
     |                          ^
  19 |             return newState
  20 |         case A.SetChanger:
  21 |             newState = { ...state, fieldName: action.payload }
SyntaxError: src/jsx/Configuration.jsx: Unexpected token (19:4)
  17 |     resetForm,
  18 |     isUpdating,
> 19 |     ...props }) => {
     |     ^
  20 |     COMPONENTS["Configuration"] = props // Register this component in the Dash Components list (so we can get th
e change() function)
  21 |     return (
  22 |         <Form horizontal onSubmit={(e) => { alert('foobar'); handleSubmit(doSubmit) }}>
SyntaxError: src/jsx/Controls.jsx: Unexpected token (7:8)
   5 | const Control = ({ WatsonInstalled, WatsonRunning, FMERunning, buttonAction }) => {
   6 |     return (
>  7 |         <Grid>
     |         ^
   8 |             <Row className="propRow">
   9 |                 <Col sm={3}>
  10 |                     <OverlayTrigger placement="bottom"
SyntaxError: src/jsx/Dashboard.jsx: Unexpected token (12:4)
  10 | const App = ({ GLVersion }) => {
  11 |   return (
> 12 |     <Grid>
|         ^
   8 |             <Row className="propRow">
   9 |                 <Col sm={3}>
  10 |                     <OverlayTrigger placement="bottom"
SyntaxError: src/jsx/Dashboard.jsx: Unexpected token (12:4)
  10 | const App = ({ GLVersion }) => {
  11 |   return (
> 12 |     <Grid>
     |     ^
  13 |       <Row className="versionRow">
  14 |         <Col smOffset={10} sm={1} className="fieldLabel">Version:</Col>
  15 |         <Col sm={1} className="fieldLabel">{GLVersion}</Col>
SyntaxError: src/jsx/FieldInputs.jsx: Unexpected token (9:8)
   7 | const FieldControl = ({ input, meta, type, min, max, tip, cid }) => {
   8 |     return (
>  9 |         <OverlayTrigger placement="left" overlay={(<Tooltip id={cid + "-tip"}>{tip}</Tooltip>)}>
     |         ^
  10 |             <FormControl
  11 |                 type={type}
  12 |                 min={min}
SyntaxError: src/jsx/Utilities.jsx: Unexpected token (9:8)
   7 | const Util = ({ JobsDirSize, killAction }) => {
   8 |     return (
>  9 |         <Grid>
     |         ^
  10 |             <Row className="propRow">
  11 |                 <Col sm={3} className="fieldLabel">Job Folder Size:</Col>
  12 |                 <Col sm={9} className="fieldLabel">{JobsDirSize} MB</Col>
src\main\main.js -> dist\main\main.js
src\main\monitor.js -> dist\main\monitor.js
src\main\utils.js -> dist\main\utils.js
src\main\watson.js -> dist\main\watson.js

1 个答案:

答案 0 :(得分:2)

事实证明这是预设的一个未解决的问题:https://github.com/babel/babel-preset-env/issues/326