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

fix: normalize paths in get-options-overrides #331

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions __tests__/get-options-overrides.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { getOptionsOverrides, createFilter } from "../src/get-options-overrides"

setTypescriptModule(ts);

const local = (x: string) => path.resolve(__dirname, x);
const local = (x: string) => normalize(path.resolve(__dirname, x));
const cacheDir = local("__temp/get-options-overrides");

// filter expects an absolute path and resolves include/exclude to process.cwd() by default: https://github.com/ezolenko/rollup-plugin-typescript2/pull/321#discussion_r873077874
Expand Down Expand Up @@ -51,7 +51,7 @@ const forcedOptions: ts.CompilerOptions = {
noEmit: false,
noEmitHelpers: false,
noResolve: false,
outDir: `${cacheDir}/placeholder`, // TODO: fix get-options-overrides.ts on Windows by normalizing the path: https://github.com/ezolenko/rollup-plugin-typescript2/pull/321#discussion_r869710856
outDir: `${cacheDir}/placeholder`,
};

const defaultPreParsedTsConfig: ts.ParsedCommandLine = {
Expand Down
10 changes: 5 additions & 5 deletions src/get-options-overrides.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { createFilter as createRollupFilter} from "@rollup/pluginutils";
import { createFilter as createRollupFilter, normalizePath as normalize } from "@rollup/pluginutils";
import { tsModule } from "./tsproxy";
import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
import { join } from "path";
import * as path from "path";
import { IContext } from "./context";

export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, preParsedTsconfig?: tsTypes.ParsedCommandLine): tsTypes.CompilerOptions
Expand All @@ -13,7 +13,7 @@ export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IO
noResolve: false,
noEmit: false,
inlineSourceMap: false,
outDir: `${cacheRoot}/placeholder`, // need an outdir that is different from source or tsconfig parsing trips up. https://github.com/Microsoft/TypeScript/issues/24715
outDir: normalize(`${cacheRoot}/placeholder`), // need an outdir that is different from source or tsconfig parsing trips up. https://github.com/Microsoft/TypeScript/issues/24715
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
allowNonTsExtensions: true,
};
Expand Down Expand Up @@ -42,9 +42,9 @@ function expandIncludeWithDirs(include: string | string[], dirs: string[])

dirs.forEach(root => {
if (include instanceof Array)
include.forEach(x => newDirs.push(join(root, x)));
include.forEach(x => newDirs.push(normalize(path.join(root, x))));
else
newDirs.push(join(root, include));
newDirs.push(normalize(path.join(root, include)));
});
return newDirs;
}
Expand Down