@@ -2,25 +2,24 @@ import {writeFile} from 'fs';
22import { logger } from 'process-console-log' ;
33import exists from './exists' ;
44import { testPath } from './constants' ;
5- import * as ts from 'typescript' ;
65import importPaths from './import-paths' ;
6+ import compiler from './compiler' ;
77
88export default function writeTest ( config , testString : string ) {
99 return new Promise ( ( resolve , reject ) => {
1010 // fix import paths relative to project dir instead of test runner
11- const testStringWithFixedImportPaths = importPaths ( testString ) ;
11+ const testStringWithFixedImportPaths = importPaths ( config . dir , testString ) ;
1212
1313 const output = ''
1414 // append logger
1515 . concat ( logger )
1616 // exists polyfill for file/folder exists checks
1717 . concat ( exists ( config . dir ) )
18+ // babel hook to handle import / export in other files
19+ . concat ( `require("babel-register")({"plugins": [["transform-es2015-modules-commonjs", {"strict": true,"loose": true}]]});` )
1820 // compile using ts
19- . concat (
20- ts . transpile ( testStringWithFixedImportPaths , {
21- module : ts . ModuleKind . CommonJS
22- } )
23- ) ;
21+ . concat ( compiler ( testStringWithFixedImportPaths ) ) ;
22+
2423 // write test file
2524 writeFile ( testPath , output , ( err ) => {
2625 if ( err ) { reject ( err ) ; }
0 commit comments