Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding conformance webpack plugin #9716

Merged
merged 16 commits into from Jan 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -5,8 +5,12 @@ export interface IConformanceAnomaly {
stack_trace?: string
}

export enum IConformanceTestStatus {
Timer marked this conversation as resolved.
Show resolved Hide resolved
SUCCESS,
FAILED,
}
export interface IConformanceTestResult {
result: 'SUCCESS' | 'FAILED'
result: IConformanceTestStatus
warnings?: Array<IConformanceAnomaly>
errors?: Array<IConformanceAnomaly>
}
Expand Down
@@ -1,6 +1,7 @@
import {
IWebpackConformanceTest,
IConformanceTestResult,
IConformanceTestStatus,
} from '../TestInterface'
import { CONFORMANCE_ERROR_PREFIX } from '../constants'

Expand All @@ -10,7 +11,7 @@ export class MinificationConformanceCheck implements IWebpackConformanceTest {

if (options.optimization.minimize === false) {
return {
result: 'FAILED',
result: IConformanceTestStatus.FAILED,
errors: [
{
message: `${CONFORMANCE_ERROR_PREFIX}: Minification is disabled for this build.\nDisabling minification can result in serious performance degradation.`,
Expand All @@ -19,7 +20,7 @@ export class MinificationConformanceCheck implements IWebpackConformanceTest {
}
} else {
return {
result: 'SUCCESS',
result: IConformanceTestStatus.SUCCESS,
}
}
}
Expand Down
@@ -1,4 +1,6 @@
import { red, yellow } from 'kleur'
import chalk from 'chalk'

const { red, yellow } = chalk

export const CONFORMANCE_ERROR_PREFIX: string = red('[BUILD CONFORMANCE ERROR]')
export const CONFORMANCE_WARNING_PREFIX: string = yellow(
Expand Down
Expand Up @@ -5,6 +5,7 @@ import {
IConformanceAnomaly,
IGetAstNodeResult,
NodeInspector,
IConformanceTestStatus,
} from './TestInterface'
import { NodePath } from 'ast-types/lib/node-path'
import { visit } from 'recast'
Expand Down Expand Up @@ -54,17 +55,12 @@ export default class WebpackConformancePlugin {
return test.buildStared(this.compiler.options)
}
return {
result: 'SUCCESS',
result: IConformanceTestStatus.SUCCESS,
} as IConformanceTestResult
}
)

Promise.all(buildStartedResults).then(
(results: Array<IConformanceTestResult>) => {
this.gatherResults(results)
}
)

this.gatherResults(buildStartedResults)
callback()
}

Expand All @@ -78,7 +74,7 @@ export default class WebpackConformancePlugin {
return test.buildCompleted(compilation.assets)
}
return {
result: 'SUCCESS',
result: IConformanceTestStatus.SUCCESS,
} as IConformanceTestResult
}
)
Expand Down