Skip to content

Commit 1a160da

Browse files
clydinalan-agius4
authored andcommitted
fix(@angular-devkit/build-angular): ensure karma sourcemap support on Windows
The `glob`-based check when adding the sourcemap support packages to the karma setup was incorrectly skipping the files due to Windows pathing issues. The `glob`-based check, however, is unneeded due to the already present `require.resolve` checks for the sourcemap support packages which will throw if the packages are not present.
1 parent c24be81 commit 1a160da

File tree

2 files changed

+9
-32
lines changed
  • .circleci
  • packages/angular_devkit/build_angular/src/webpack/plugins/karma

2 files changed

+9
-32
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ jobs:
318318
name: Execute E2E Tests
319319
command: |
320320
if (Test-Path env:CIRCLE_PULL_REQUEST) {
321-
node tests\legacy-cli\run_e2e.js "--glob={tests/basic/**,tests/i18n/extract-ivy*.ts,tests/build/profile.ts}" --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
321+
node tests\legacy-cli\run_e2e.js "--glob={tests/basic/**,tests/i18n/extract-ivy*.ts,tests/build/profile.ts,tests/test/test-sourcemap.ts}" --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
322322
} else {
323323
node tests\legacy-cli\run_e2e.js --nb-shards=$env:CIRCLE_NODE_TOTAL --shard=$env:CIRCLE_NODE_INDEX
324324
}

packages/angular_devkit/build_angular/src/webpack/plugins/karma/karma.ts

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
// TODO: cleanup this file, it's copied as is from Angular CLI.
1111
import * as http from 'http';
1212
import * as path from 'path';
13-
import * as glob from 'glob';
1413
import webpack from 'webpack';
1514
import webpackDevMiddleware from 'webpack-dev-middleware';
1615

@@ -28,29 +27,6 @@ let webpackMiddleware: any;
2827
let successCb: () => void;
2928
let failureCb: () => void;
3029

31-
// Add files to the Karma files array.
32-
function addKarmaFiles(files: any[], newFiles: any[], prepend = false) {
33-
const defaults = {
34-
included: true,
35-
served: true,
36-
watched: true,
37-
};
38-
39-
const processedFiles = newFiles
40-
// Remove globs that do not match any files, otherwise Karma will show a warning for these.
41-
.filter((file) => glob.sync(file.pattern, { nodir: true }).length != 0)
42-
// Fill in pattern properties with defaults.
43-
.map((file) => ({ ...defaults, ...file }));
44-
45-
// It's important to not replace the array, because
46-
// karma already has a reference to the existing array.
47-
if (prepend) {
48-
files.unshift(...processedFiles);
49-
} else {
50-
files.push(...processedFiles);
51-
}
52-
}
53-
5430
const init: any = (config: any, emitter: any) => {
5531
if (!config.buildWebpack) {
5632
throw new Error(
@@ -73,13 +49,14 @@ const init: any = (config: any, emitter: any) => {
7349
const smsPath = path.dirname(require.resolve('source-map-support'));
7450
const ksmsPath = path.dirname(require.resolve('karma-source-map-support'));
7551

76-
addKarmaFiles(
77-
config.files,
78-
[
79-
{ pattern: path.join(smsPath, 'browser-source-map-support.js'), watched: false },
80-
{ pattern: path.join(ksmsPath, 'client.js'), watched: false },
81-
],
82-
true,
52+
config.files.unshift(
53+
{
54+
pattern: path.join(smsPath, 'browser-source-map-support.js'),
55+
included: true,
56+
served: true,
57+
watched: false,
58+
},
59+
{ pattern: path.join(ksmsPath, 'client.js'), included: true, served: true, watched: false },
8360
);
8461
}
8562

0 commit comments

Comments
 (0)