Skip to content

Commit

Permalink
fix(@angular/cli): ignore ts-node when attempting to run karma with a…
Browse files Browse the repository at this point in the history
… linked cli (angular#4997)

fixes angular#4568, angular#4177
  • Loading branch information
delasteve authored and Zhicheng Wang committed Mar 16, 2017
1 parent 8b04631 commit c67d4ba
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/bootstrap-local.js
Expand Up @@ -12,7 +12,7 @@ global.angularCliPackages = require('./packages');
const compilerOptions = JSON.parse(fs.readFileSync(path.join(__dirname, '../tsconfig.json')));

const oldRequireTs = require.extensions['.ts'];
require.extensions['.ts'] = function(m, filename) {
require.extensions['.ts'] = function (m, filename) {
// If we're in node module, either call the old hook or simply compile the
// file without transpilation. We do not touch node_modules/**.
// We do touch `Angular CLI` files anywhere though.
Expand Down Expand Up @@ -52,6 +52,9 @@ if (!__dirname.match(new RegExp(`\\${path.sep}node_modules\\${path.sep}`))) {
const Module = require('module');
const oldLoad = Module._load;
Module._load = function (request, parent) {
if (request.match(/ts-node/) && parent && parent.id && parent.id.match(/karma/)) {
throw new Error();
}
if (request in packages) {
return oldLoad.call(this, packages[request].main, parent);
} else if (request.startsWith('@angular/cli/')) {
Expand Down

1 comment on commit c67d4ba

@codeNoobie
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@delasteve @asnowwolf With this change, does angular cli no longer accepts a typescript version of karma config?

I have been trying to pass karma.config.ts to as below, but it is not able to transpile the ts file.

"test": {
"karma": {
"config": "./src/karma.prod.config.ts"
}
},

Please help.

Please sign in to comment.