Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: combine check-tsconfig with parse-tsconfig #413

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -66,7 +66,7 @@ It can also be useful to review some issues and have a "goal" in mind (especiall
Once you have some understanding of the codebase's main workflow, you can start to dive deeper into pieces that require more domain knowledge.<br />
A useful resource as you dive deeper are the [unit tests](__tests__/). They're good to look through as you dig into a module to understand how it's used.

1. From here, you can start to read more of the modules that integrate with the TypeScript API, such as [`host`](src/host.ts), [`parse-tsconfig`](src/parse-tsconfig.ts), [`check-tsconfig`](src/check-tsconfig.ts), and maybe how TS is imported in [`tsproxy`](src/tsproxy.ts) and [`tslib`](src/tslib.ts)
1. From here, you can start to read more of the modules that integrate with the TypeScript API, such as [`host`](src/host.ts) and [`parse-tsconfig`](src/parse-tsconfig.ts), and maybe how TS is imported in [`tsproxy`](src/tsproxy.ts) and [`tslib`](src/tslib.ts)
- A _very_ useful reference here is the [TypeScript Wiki](https://github.com/microsoft/TypeScript/wiki), which has two main articles that are the basis for most Compiler integrations:
- [Using the Compiler API](https://github.com/microsoft/TypeScript/wiki/Using-the-Compiler-API)
- [Using the Language Service API](https://github.com/microsoft/TypeScript/wiki/Using-the-Language-Service-API)
Expand Down
33 changes: 0 additions & 33 deletions __tests__/check-tsconfig.spec.ts

This file was deleted.

7 changes: 7 additions & 0 deletions __tests__/parse-tsconfig.spec.ts
Expand Up @@ -14,6 +14,13 @@ test("parseTsConfig", () => {
expect(() => parseTsConfig(makeContext(), defaultOpts)).not.toThrow();
});

test("parseTsConfig - incompatible module", () => {
expect(() => parseTsConfig(makeContext(), {
...defaultOpts,
tsconfigOverride: { compilerOptions: { module: "none" } },
})).toThrow("Incompatible tsconfig option. Module resolves to 'None'. This is incompatible with Rollup, please use");
});

test("parseTsConfig - tsconfig errors", () => {
const context = makeContext();

Expand Down
11 changes: 0 additions & 11 deletions src/check-tsconfig.ts

This file was deleted.

6 changes: 4 additions & 2 deletions src/parse-tsconfig.ts
Expand Up @@ -7,7 +7,6 @@ import { printDiagnostics } from "./print-diagnostics";
import { convertDiagnostic } from "./tscache";
import { getOptionsOverrides } from "./get-options-overrides";
import { IOptions } from "./ioptions";
import { checkTsConfig } from "./check-tsconfig";

export function parseTsConfig(context: IContext, pluginOptions: IOptions)
{
Expand Down Expand Up @@ -45,7 +44,10 @@ export function parseTsConfig(context: IContext, pluginOptions: IOptions)
const compilerOptionsOverride = getOptionsOverrides(pluginOptions, preParsedTsConfig);
const parsedTsConfig = tsModule.parseJsonConfigFileContent(mergedConfig, tsModule.sys, baseDir, compilerOptionsOverride, configFileName);

checkTsConfig(parsedTsConfig);
const module = parsedTsConfig.options.module!;
if (module !== tsModule.ModuleKind.ES2015 && module !== tsModule.ModuleKind.ES2020 && module !== tsModule.ModuleKind.ESNext)
throw new Error(`rpt2: Incompatible tsconfig option. Module resolves to '${tsModule.ModuleKind[module]}'. This is incompatible with Rollup, please use 'module: "ES2015"', 'module: "ES2020"', or 'module: "ESNext"'.`);

printDiagnostics(context, convertDiagnostic("config", parsedTsConfig.errors), pretty);

context.debug(`built-in options overrides: ${JSON.stringify(compilerOptionsOverride, undefined, 4)}`);
Expand Down