power-assert-js / espower-typescript

power-assert instrumentor for TypeScript
https://npm.im/espower-typescript
86 stars 11 forks source link

fix: espower throw error Attempted to transform AST twice when use allowJs true, and there has js and ts files in test directory #67

Closed echizen closed 3 years ago

echizen commented 4 years ago

bugfix: bug performance: when use allowJs: true in tsconfig.json, and has js and ts file in test directory, it will throw error : espower Attempted to transform AST twice.

cause reason: as for js file, espower-loader will call espower-source instrument target ast as output, and then call localModule._compile to handle output, see https://github.com/power-assert-js/espower-loader/blob/master/index.js#L42 and https://github.com/power-assert-js/espower-loader/blob/master/index.js#L45。while espower-typescript add _compile function to js file which is also call espower-source to cook code and instrument ast。

fix: so we can exclude js file when add _compile funciton to module, leave js file handling by espower-loader。

teppeis commented 3 years ago

This change breaks allowJS original behavior. I'm closing this PR because it's already out of date and I can't reproduce your problem. If you still need it, please send me a new PR. Thank you.