Skip to content

Commit 486e523

Browse files
committed
[angular-jit-compiler] ES2015 import support added
1 parent 03bfce5 commit 486e523

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

atmosphere-packages/angular-jit-compiler/package.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Package.onUse(function(api) {
1515
api.versionsFrom('1.5.2.2');
1616
api.use([
1717
'ecmascript',
18-
'barbatus:[email protected]'
18+
'barbatus:[email protected]',
19+
'babel-compiler'
1920
], 'server');
2021
api.mainModule('index.js', 'server');
2122
api.export([

atmosphere-packages/angular-jit-compiler/scss-compiler.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const basePath = process.cwd();
66

77
export class AngularJitScssCompiler{
88
processFilesForTarget(scssFiles){
9-
try{
10-
for(const scssFile of scssFiles){
9+
for(const scssFile of scssFiles){
10+
try{
1111
const fileName = scssFile.getBasename();
1212
const filePath = scssFile.getPathInPackage();
1313
if(!fileName.startsWith('_' ) &&
@@ -25,9 +25,9 @@ export class AngularJitScssCompiler{
2525
sourceMap: outputData.map
2626
});
2727
}
28+
}catch(e){
29+
scssFile.error(e);
2830
}
29-
}catch(e){
30-
scssFile.error(e);
3131
}
3232
}
3333
}

atmosphere-packages/angular-jit-compiler/ts-compiler.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
1-
const path = Npm.require('path');
1+
import fs from 'fs';
2+
import path from 'path';
23

34
// using: regex, capture groups, and capture group variables.
45
const TEMPLATE_URL_REGEX = /templateUrl\s*:(\s*['"`](.*?)['"`]\s*([,}]))/gm;
56
const STYLES_URLS_REGEX = /styleUrls *:(\s*\[[^\]]*?\])/g;
67
const STRING_REGEX = /(['`"])((?:[^\\]\\\1|.)*?)\1/g;
78

9+
const basePath = process.cwd();
10+
811
export class AngularJitTsCompiler extends TypeScriptCompiler {
912
processFilesForTarget(tsFiles){
1013
for(const tsFile of tsFiles){
14+
const tsFilePath = tsFile.getPathInPackage();
15+
if(tsFilePath.endsWith('.d.ts')){
16+
const jsFilePath = tsFilePath.replace('.d.ts', '.js');
17+
try{
18+
const source = fs.readFileSync(path.join(basePath, jsFilePath), 'utf8');
19+
const result = Babel.compile(source);
20+
tsFile.addJavaScript({
21+
path: jsFilePath,
22+
data: result.code
23+
})
24+
}catch(e){
25+
console.log(e);
26+
}
27+
}
1128
this.fixTemplateAndStyleUrls(tsFile);
1229
}
1330
super.processFilesForTarget(tsFiles)

0 commit comments

Comments
 (0)