Skip to content

Commit 4802585

Browse files
authored
Bug: TS fixes (#341)
- Move types to `pluing/types.d.ts` - Update plugin signature to webpack 5 inclusive format - Add webpack type check to `check-ts` - Add `yarn dev-ts` TS-based configuration example to our examples...
1 parent 8a725a4 commit 4802585

File tree

7 files changed

+149
-27
lines changed

7 files changed

+149
-27
lines changed

.github/workflows/ci.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
name: CI
22

3-
on: [push]
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
410

511
jobs:
612
build:

CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# Changelog
22

3-
This project adheres to [Semantic Versioning](http://semver.org/).
3+
## UNRELEASED
4+
5+
- Bug: Move plugin types and update to webpack v5. [#324](https://github.com/FormidableLabs/webpack-dashboard/issues/324)
46

57
## 3.3.6
68

examples/config/webpack.config.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* No-op build with TS config to see if webpack-cli bombs out.
3+
*/
4+
5+
import DashboardPlugin from '../../plugin';
6+
7+
import * as path from 'path';
8+
import * as webpack from 'webpack';
9+
const webpackVers = webpack.version;
10+
11+
const cwd = `${process.cwd()}/examples/${process.env.EXAMPLE}`;
12+
if (!process.env.EXAMPLE) {
13+
throw new Error("EXAMPLE is required");
14+
}
15+
16+
const mode = process.env.WEBPACK_MODE || "development";
17+
18+
const config: webpack.Configuration = {
19+
mode: 'development',
20+
entry: {
21+
bundle: "./src/index.js"
22+
},
23+
context: path.resolve(cwd),
24+
output: {
25+
path: path.resolve(cwd, `dist-ts-${mode}-${webpackVers}`),
26+
pathinfo: true,
27+
filename: "[name].js"
28+
},
29+
devtool: false,
30+
plugins: [
31+
new DashboardPlugin()
32+
]
33+
};
34+
35+
export default config;

index.d.ts

-24
This file was deleted.

package.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
"lint": "eslint .",
1515
"check": "run-s format-check lint test check-ts",
1616
"check-ci": "run-s format-check lint test-cov check-ts",
17-
"check-ts": "tsc index.d.ts --noEmit",
17+
"check-ts": "tsc plugin/index.d.ts examples/config/webpack.config.ts --noEmit",
1818
"dev": "cross-env EXAMPLE=duplicates-esm node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.js --watch",
19+
"dev-ts": "cross-env EXAMPLE=duplicates-esm node bin/webpack-dashboard.js -- webpack-cli --config examples/config/webpack.config.ts --watch",
1920
"format": "prettier --write \"./{bin,examples,plugin,test,utils}/**/*.js\"",
2021
"format-check": "prettier --list-different \"./{bin,examples,plugin,test,utils}/**/*.js\""
2122
},
@@ -67,6 +68,7 @@
6768
"prettier": "^2.3.2",
6869
"sinon": "^11.1.1",
6970
"sinon-chai": "^3.7.0",
71+
"ts-node": "^10.4.0",
7072
"typescript": "^4.3.5",
7173
"webpack": "^5.44.0",
7274
"webpack-cli": "^4.7.2",

plugin/index.d.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
interface IMessage {
2+
type: string;
3+
value: string | number | { [key: string]: any }
4+
error?: boolean;
5+
}
6+
7+
interface IDashboardOptions {
8+
port?: number;
9+
host?: string;
10+
handler?: (dataArray: IMessage[]) => void;
11+
}
12+
13+
interface ICompiler {
14+
hooks?: any;
15+
plugin?: (name: string, callback: () => void) => void;
16+
}
17+
18+
export default class DashboardPlugin {
19+
constructor(options?: IDashboardOptions);
20+
apply(compiler: ICompiler): void;
21+
}

yarn.lock

+80
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,18 @@
208208
"@babel/helper-validator-identifier" "^7.14.5"
209209
to-fast-properties "^2.0.0"
210210

211+
"@cspotcode/[email protected]":
212+
version "0.8.0"
213+
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-consumer/-/source-map-consumer-0.8.0.tgz#33bf4b7b39c178821606f669bbc447a6a629786b"
214+
integrity sha512-41qniHzTU8yAGbCp04ohlmSrZf8bkf/iJsl3V0dRGsQN/5GFfx+LbCSsCpp2gqrqjTVg/K6O8ycoV35JIwAzAg==
215+
216+
"@cspotcode/[email protected]":
217+
version "0.7.0"
218+
resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.7.0.tgz#4789840aa859e46d2f3173727ab707c66bf344f5"
219+
integrity sha512-X4xqRHqN8ACt2aHVe51OxeA2HjbcL4MqFqXkrmQszJ1NOUuUu5u6Vqx/0lZSVNku7velL5FC/s5uEAj1lsBMhA==
220+
dependencies:
221+
"@cspotcode/source-map-consumer" "0.8.0"
222+
211223
"@discoveryjs/json-ext@^0.5.0":
212224
version "0.5.3"
213225
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.3.tgz#90420f9f9c6d3987f176a19a7d8e764271a2f55d"
@@ -291,6 +303,26 @@
291303
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-1.1.2.tgz#ccb91445360179a04e7fe6aff78c00ffc1eeaf82"
292304
integrity sha512-RbzJvlNzmRq5c3O09UipeuXno4tA1FE6ikOjxZK0tuxVv3412l64l5t1W5pj4+rJq9vpkm/kwiR07aZXnsKPxw==
293305

306+
"@tsconfig/node10@^1.0.7":
307+
version "1.0.8"
308+
resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.8.tgz#c1e4e80d6f964fbecb3359c43bd48b40f7cadad9"
309+
integrity sha512-6XFfSQmMgq0CFLY1MslA/CPUfhIL919M1rMsa5lP2P097N2Wd1sSX0tx1u4olM16fLNhtHZpRhedZJphNJqmZg==
310+
311+
"@tsconfig/node12@^1.0.7":
312+
version "1.0.9"
313+
resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.9.tgz#62c1f6dee2ebd9aead80dc3afa56810e58e1a04c"
314+
integrity sha512-/yBMcem+fbvhSREH+s14YJi18sp7J9jpuhYByADT2rypfajMZZN4WQ6zBGgBKp53NKmqI36wFYDb3yaMPurITw==
315+
316+
"@tsconfig/node14@^1.0.0":
317+
version "1.0.1"
318+
resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.1.tgz#95f2d167ffb9b8d2068b0b235302fafd4df711f2"
319+
integrity sha512-509r2+yARFfHHE7T6Puu2jjkoycftovhXRqW328PDXTVGKihlb1P8Z9mMZH04ebyajfRY7dedfGynlrFHJUQCg==
320+
321+
"@tsconfig/node16@^1.0.2":
322+
version "1.0.2"
323+
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
324+
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==
325+
294326
"@types/component-emitter@^1.2.10":
295327
version "1.2.10"
296328
resolved "https://registry.yarnpkg.com/@types/component-emitter/-/component-emitter-1.2.10.tgz#ef5b1589b9f16544642e473db5ea5639107ef3ea"
@@ -503,6 +535,11 @@ acorn-jsx@^5.3.1:
503535
resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-5.3.2.tgz#7ed5bb55908b3b2f1bc55c6af1653bada7f07937"
504536
integrity sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==
505537

538+
acorn-walk@^8.1.1:
539+
version "8.2.0"
540+
resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1"
541+
integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==
542+
506543
acorn@^7.4.0:
507544
version "7.4.1"
508545
resolved "https://registry.yarnpkg.com/acorn/-/acorn-7.4.1.tgz#feaed255973d2e77555b83dbc08851a6c63520fa"
@@ -602,6 +639,11 @@ archy@^1.0.0:
602639
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
603640
integrity sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=
604641

642+
arg@^4.1.0:
643+
version "4.1.3"
644+
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
645+
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
646+
605647
argparse@^1.0.7:
606648
version "1.0.10"
607649
resolved "https://registry.yarnpkg.com/argparse/-/argparse-1.0.10.tgz#bcd6791ea5ae09725e17e5ad988134cd40b3d911"
@@ -936,6 +978,11 @@ cors@~2.8.5:
936978
object-assign "^4"
937979
vary "^1"
938980

981+
create-require@^1.1.0:
982+
version "1.1.1"
983+
resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333"
984+
integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==
985+
939986
cross-env@^7.0.3:
940987
version "7.0.3"
941988
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
@@ -1032,6 +1079,11 @@ [email protected], diff@^5.0.0:
10321079
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
10331080
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
10341081

1082+
diff@^4.0.1:
1083+
version "4.0.2"
1084+
resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d"
1085+
integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==
1086+
10351087
doctrine@^2.1.0:
10361088
version "2.1.0"
10371089
resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d"
@@ -2146,6 +2198,11 @@ make-dir@^3.0.0, make-dir@^3.0.2:
21462198
dependencies:
21472199
semver "^6.0.0"
21482200

2201+
make-error@^1.1.1:
2202+
version "1.3.6"
2203+
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
2204+
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
2205+
21492206
memorystream@^0.3.1:
21502207
version "0.3.1"
21512208
resolved "https://registry.yarnpkg.com/memorystream/-/memorystream-0.3.1.tgz#86d7090b30ce455d63fbae12dda51a47ddcaf9b2"
@@ -3151,6 +3208,24 @@ to-regex-range@^5.0.1:
31513208
dependencies:
31523209
is-number "^7.0.0"
31533210

3211+
ts-node@^10.4.0:
3212+
version "10.4.0"
3213+
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.4.0.tgz#680f88945885f4e6cf450e7f0d6223dd404895f7"
3214+
integrity sha512-g0FlPvvCXSIO1JDF6S232P5jPYqBkRL9qly81ZgAOSU7rwI0stphCgd2kLiCrU9DjQCrJMWEqcNSjQL02s6d8A==
3215+
dependencies:
3216+
"@cspotcode/source-map-support" "0.7.0"
3217+
"@tsconfig/node10" "^1.0.7"
3218+
"@tsconfig/node12" "^1.0.7"
3219+
"@tsconfig/node14" "^1.0.0"
3220+
"@tsconfig/node16" "^1.0.2"
3221+
acorn "^8.4.1"
3222+
acorn-walk "^8.1.1"
3223+
arg "^4.1.0"
3224+
create-require "^1.1.0"
3225+
diff "^4.0.1"
3226+
make-error "^1.1.1"
3227+
yn "3.1.1"
3228+
31543229
tsconfig-paths@^3.9.0:
31553230
version "3.10.1"
31563231
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.10.1.tgz#79ae67a68c15289fdf5c51cb74f397522d795ed7"
@@ -3499,6 +3574,11 @@ [email protected]:
34993574
resolved "https://registry.yarnpkg.com/yeast/-/yeast-0.1.2.tgz#008e06d8094320c372dbc2f8ed76a0ca6c8ac419"
35003575
integrity sha1-AI4G2AlDIMNy28L47XagymyKxBk=
35013576

3577+
3578+
version "3.1.1"
3579+
resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50"
3580+
integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==
3581+
35023582
yocto-queue@^0.1.0:
35033583
version "0.1.0"
35043584
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"

0 commit comments

Comments
 (0)