Skip to content

Commit af3a221

Browse files
committed
Added FB prepack
1 parent 0c1fbf5 commit af3a221

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

src/compilers/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Babel5 from './babel5'
33
import Traceur from './traceur'
44
import TypeScript from './typescript'
55
import Regenerator from './regenerator'
6+
import Prepack from './prepack'
67

78

89
export const DEFAULT_COMPILER = 'Babel (6)';
@@ -21,6 +22,7 @@ const compilers = {
2122
'Traceur': new Traceur(),
2223
'TypeScript': new TypeScript(),
2324
'Regenerator': new Regenerator(),
25+
'Prepack': new Prepack(),
2426
};
2527

2628
export default compilers;

src/compilers/prepack.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import Base from './base';
2+
3+
export default class Prepack extends Base {
4+
static makeError( { lineNumber, description, column, endColumn = NaN } ) {
5+
let l = lineNumber - 1;
6+
7+
return {
8+
loc : {
9+
line : l,
10+
column : column,
11+
offset : () => { return { line: l,column:endColumn} }
12+
},
13+
message : description
14+
};
15+
}
16+
17+
loadCompiler() {
18+
require.ensure(['prepack'],require => {
19+
this.compiler = require('prepack');
20+
this.resolveFuture();
21+
});
22+
}
23+
24+
compile( input ) {
25+
this._checkIfCompilerIsLoaded();
26+
27+
let code = "",
28+
errors = [];
29+
30+
try {
31+
code = this.compiler.prepack(input).code;
32+
} catch (e) {
33+
// errors = [e];
34+
}
35+
36+
return {
37+
code,
38+
errors
39+
};
40+
}
41+
}

0 commit comments

Comments
 (0)