-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial CoffeeScript support * Minor * Simplify CoffeeScriptAsset
- Loading branch information
1 parent
87350f4
commit 2d680c0
Showing
7 changed files
with
43 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ coverage | |
dist | ||
lib | ||
!test/**/node_modules | ||
.vscode/ | ||
.vscode/ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const JSAsset = require('./JSAsset'); | ||
const config = require('../utils/config'); | ||
const localRequire = require('../utils/localRequire'); | ||
|
||
class CoffeeScriptAsset extends JSAsset { | ||
async parse(code) { | ||
// require coffeescript, installed locally in the app | ||
let coffee = localRequire('coffeescript', this.name); | ||
|
||
// Transpile Module using CoffeeScript and parse result as ast format through babylon | ||
this.contents = coffee.compile(code, {}); | ||
return await super.parse(this.contents); | ||
} | ||
} | ||
|
||
module.exports = CoffeeScriptAsset; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var local = require('./local.coffee'); | ||
|
||
module.exports = function () { | ||
return local.a + local.b.c; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = | ||
a: 1 | ||
b: | ||
c: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters