Skip to content

Commit c0aafcc

Browse files
committed
chore: comment some stuff
1 parent e39af9e commit c0aafcc

5 files changed

Lines changed: 158 additions & 288 deletions

File tree

AGENTS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Use `yarn` (not npm).
88

99
## Key commands
1010

11+
Note: test scripts clean test directories first using `git clean -xfd`.
12+
1113
```bash
1214
yarn build # compile src/ → dist/ (tsc --project "./src")
1315
yarn lint # type-check + ESLint (no separate typecheck script)
@@ -43,7 +45,7 @@ yarn comparison-tests -- --save-output --single-test <name> # regenerate o
4345
4446
## Execution tests (`test/execution-tests/`)
4547

46-
Each sub-directory is a mini webpack project with a Karma/Jasmine test suite. The harness compiles the project and **runs the compiled code** — useful for asserting correct runtime behaviour. These are matrix-tested in CI across Node 20/22 and TypeScript 5.x versions.
48+
Each sub-directory is a mini webpack project with a Karma/Jasmine test suite. The harness compiles the project and **runs the compiled code** — useful for asserting correct runtime behaviour. These are matrix-tested in CI across multiple Node and TypeScript versions (see `.github/workflows/push.yml` for the current matrix).
4749

4850
Full docs: [`test/execution-tests/README.md`](test/execution-tests/README.md)
4951

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"ts"
4141
],
4242
"engines": {
43-
"node": ">=18.18.0"
43+
"node": ">=12.0.0"
4444
},
4545
"author": "John Reilly <johnny_reilly@hotmail.com> (https://johnnyreilly.com)",
4646
"contributors": [

src/after-compile.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,15 @@ function provideErrorsToWebpack(
266266
compilation.compiler.context
267267
);
268268

269-
if (!moduleHasErrors(module, instance.isWebpack5)) {
269+
// if (!moduleHasErrors(module, instance.isWebpack5)) {
270270
formattedErrors.forEach(error => {
271271
if (module.addError) {
272272
module.addError(error);
273273
} else {
274274
module.errors.push(error);
275275
}
276276
});
277-
}
277+
// }
278278

279279
compilation.errors.push(...formattedErrors);
280280
});
@@ -336,15 +336,15 @@ function provideSolutionErrorsToWebpack(
336336
compilation.compiler.context
337337
);
338338

339-
if (!moduleHasErrors(module, instance.isWebpack5)) {
339+
// if (!moduleHasErrors(module, instance.isWebpack5)) {
340340
formattedErrors.forEach(error => {
341341
if (module.addError) {
342342
module.addError(error);
343343
} else {
344344
module.errors.push(error);
345345
}
346346
});
347-
}
347+
// }
348348

349349
compilation.errors.push(...formattedErrors);
350350
});
@@ -577,9 +577,9 @@ function isTSLoaderModuleError(error: any, loaderOptions: LoaderOptions) {
577577
);
578578
}
579579

580-
function moduleHasErrors(module: webpack.Module, isWebpack5: boolean) {
581-
return isWebpack5
582-
? Array.from(module.getErrors!() || []).length > 0
583-
: (((module as any).errors as webpack.WebpackError[] | undefined) || [])
584-
.length > 0;
585-
}
580+
// function moduleHasErrors(module: webpack.Module, isWebpack5: boolean) {
581+
// return isWebpack5
582+
// ? Array.from(module.getErrors!() || []).length > 0
583+
// : (((module as any).errors as webpack.WebpackError[] | undefined) || [])
584+
// .length > 0;
585+
// }

src/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as crypto from 'crypto';
22
import * as path from 'path';
33
import type * as typescript from 'typescript';
4-
import type * as webpack from 'webpack';
4+
import * as webpack from 'webpack';
55

66
import * as constants from './constants';
77
import {
@@ -32,6 +32,8 @@ import { SourceMapConsumer, SourceMapGenerator } from 'source-map';
3232

3333
const loaderOptionsCache: LoaderOptionsCache = {};
3434

35+
const isWebpack5 = webpack.version.startsWith('5.');
36+
3537
/**
3638
* The entry point for ts-loader
3739
*/
@@ -43,7 +45,6 @@ function loader(
4345
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
4446
this.cacheable && this.cacheable();
4547
const callback = this.async();
46-
const isWebpack5 = typeof this.getOptions === 'function';
4748
const options = getLoaderOptions(this, isWebpack5);
4849
const instanceOrError = getTypeScriptInstance(options, this, isWebpack5);
4950

0 commit comments

Comments
 (0)