Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 反应JSX+;二氧化钛_Javascript_Reactjs_Gruntjs_React Jsx_Grunt Browserify - Fatal编程技术网

Javascript 反应JSX+;二氧化钛

Javascript 反应JSX+;二氧化钛,javascript,reactjs,gruntjs,react-jsx,grunt-browserify,Javascript,Reactjs,Gruntjs,React Jsx,Grunt Browserify,我们目前的基础设施依赖钛作为天然材料。我正在尝试使用将我的节点项目转换为CommonJS。但是,它在JSX上失败: return ( <div className="App"> <EnergyChart width="1000" data={JSONData.data} customerID={customerID} lineColor='#FF0' height="500" marginTop="20" marginLeft="50" marginBottom="

我们目前的基础设施依赖钛作为天然材料。我正在尝试使用将我的节点项目转换为CommonJS。但是,它在JSX上失败:

return (
  <div className="App">
    <EnergyChart width="1000" data={JSONData.data} customerID={customerID} lineColor='#FF0' height="500" marginTop="20" marginLeft="50" marginBottom="20" marginRight="20" />
  </div>
);
对于titaniumifier,我有以下几点:

"titaniumifier": {
  "module": {
    files: {
      // The package is in "." and the zipfile will be written in "."
      ".": "."

    },

  },
  options: {
      transform: [ require('grunt-react').browserify],
  }
}
但是运行
grunt titaniumifier:module
返回

致命错误:正在分析文件 /Users/rduckworth/Projects/titanium-d3/app/app.js:意外令牌 (23:6)

这是上面的JSX代码


我能让Titaniumifier像browserify那样编译JSX吗?

@rickyduck的创建者和维护者。很抱歉我错过了这个问题

通过为应用程序启用Babel Transfilation,您可以为包/模块启用Babel Transfilation

长话短说:

  • 添加Babel作为依赖项
  • 使用package.json的
    titaniumifier.transforms
    对象
  • 例如:

    {
      "devDependencies": { ".." },
      "titaniumifier": {
        "transforms": {
          "babel": { "presets": [ "es2015" ] }
        }
      }
    }
    
    {
      "devDependencies": { ".." },
      "titaniumifier": {
        "transforms": {
          "babel": { "presets": [ "es2015" ] }
        }
      }
    }