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

make node 6 compatible #202

Merged
merged 7 commits into from
Jan 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v1.0.0-alpha.4

* [make node 6 compatible](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/202)

## v1.0.0-alpha.3

* [replace peerDeps with runtime checks](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/201)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ may be much faster, even compared to multi-threaded compilation.

* **measureCompilationTime** `boolean`:
If true, the plugin will measure the time spent inside the compilation code. This may be useful to compare modes,
especially if there are other loaders/plugins involved in the compilation.
especially if there are other loaders/plugins involved in the compilation. **requires node 8+**

### Pre-computed consts:
* `ForkTsCheckerWebpackPlugin.ONE_CPU` - always use one CPU
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fork-ts-checker-webpack-plugin",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"description": "Runs typescript type checker and linter on separate process.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
Expand Down Expand Up @@ -38,7 +38,7 @@
"webpack-plugin"
],
"engines": {
"node": ">=8.9.0"
"node": ">=6.11.5"
},
"author": "Piotr Oleś <piotrek.oles@gmail.com>",
"contributors": [
Expand Down
10 changes: 7 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as path from 'path';
import * as process from 'process';
import { performance } from 'perf_hooks';
import * as childProcess from 'child_process';
import * as semver from 'semver';
import chalk, { Chalk } from 'chalk';
Expand Down Expand Up @@ -118,6 +117,7 @@ class ForkTsCheckerWebpackPlugin {
private vue: boolean;

private measureTime: boolean;
private performance: any;
private startAt: number = 0;
constructor(options?: Partial<Options>) {
options = options || ({} as Options);
Expand Down Expand Up @@ -186,6 +186,10 @@ class ForkTsCheckerWebpackPlugin {

this.vue = options.vue === true; // default false
this.measureTime = options.measureCompilationTime === true;
if (this.measureTime) {
// Node 8+ only
this.performance = require('perf_hooks').performance;
}
}

private validateVersions() {
Expand Down Expand Up @@ -362,7 +366,7 @@ class ForkTsCheckerWebpackPlugin {

try {
if (this.measureTime) {
this.startAt = performance.now();
this.startAt = this.performance.now();
}
this.service!.send(this.cancellationToken);
} catch (error) {
Expand Down Expand Up @@ -625,7 +629,7 @@ class ForkTsCheckerWebpackPlugin {

private handleServiceMessage(message: Message): void {
if (this.measureTime) {
const delta = performance.now() - this.startAt;
const delta = this.performance.now() - this.startAt;
this.logger.info(`compilation took: ${delta} ms.`);
}
if (this.cancellationToken) {
Expand Down
2 changes: 1 addition & 1 deletion src/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"skipLibCheck": true,
"suppressImplicitAnyIndexErrors": true,
"strict": true,
"lib": ["es2015", "es2016.array.include", "dom"],
"lib": ["es2015", "es2016.array.include"],
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
Expand Down