mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-17 11:03:53 +08:00
ci: add option to ignore imports/requires from dependencies
It needs to be in the file itself where the require/import is made.
This commit is contained in:
parent
b965a49a49
commit
fe69b5b110
@ -3,7 +3,6 @@
|
|||||||
// Prevent the dependency validation from tripping because we don't import these. We need
|
// Prevent the dependency validation from tripping because we don't import these. We need
|
||||||
// it as a peer dependency of @angular/core.
|
// it as a peer dependency of @angular/core.
|
||||||
// require('zone.js')
|
// require('zone.js')
|
||||||
// require('@angular/tsc-wrapped')
|
|
||||||
|
|
||||||
|
|
||||||
// This file hooks up on require calls to transpile TypeScript.
|
// This file hooks up on require calls to transpile TypeScript.
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ignoreDep @angular/compiler-cli
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ignoreDep @angular/compiler-cli
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
|
|
||||||
let version;
|
let version;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ignoreDep @angular/compiler-cli
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import * as ts from 'typescript';
|
import * as ts from 'typescript';
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// @ignoreDep @angular/compiler-cli
|
||||||
import {CodeGenerator} from '@angular/compiler-cli';
|
import {CodeGenerator} from '@angular/compiler-cli';
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ const path = require('path');
|
|||||||
|
|
||||||
const IMPORT_RE = /(^|\n)\s*import\b(?:.|\n)*?\'[^\']*\'/g;
|
const IMPORT_RE = /(^|\n)\s*import\b(?:.|\n)*?\'[^\']*\'/g;
|
||||||
const REQUIRE_RE = /\brequire\('[^)]+?'\)/g;
|
const REQUIRE_RE = /\brequire\('[^)]+?'\)/g;
|
||||||
|
const IGNORE_RE = /\s+@ignoreDep\s+\S+/g;
|
||||||
const NODE_PACKAGES = [
|
const NODE_PACKAGES = [
|
||||||
'child_process',
|
'child_process',
|
||||||
'fs',
|
'fs',
|
||||||
@ -72,6 +73,16 @@ function listRequiredModules(source) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function listIgnoredModules(source) {
|
||||||
|
const ignored = source.match(IGNORE_RE);
|
||||||
|
return (ignored || [])
|
||||||
|
.map(match => {
|
||||||
|
const m = match.match(/@ignoreDep\s+(\S+)/);
|
||||||
|
return m && m[1];
|
||||||
|
})
|
||||||
|
.filter(x => !!x);
|
||||||
|
}
|
||||||
|
|
||||||
function reportMissingDependencies(missingDeps) {
|
function reportMissingDependencies(missingDeps) {
|
||||||
if (missingDeps.length == 0) {
|
if (missingDeps.length == 0) {
|
||||||
console.log(chalk.green(' no dependency missing from package.json.'));
|
console.log(chalk.green(' no dependency missing from package.json.'));
|
||||||
@ -110,6 +121,10 @@ for (const packageName of Object.keys(packages)) {
|
|||||||
.forEach(modulePath => importMap[modulePath] = true);
|
.forEach(modulePath => importMap[modulePath] = true);
|
||||||
listRequiredModules(source)
|
listRequiredModules(source)
|
||||||
.forEach(modulePath => importMap[modulePath] = true);
|
.forEach(modulePath => importMap[modulePath] = true);
|
||||||
|
listIgnoredModules(source)
|
||||||
|
.forEach(modulePath => {
|
||||||
|
delete importMap[modulePath];
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const dependencies = Object.keys(importMap)
|
const dependencies = Object.keys(importMap)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user