Skip to content

Commit bb8dbf8

Browse files
authored
make node 6 compatible (#202)
* replace peerDeps with runtime checks * update changelog * make node 6 compatible * remove dupe / update version * change engines version * drop travis from build matrix
1 parent e66e912 commit bb8dbf8

File tree

5 files changed

+15
-7
lines changed

5 files changed

+15
-7
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## v1.0.0-alpha.4
2+
3+
* [make node 6 compatible](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/202)
4+
15
## v1.0.0-alpha.3
26

37
* [replace peerDeps with runtime checks](https://github.com/Realytics/fork-ts-checker-webpack-plugin/pull/201)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ may be much faster, even compared to multi-threaded compilation.
129129

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

134134
### Pre-computed consts:
135135
* `ForkTsCheckerWebpackPlugin.ONE_CPU` - always use one CPU

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "fork-ts-checker-webpack-plugin",
3-
"version": "1.0.0-alpha.3",
3+
"version": "1.0.0-alpha.4",
44
"description": "Runs typescript type checker and linter on separate process.",
55
"main": "lib/index.js",
66
"types": "lib/index.d.ts",
@@ -38,7 +38,7 @@
3838
"webpack-plugin"
3939
],
4040
"engines": {
41-
"node": ">=8.9.0"
41+
"node": ">=6.11.5"
4242
},
4343
"author": "Piotr Oleś <[email protected]>",
4444
"contributors": [

src/index.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as path from 'path';
22
import * as process from 'process';
3-
import { performance } from 'perf_hooks';
43
import * as childProcess from 'child_process';
54
import * as semver from 'semver';
65
import chalk, { Chalk } from 'chalk';
@@ -118,6 +117,7 @@ class ForkTsCheckerWebpackPlugin {
118117
private vue: boolean;
119118

120119
private measureTime: boolean;
120+
private performance: any;
121121
private startAt: number = 0;
122122
constructor(options?: Partial<Options>) {
123123
options = options || ({} as Options);
@@ -186,6 +186,10 @@ class ForkTsCheckerWebpackPlugin {
186186

187187
this.vue = options.vue === true; // default false
188188
this.measureTime = options.measureCompilationTime === true;
189+
if (this.measureTime) {
190+
// Node 8+ only
191+
this.performance = require('perf_hooks').performance;
192+
}
189193
}
190194

191195
private validateVersions() {
@@ -362,7 +366,7 @@ class ForkTsCheckerWebpackPlugin {
362366

363367
try {
364368
if (this.measureTime) {
365-
this.startAt = performance.now();
369+
this.startAt = this.performance.now();
366370
}
367371
this.service!.send(this.cancellationToken);
368372
} catch (error) {
@@ -625,7 +629,7 @@ class ForkTsCheckerWebpackPlugin {
625629

626630
private handleServiceMessage(message: Message): void {
627631
if (this.measureTime) {
628-
const delta = performance.now() - this.startAt;
632+
const delta = this.performance.now() - this.startAt;
629633
this.logger.info(`compilation took: ${delta} ms.`);
630634
}
631635
if (this.cancellationToken) {

src/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"skipLibCheck": true,
88
"suppressImplicitAnyIndexErrors": true,
99
"strict": true,
10-
"lib": ["es2015", "es2016.array.include", "dom"],
10+
"lib": ["es2015", "es2016.array.include"],
1111
"module": "commonjs",
1212
"moduleResolution": "node",
1313
"declaration": true,

0 commit comments

Comments
 (0)