This repository has been archived by the owner on Dec 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
Fixed skyux test/watch
performance
#202
Merged
Merged
Changes from 12 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
1ac892f
Removed tslint-loader
Blackbaud-SteveBrush 7d9b496
Updated gitignore
Blackbaud-SteveBrush 2bfdb7b
Re-added tslint-loader
Blackbaud-SteveBrush 2a27ebe
Update .gitignore
Blackbaud-SteveBrush 720d925
Added todo comment
Blackbaud-SteveBrush f6bc66f
Merge branch 'fix-test-performance' of https://github.com/blackbaud/s…
Blackbaud-SteveBrush 5eecf55
Cleanup
Blackbaud-SteveBrush ec7181d
Removed tslint loader
Blackbaud-SteveBrush 5976cc6
Created tslint webpack loader and plugin
Blackbaud-SteveBrush d3fc8e8
Added comments
Blackbaud-SteveBrush f7eb0bf
Moved imports
Blackbaud-SteveBrush 700ddab
Removed lint command
Blackbaud-SteveBrush fe97a9b
Cleaned up implementation
Blackbaud-SteveBrush 59593f1
Updated tests, added mocks
Blackbaud-SteveBrush 742cd43
Updated unit tests
Blackbaud-SteveBrush b3f9b2e
Updated unit tests
Blackbaud-SteveBrush File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
/*jslint node: true */ | ||
'use strict'; | ||
|
||
function getWebpackConfig(skyPagesConfig, argv) { | ||
|
||
function spaPath() { | ||
return skyPagesConfigUtil.spaPath.apply(skyPagesConfigUtil, arguments); | ||
} | ||
|
||
function outPath() { | ||
return skyPagesConfigUtil.outPath.apply(skyPagesConfigUtil, arguments); | ||
} | ||
|
||
const path = require('path'); | ||
const path = require('path'); | ||
const DefinePlugin = require('webpack/lib/DefinePlugin'); | ||
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); | ||
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin'); | ||
const ProcessExitCode = require('../../plugin/process-exit-code'); | ||
const SkyTsLintCheckerPlugin = require('../../loader/sky-tslint/checker-plugin'); | ||
const skyPagesConfigUtil = require('../sky-pages/sky-pages.config'); | ||
const aliasBuilder = require('./alias-builder'); | ||
|
||
function spaPath() { | ||
return skyPagesConfigUtil.spaPath.apply(skyPagesConfigUtil, arguments); | ||
} | ||
|
||
const DefinePlugin = require('webpack/lib/DefinePlugin'); | ||
const LoaderOptionsPlugin = require('webpack/lib/LoaderOptionsPlugin'); | ||
const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin'); | ||
const ProcessExitCode = require('../../plugin/process-exit-code'); | ||
const skyPagesConfigUtil = require('../sky-pages/sky-pages.config'); | ||
const aliasBuilder = require('./alias-builder'); | ||
function outPath() { | ||
return skyPagesConfigUtil.outPath.apply(skyPagesConfigUtil, arguments); | ||
} | ||
|
||
function getWebpackConfig(skyPagesConfig, argv) { | ||
const runCoverage = (!argv || argv.coverage !== false); | ||
skyPagesConfig.runtime.includeRouteModule = false; | ||
|
||
const ENV = process.env.ENV = process.env.NODE_ENV = 'test'; | ||
const srcPath = path.resolve(process.cwd(), 'src', 'app'); | ||
const moduleLoader = outPath('loader', 'sky-pages-module'); | ||
|
||
const resolves = [ | ||
process.cwd(), | ||
|
@@ -66,17 +64,7 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
{ | ||
enforce: 'pre', | ||
test: /sky-pages\.module\.ts$/, | ||
loader: moduleLoader | ||
}, | ||
{ | ||
enforce: 'pre', | ||
test: /\.ts$/, | ||
loader: 'tslint-loader', | ||
exclude: excludes, | ||
options: { | ||
emitErrors: true, | ||
failOnHint: true | ||
} | ||
loader: outPath('loader', 'sky-pages-module') | ||
}, | ||
{ | ||
enforce: 'pre', | ||
|
@@ -87,7 +75,13 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
{ | ||
enforce: 'pre', | ||
loader: outPath('loader', 'sky-processor', 'preload'), | ||
exclude: /node_modules/ | ||
exclude: excludes | ||
}, | ||
{ | ||
enforce: 'pre', | ||
test: /\.ts$/, | ||
loader: outPath('loader', 'sky-tslint'), | ||
exclude: excludes | ||
}, | ||
{ | ||
test: /\.ts$/, | ||
|
@@ -98,7 +92,9 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
// Ignore the "Cannot find module" error that occurs when referencing | ||
// an aliased file. Webpack will still throw an error when a module | ||
// cannot be resolved via a file path or alias. | ||
ignoreDiagnostics: [2307] | ||
ignoreDiagnostics: [2307], | ||
// Linting is handled by the sky-tslint loader. | ||
transpileOnly: true | ||
} | ||
}, | ||
{ | ||
|
@@ -108,19 +104,12 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
exclude: [/\.e2e\.ts$/] | ||
}, | ||
{ | ||
test: /\.css$/, | ||
loader: 'raw-loader' | ||
test: /\.s?css$/, | ||
use: ['raw-loader', 'sass-loader'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just some cleanup to match what's in common config. |
||
}, | ||
{ | ||
test: /\.html$/, | ||
loader: 'raw-loader' | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
'raw-loader', | ||
'sass-loader' | ||
] | ||
} | ||
] | ||
}, | ||
|
@@ -130,13 +119,7 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
debug: true, | ||
options: { | ||
context: __dirname, | ||
skyPagesConfig: skyPagesConfig, | ||
tslint: { | ||
emitErrors: false, | ||
failOnHint: false, | ||
resourcePath: 'src', | ||
typeCheck: true | ||
} | ||
skyPagesConfig: skyPagesConfig | ||
} | ||
}), | ||
|
||
|
@@ -159,6 +142,9 @@ function getWebpackConfig(skyPagesConfig, argv) { | |
{} | ||
), | ||
|
||
// Handles watch-mode maintenance for TSLint. | ||
new SkyTsLintCheckerPlugin(), | ||
|
||
// Webpack 2 behavior does not correctly return non-zero exit code. | ||
new ProcessExitCode() | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*jshint node: true*/ | ||
'use strict'; | ||
|
||
function SkyTsLintCheckerPlugin() { | ||
let isWatchMode = false; | ||
|
||
const apply = (compiler) => { | ||
compiler.plugin('run', function (params, callback) { | ||
isWatchMode = false; | ||
callback(); | ||
}); | ||
|
||
compiler.plugin('watch-run', function (params, callback) { | ||
isWatchMode = true; | ||
callback(); | ||
}); | ||
|
||
compiler.plugin('emit', function (compilation, callback) { | ||
if (isWatchMode === true) { | ||
require('./program').clearProgram(); | ||
} | ||
|
||
callback(); | ||
}); | ||
}; | ||
|
||
return { | ||
apply | ||
}; | ||
} | ||
|
||
module.exports = SkyTsLintCheckerPlugin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const tslint = require('tslint'); | ||
const skyPagesConfigUtil = require('../../config/sky-pages/sky-pages.config'); | ||
const skyTsLintProgram = require('./program'); | ||
|
||
const lint = (instance, input) => { | ||
const options = { | ||
fix: false, | ||
typeCheck: true | ||
}; | ||
|
||
const program = skyTsLintProgram.getProgram(); | ||
const linter = new tslint.Linter(options, program); | ||
const tslintConfig = skyPagesConfigUtil.spaPath('tslint.json'); | ||
const configuration = tslint.Configuration.findConfiguration(tslintConfig).results; | ||
|
||
linter.lint(instance.resourcePath, input, configuration); | ||
const result = linter.getResult(); | ||
|
||
if (result.failures.length) { | ||
return new Error(`Compilation failed due to tslint errors. ${result.output}`); | ||
} | ||
|
||
return; | ||
}; | ||
|
||
module.exports = function (input, map) { | ||
const instance = this; | ||
const callback = instance.async(); | ||
|
||
instance.cacheable && instance.cacheable(); | ||
|
||
let error = lint(instance, input); | ||
callback(error, input, map); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/*jshint node: true*/ | ||
'use strict'; | ||
|
||
const tslint = require('tslint'); | ||
const skyPagesConfigUtil = require('../../config/sky-pages/sky-pages.config'); | ||
|
||
const tsconfigPath = skyPagesConfigUtil.spaPath('tsconfig.json'); | ||
let _context = {}; | ||
|
||
const getProgram = () => { | ||
if (!_context.tslintProgram) { | ||
_context.tslintProgram = tslint.Linter.createProgram(tsconfigPath); | ||
} | ||
|
||
return _context.tslintProgram; | ||
}; | ||
|
||
const clearProgram = () => { | ||
delete _context.tslintProgram; | ||
}; | ||
|
||
module.exports = { | ||
getProgram, | ||
clearProgram | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed this rule because it is already listed in "common" config.