Skip to content

Commit fe69b5b

Browse files
committed
ci: add option to ignore imports/requires from dependencies
It needs to be in the file itself where the require/import is made.
1 parent b965a49 commit fe69b5b

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

packages/@angular/cli/lib/cli/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// Prevent the dependency validation from tripping because we don't import these. We need
44
// it as a peer dependency of @angular/core.
55
// require('zone.js')
6-
// require('@angular/tsc-wrapped')
76

87

98
// This file hooks up on require calls to transpile TypeScript.

packages/@ngtools/webpack/src/extract_i18n_plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ignoreDep @angular/compiler-cli
12
import * as ts from 'typescript';
23
import * as path from 'path';
34
import * as fs from 'fs';

packages/@ngtools/webpack/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ignoreDep @angular/compiler-cli
12
import * as path from 'path';
23

34
let version;

packages/@ngtools/webpack/src/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ignoreDep @angular/compiler-cli
12
import * as fs from 'fs';
23
import * as path from 'path';
34
import * as ts from 'typescript';

packages/@ngtools/webpack/src/reflector_host.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ignoreDep @angular/compiler-cli
12
import {CodeGenerator} from '@angular/compiler-cli';
23

34

scripts/publish/validate_dependencies.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const path = require('path');
1111

1212
const IMPORT_RE = /(^|\n)\s*import\b(?:.|\n)*?\'[^\']*\'/g;
1313
const REQUIRE_RE = /\brequire\('[^)]+?'\)/g;
14+
const IGNORE_RE = /\s+@ignoreDep\s+\S+/g;
1415
const NODE_PACKAGES = [
1516
'child_process',
1617
'fs',
@@ -72,6 +73,16 @@ function listRequiredModules(source) {
7273
});
7374
}
7475

76+
function listIgnoredModules(source) {
77+
const ignored = source.match(IGNORE_RE);
78+
return (ignored || [])
79+
.map(match => {
80+
const m = match.match(/@ignoreDep\s+(\S+)/);
81+
return m && m[1];
82+
})
83+
.filter(x => !!x);
84+
}
85+
7586
function reportMissingDependencies(missingDeps) {
7687
if (missingDeps.length == 0) {
7788
console.log(chalk.green(' no dependency missing from package.json.'));
@@ -110,6 +121,10 @@ for (const packageName of Object.keys(packages)) {
110121
.forEach(modulePath => importMap[modulePath] = true);
111122
listRequiredModules(source)
112123
.forEach(modulePath => importMap[modulePath] = true);
124+
listIgnoredModules(source)
125+
.forEach(modulePath => {
126+
delete importMap[modulePath];
127+
});
113128
});
114129

115130
const dependencies = Object.keys(importMap)

0 commit comments

Comments
 (0)