Skip to content

Commit

Permalink
chore(bundle): suppress CIRCULAR_DEPENDENCY warnings to debug logs
Browse files Browse the repository at this point in the history
  • Loading branch information
adamdbradley committed Feb 15, 2018
1 parent 916fb39 commit 8cd6d54
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/compiler/app/app-global-scripts.ts
Expand Up @@ -112,7 +112,7 @@ async function bundleProjectGlobal(config: Config, compilerCtx: CompilerCtx, bui
transpiledInMemoryPlugin(config, compilerCtx),
...config.plugins
],
onwarn: createOnWarnFn(buildCtx.diagnostics)
onwarn: createOnWarnFn(config, buildCtx.diagnostics)
});

const results = await rollup.generate({ format: 'es' });
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/bundle/rollup-bundle.ts
Expand Up @@ -39,7 +39,7 @@ export async function createBundle(config: Config, compilerCtx: CompilerCtx, bui
nodeEnvVars(config),
...config.plugins
],
onwarn: createOnWarnFn(buildCtx.diagnostics)
onwarn: createOnWarnFn(config, buildCtx.diagnostics)
};

try {
Expand Down
23 changes: 15 additions & 8 deletions src/util/logger/logger-rollup.ts
@@ -1,4 +1,4 @@
import { BuildCtx, CompilerCtx, Config, Diagnostic, ModuleFile, PrintLine } from '../interfaces';
import { BuildCtx, CompilerCtx, Config, Diagnostic, ModuleFile, PrintLine } from '../../declarations';
import { buildWarn } from '../../compiler/util';
import { formatFileName, formatHeader, splitLineBreaks } from './logger-util';
import { highlight } from './highlight/highlight';
Expand All @@ -22,8 +22,8 @@ export function loadRollupDiagnostics(config: Config, compilerCtx: CompilerCtx,
d.relFilePath = formatFileName(config.rootDir, d.absFilePath);

try {
let sourceText = compilerCtx.fs.readFileSync(d.absFilePath);
let srcLines = splitLineBreaks(sourceText);
const sourceText = compilerCtx.fs.readFileSync(d.absFilePath);
const srcLines = splitLineBreaks(sourceText);
let htmlLines = srcLines;

try {
Expand All @@ -39,7 +39,7 @@ export function loadRollupDiagnostics(config: Config, compilerCtx: CompilerCtx,
errorLength: 0
};

let highlightLine = errorLine.text.substr(rollupError.loc.column);
const highlightLine = errorLine.text.substr(rollupError.loc.column);
for (var i = 0; i < highlightLine.length; i++) {
if (CHAR_BREAK.indexOf(highlightLine.charAt(i)) > -1) {
break;
Expand Down Expand Up @@ -110,17 +110,20 @@ export function loadRollupDiagnostics(config: Config, compilerCtx: CompilerCtx,
const CHAR_BREAK = [' ', '=', '.', ',', '?', ':', ';', '(', ')', '{', '}', '[', ']', '|', `'`, `"`, '`'];


export function createOnWarnFn(diagnostics: Diagnostic[], bundleModulesFiles?: ModuleFile[]) {
export function createOnWarnFn(config: Config, diagnostics: Diagnostic[], bundleModulesFiles?: ModuleFile[]) {
const previousWarns: {[key: string]: boolean} = {};

return function onWarningMessage(warning: any) {
return function onWarningMessage(warning: { code: string, importer: string, message: string }) {
if (warning && warning.message in previousWarns) {
return;
}
if (warning && warning.code) {
if (INGORE_BUNDLE_CODES.indexOf(warning.code) > -1) {
if (INGORE_WARNING_CODES.includes(warning.code)) {
return;
}
if (SUPPRESS_WARNING_CODES.includes(warning.code)) {
config.logger.debug(warning.message);
}
}
previousWarns[warning.message] = true;

Expand All @@ -137,6 +140,10 @@ export function createOnWarnFn(diagnostics: Diagnostic[], bundleModulesFiles?: M
}


const INGORE_BUNDLE_CODES = [
const INGORE_WARNING_CODES = [
`THIS_IS_UNDEFINED`, `NON_EXISTENT_EXPORT`
];

const SUPPRESS_WARNING_CODES = [
`CIRCULAR_DEPENDENCY`
];

0 comments on commit 8cd6d54

Please sign in to comment.