Skip to content

Commit 4ef274d

Browse files
committed
webpack typescript type stuff
1 parent df6b68b commit 4ef274d

6 files changed

Lines changed: 14 additions & 42 deletions

File tree

package-lock.json

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/scripts/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"@test-it/cli": "^0.8.0",
1414
"@test-it/core": "^0.8.0",
1515
"@types/lodash.debounce": "^4.0.9",
16-
"@types/webpack": "^5.28.5",
1716
"aseprite-loader": "^0.1.3",
1817
"babel-loader": "^9.1.3",
1918
"bmfont-loader": "^0.2.0",

packages/scripts/src/commands/build.ts

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,21 @@ export default async function build(options: { lib?: string; title?: string }) {
2323
title: options.title,
2424
});
2525

26-
// @ts-ignore
2726
const compiler = webpack(webpackConfig);
2827
return new Promise<void>((resolve, reject) => {
29-
compiler.run((err: any, stats: any) => {
30-
let messages;
28+
compiler.run((err, stats) => {
3129
if (err != null) {
32-
messages = {
33-
errors: [err],
34-
warnings: [],
35-
};
36-
} else {
37-
messages = stats.toJson({
38-
all: false,
39-
warnings: true,
40-
errors: true,
41-
});
30+
console.error(chalk.red(err));
31+
return reject(err);
4232
}
4333

44-
if (messages.errors.length > 0) {
34+
const messages = stats!.toJson({
35+
all: false,
36+
warnings: true,
37+
errors: true,
38+
});
39+
40+
if (messages.errors && messages.errors.length > 0) {
4541
for (const error of messages.errors) {
4642
console.error(chalk.red(error));
4743
}
@@ -52,6 +48,7 @@ export default async function build(options: { lib?: string; title?: string }) {
5248
process.env.CI &&
5349
(typeof process.env.CI !== "string" ||
5450
process.env.CI.toLowerCase() !== "false") &&
51+
messages.warnings &&
5552
messages.warnings.length > 0
5653
) {
5754
console.log(

packages/scripts/src/makeWebpackConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const makeWebpackConfig = ({
3838
outDir: string;
3939
library?: string;
4040
title?: string;
41-
}) => {
41+
}): webpack.Configuration => {
4242
const htmlWebpackPluginOptions: { [key: string]: any } = {
4343
title: title || "hex-engine game",
4444
};

packages/scripts/src/test-it-loader.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,6 @@ export function load(filename: string): string {
6666
case ".tsx": {
6767
let config;
6868
if (filename.match(/node_modules/)) {
69-
// We need to always compile ESM to CJS, because @hex-engine
70-
// packages are published with ESM, but test-it can't run
71-
// ESM unless the loader compiles it to CJS. Its default loader
72-
// compiles ESM to CJS, but not for node_modules (for speed).
73-
//
74-
// The reason @hex-engine packages are published with ESM
75-
// is because it allows webpack to treeshake unused named
76-
// exports, which reduces the size of published games
77-
// drastically, because it removes unused component functions.
78-
//
79-
// We could relax this to only compile node_modules/@hex-engine,
80-
// but I want third-party hex-engine component libraries to be
81-
// able to benefit from tree-shaking, too.
8269
config = {
8370
compact: true,
8471
plugins: ["@babel/plugin-transform-modules-commonjs"],

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"./node_modules/aseprite-loader/index.d.ts",
44
"./node_modules/xml-source-loader/index.d.ts",
55
"./node_modules/bmfont-loader/index.d.ts",
6-
"./packages/scripts/node_modules/@test-it/core/globals.d.ts",
6+
"./node_modules/@test-it/core/globals.d.ts",
77
"./ts-webpack.ts"
88
],
99
"include": ["./packages/**/*.ts", "./packages/**/*.tsx"],
@@ -17,6 +17,7 @@
1717
"lib": ["es2019", "dom"],
1818
"target": "es2015",
1919
"module": "ES2015",
20+
"skipLibCheck": true,
2021
"outDir": "./dist",
2122

2223
"strict": true,

0 commit comments

Comments
 (0)