-
Notifications
You must be signed in to change notification settings - Fork 178
ignoreDiagnostics like ts-loader #150
Changes from all commits
2bbfe09
9d9b270
e986b0d
585e0ee
24eddaa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,3 @@ | ||
.tscache | ||
node_modules | ||
dist | ||
!/dist | ||
!/dist.babel | ||
tscommand | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,17 @@ | |
"description": "Awesome TS loader for webpack", | ||
"main": "dist.babel/entry.js", | ||
"scripts": { | ||
"prepublish": "npm run ts-build && npm run babel-build && grunt", | ||
"ts": "./node_modules/.bin/tsc --project src --watch --pretty --diagnostics", | ||
"ts-build": "./node_modules/.bin/tsc --project src --pretty", | ||
"babel": "babel dist --presets es2015 --out-dir dist.babel --watch", | ||
"babel-build": "babel dist --presets es2015 --out-dir dist.babel", | ||
"prepublish": "npm run test && grunt", | ||
"pretest": "npm run build", | ||
"test": "mocha dist.babel/test", | ||
"build": "npm run grunt && npm run babel-compile", | ||
"lint": "./node_modules/.bin/tslint src/*.ts" | ||
"watch": "npm run watch:ts && npm run watch:babel", | ||
"watch:ts": "npm run build:ts -- --watch --diagnostics", | ||
"watch:babel": "npm run build:babel -- --watch", | ||
"prebuild": "npm run lint", | ||
"build": "npm run build:ts && npm run build:babel", | ||
"build:ts": "tsc -p src --pretty", | ||
"build:babel": "babel dist -d dist.babel", | ||
"lint": "tslint src/*.ts" | ||
}, | ||
"author": "Stanislav Panferov <[email protected]> (http://panferov.me/)", | ||
"repository": { | ||
|
@@ -59,7 +62,6 @@ | |
"grunt-contrib-copy": "^0.7.0", | ||
"grunt-conventional-changelog": "^1.2.1", | ||
"grunt-shell": "^1.1.2", | ||
"grunt-ts": "^3.0.0", | ||
"load-grunt-tasks": "^0.6.0", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^2.3.4", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,20 +58,18 @@ export function codegenErrorReport(errors) { | |
.join('\n'); | ||
} | ||
|
||
export function formatErrors(instanceName: string, errors: ts.Diagnostic[]) { | ||
return errors.map(function (diagnostic) { | ||
let lineChar; | ||
if (diagnostic.file) { | ||
lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); | ||
} | ||
return ( | ||
`[${ instanceName }] ` + (diagnostic.file ? diagnostic.file.fileName : '') | ||
+ (lineChar ? formatLineChar(lineChar) + ' ' : '') + "\n" | ||
+ (typeof diagnostic.messageText == "string" ? | ||
diagnostic.messageText : | ||
formatMessageChain(<ts.DiagnosticMessageChain>diagnostic.messageText)) | ||
); | ||
}); | ||
export function formatError(diagnostic) { | ||
let lineChar; | ||
if (diagnostic.file) { | ||
lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); | ||
} | ||
return ( | ||
(diagnostic.file ? diagnostic.file.fileName : '') | ||
+ (lineChar ? formatLineChar(lineChar) + ' ' : '') + "\n" | ||
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.
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. Noted where it moved to. This just unwrapped |
||
+ (typeof diagnostic.messageText == "string" ? | ||
diagnostic.messageText : | ||
formatMessageChain(<ts.DiagnosticMessageChain>diagnostic.messageText)) | ||
); | ||
} | ||
|
||
export function formatMessageChain(chain: ts.DiagnosticMessageChain) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ import * as fs from 'fs'; | |
import * as path from 'path'; | ||
import * as _ from 'lodash'; | ||
import * as tsconfig from 'tsconfig'; | ||
import { loadLib, formatErrors } from './helpers'; | ||
import { loadLib, formatError } from './helpers'; | ||
import { ICompilerInfo } from './host'; | ||
import { createResolver } from './deps'; | ||
import { createChecker } from './checker'; | ||
|
@@ -358,16 +358,19 @@ function setupAfterCompile(compiler, instanceName, forkChecker = false) { | |
} | ||
|
||
let diagnostics = state.ts.getPreEmitDiagnostics(state.program); | ||
let emitError = (err) => { | ||
let emitError = (msg) => { | ||
if (compilation.bail) { | ||
console.error('Error in bail mode:', err); | ||
console.error('Error in bail mode:', msg); | ||
process.exit(1); | ||
} | ||
compilation.errors.push(new Error(err)); | ||
compilation.errors.push(new Error(msg)); | ||
}; | ||
|
||
let errors = formatErrors(instanceName, diagnostics); | ||
errors.forEach(emitError); | ||
let {options: {ignoreDiagnostics}} = instance; | ||
diagnostics | ||
.filter(err => !ignoreDiagnostics || ignoreDiagnostics.indexOf(err.code) == -1) | ||
.map(err => `[${ instanceName }] ` + formatError(err)) | ||
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.
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. Sorry, my fault. 👍 |
||
.forEach(emitError); | ||
|
||
instance.initedPlugins.forEach(plugin => { | ||
plugin.processProgram(state.program); | ||
|
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.
You're right I should've left this line so TS output doesn't get published to npm. The next two lines can still be removed though and maybe add
dist.babel/test
.