Skip to content

Commit a1b19a1

Browse files
ulivzjohnnyreilly
andauthored
feat: remove top-level typescript import statements (#1259)
* feat: remove top-level typescript import statements * Update package.json * Update CHANGELOG.md Co-authored-by: John Reilly <[email protected]>
1 parent 656d6b8 commit a1b19a1

10 files changed

+18
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## v8.1.0
4+
* [feat: remove top-level typescript import statements](https://github.com/TypeStrong/ts-loader/pull/1259) - thanks @ulivz
5+
36
## v8.0.18
47
* [Perf: Optimize fileExists callback path](https://github.com/TypeStrong/ts-loader/issues/1266) - thanks @berickson1
58

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ts-loader",
3-
"version": "8.0.18",
3+
"version": "8.1.0",
44
"description": "TypeScript loader for webpack",
55
"main": "index.js",
66
"types": "dist",

src/after-compile.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import * as ts from 'typescript';
2+
import type * as ts from 'typescript';
33
import * as webpack from 'webpack';
44

55
import * as constants from './constants';

src/compilerSetup.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as semver from 'semver';
2-
import * as typescript from 'typescript';
2+
import type * as typescript from 'typescript';
33

44
import { LoaderOptions } from './interfaces';
55
import * as logger from './logger';
@@ -52,7 +52,8 @@ export function getCompiler(loaderOptions: LoaderOptions, log: logger.Logger) {
5252
}
5353

5454
export function getCompilerOptions(
55-
configParseResult: typescript.ParsedCommandLine
55+
configParseResult: typescript.ParsedCommandLine,
56+
compiler: typeof typescript
5657
) {
5758
const compilerOptions = Object.assign({}, configParseResult.options, {
5859
skipLibCheck: true,
@@ -63,9 +64,9 @@ export function getCompilerOptions(
6364
if (
6465
compilerOptions.module === undefined &&
6566
compilerOptions.target !== undefined &&
66-
compilerOptions.target < typescript.ScriptTarget.ES2015
67+
compilerOptions.target < compiler.ScriptTarget.ES2015
6768
) {
68-
compilerOptions.module = typescript.ModuleKind.CommonJS;
69+
compilerOptions.module = compiler.ModuleKind.CommonJS;
6970
}
7071

7172
if (configParseResult.options.configFile) {

src/config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Chalk } from 'chalk';
22
import * as path from 'path';
3-
import * as typescript from 'typescript';
3+
import type * as typescript from 'typescript';
44
import * as webpack from 'webpack';
55

66
import { getCompilerOptions } from './compilerSetup';
@@ -187,7 +187,7 @@ export function getParsedCommandLine(
187187
extendedConfigCache
188188
);
189189
if (result) {
190-
result.options = getCompilerOptions(result);
190+
result.options = getCompilerOptions(result, compiler);
191191
}
192192
return result;
193193
}

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as crypto from 'crypto';
22
import * as loaderUtils from 'loader-utils';
33
import * as path from 'path';
4-
import * as typescript from 'typescript';
4+
import type * as typescript from 'typescript';
55
import * as webpack from 'webpack';
66

77
import * as constants from './constants';

src/instances.ts

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

77
import { makeAfterCompile } from './after-compile';
@@ -202,7 +202,7 @@ function successfulTypeScriptInstance(
202202
};
203203
}
204204

205-
const compilerOptions = getCompilerOptions(configParseResult);
205+
const compilerOptions = getCompilerOptions(configParseResult, compiler);
206206
const rootFileNames = new Set<string>();
207207
const files: TSFiles = new Map();
208208
const otherFiles: TSFiles = new Map();

src/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as typescript from 'typescript';
1+
import type * as typescript from 'typescript';
22

33
import { Chalk } from 'chalk';
44
import * as logger from './logger';

src/servicesHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import * as typescript from 'typescript';
2+
import type * as typescript from 'typescript';
33
import * as webpack from 'webpack';
44
import { getParsedCommandLine } from './config';
55
import * as constants from './constants';

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Chalk } from 'chalk';
22
import * as fs from 'fs';
33
import * as micromatch from 'micromatch';
44
import * as path from 'path';
5-
import * as typescript from 'typescript';
5+
import type * as typescript from 'typescript';
66

77
import constants = require('./constants');
88
import {

0 commit comments

Comments
 (0)