army8735 / jsdc

Javascript Downcast (es6 to es5)
http://army8735.me/jsdc
93 stars 12 forks source link

提供直接执行的cli? #29

Closed hax closed 9 years ago

hax commented 9 years ago

像babel提供了两个命令行: babel用于编译 babel-node用于直接基于node执行

jsdc有jsdc-cli提供了,再搞个jsdc-node?

army8735 commented 9 years ago

有个runtime的api是你说的吗

hax commented 9 years ago

我指直接的命令行。

另外runtime(true)似乎不起作用?有bug?

army8735 commented 9 years ago

抽空看看,ci是跑过的,记得io下没过。 -node是个新的项目?你不如直接owner了……

hax commented 9 years ago

不用开新项目,你把runtime修好就可以用了。 简陋代码如下:

#!/usr/bin/env node
var path = require('path')
var fs = require('fs')
var jsdc = require('jsdc')

jsdc.runtime(true)

var filename = process.argv[2]

var f = require.resolve(path.resolve(filename))
require(f)

然后在package.json里设下。

army8735 commented 9 years ago
/Users/army/Sites/github/jsdc/tests/runtime.js:3
  let a = 0;
  ^^^
SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outsi
  e strict mode

很神奇的仅io下报的错误

https://github.com/army8735/jsdc/blob/master/tests/runtime.js#L3

army8735 commented 9 years ago

"use strict";

才行

hax commented 9 years ago

嗯,是因为iojs默认开了let/const。但是v8现在的实现是要求'use strict'的,以后引擎应该会改掉。