Skip to content

Commit

Permalink
feat: remove top-level typescript import statements (#1259)
Browse files Browse the repository at this point in the history
* feat: remove top-level typescript import statements

* Update package.json

* Update CHANGELOG.md

Co-authored-by: John Reilly <johnny_reilly@hotmail.com>
  • Loading branch information
ulivz and johnnyreilly authored Mar 28, 2021
1 parent 656d6b8 commit a1b19a1
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## v8.1.0
* [feat: remove top-level typescript import statements](https://github.com/TypeStrong/ts-loader/pull/1259) - thanks @ulivz

## v8.0.18
* [Perf: Optimize fileExists callback path](https://github.com/TypeStrong/ts-loader/issues/1266) - thanks @berickson1

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ts-loader",
"version": "8.0.18",
"version": "8.1.0",
"description": "TypeScript loader for webpack",
"main": "index.js",
"types": "dist",
Expand Down
2 changes: 1 addition & 1 deletion src/after-compile.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import * as ts from 'typescript';
import type * as ts from 'typescript';
import * as webpack from 'webpack';

import * as constants from './constants';
Expand Down
9 changes: 5 additions & 4 deletions src/compilerSetup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as semver from 'semver';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';

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

export function getCompilerOptions(
configParseResult: typescript.ParsedCommandLine
configParseResult: typescript.ParsedCommandLine,
compiler: typeof typescript
) {
const compilerOptions = Object.assign({}, configParseResult.options, {
skipLibCheck: true,
Expand All @@ -63,9 +64,9 @@ export function getCompilerOptions(
if (
compilerOptions.module === undefined &&
compilerOptions.target !== undefined &&
compilerOptions.target < typescript.ScriptTarget.ES2015
compilerOptions.target < compiler.ScriptTarget.ES2015
) {
compilerOptions.module = typescript.ModuleKind.CommonJS;
compilerOptions.module = compiler.ModuleKind.CommonJS;
}

if (configParseResult.options.configFile) {
Expand Down
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chalk } from 'chalk';
import * as path from 'path';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';
import * as webpack from 'webpack';

import { getCompilerOptions } from './compilerSetup';
Expand Down Expand Up @@ -187,7 +187,7 @@ export function getParsedCommandLine(
extendedConfigCache
);
if (result) {
result.options = getCompilerOptions(result);
result.options = getCompilerOptions(result, compiler);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as crypto from 'crypto';
import * as loaderUtils from 'loader-utils';
import * as path from 'path';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';
import * as webpack from 'webpack';

import * as constants from './constants';
Expand Down
4 changes: 2 additions & 2 deletions src/instances.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as chalk from 'chalk';
import * as fs from 'fs';
import * as path from 'path';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';
import * as webpack from 'webpack';

import { makeAfterCompile } from './after-compile';
Expand Down Expand Up @@ -202,7 +202,7 @@ function successfulTypeScriptInstance(
};
}

const compilerOptions = getCompilerOptions(configParseResult);
const compilerOptions = getCompilerOptions(configParseResult, compiler);
const rootFileNames = new Set<string>();
const files: TSFiles = new Map();
const otherFiles: TSFiles = new Map();
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as typescript from 'typescript';
import type * as typescript from 'typescript';

import { Chalk } from 'chalk';
import * as logger from './logger';
Expand Down
2 changes: 1 addition & 1 deletion src/servicesHost.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as path from 'path';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';
import * as webpack from 'webpack';
import { getParsedCommandLine } from './config';
import * as constants from './constants';
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Chalk } from 'chalk';
import * as fs from 'fs';
import * as micromatch from 'micromatch';
import * as path from 'path';
import * as typescript from 'typescript';
import type * as typescript from 'typescript';

import constants = require('./constants');
import {
Expand Down

0 comments on commit a1b19a1

Please sign in to comment.