Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions lib/compiler/plugins/es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions lib/compiler/plugins/jsx.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@
"velocityjs": "0.4.x"
},
"devDependencies": {
"chai": "1.3.x"
"chai": "1.3.x",
"babel-cli": "^6.7.5",
"babel-preset-es2015": "^6.6.0",
"babel-preset-react": "^6.5.0"
},
"optionalDependencies": {},
"engines": {
Expand All @@ -56,4 +59,4 @@
"scripts": {
"prepublish": "cake build"
}
}
}
37 changes: 37 additions & 0 deletions src/compiler/plugins/es.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
utils = require '../../util'
Package = require '../../package'
syspath = require 'path'
babel = require 'babel-core'
es2015 = require('babel-preset-es2015')
react = require('babel-preset-react')

getBabelConfig = ( configPath ) ->
return null unless utils.path.exists configPath
config = utils.file.io.readJSON configPath
return config

exports.contentType = "javascript"

exports.process = (txt, path, module, cb) ->
try
name = syspath.basename path, '.es'

cwd = process.cwd()
# 先寻找最近的fekit_modules目录
basepath = utils.path.closest cwd , Package.FEKIT_MODULE_DIR , true
# 如果没有,再寻找最近的fekit.config
basepath = utils.path.closest cwd , 'fekit.config' unless basepath
# 再没有,则使用当前目录
basepath = cwd unless basepath

babel_config_path = utils.path.join( basepath , '.babelrc' )

babelConfig = getBabelConfig babel_config_path

babelConfig = {presets: [es2015, react]} unless babelConfig

txt = (babel.transform txt, babelConfig).code

cb null, txt
catch err
cb err
1 change: 1 addition & 0 deletions src/compiler/plugins/jsx.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require './es'