Skip to content

Commit d289d3f

Browse files
committed
- outDir placeholder other than cwd, fix for #83
1 parent b9a93eb commit d289d3f

10 files changed

+24
-35
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ The plugin inherits all compiler options and file lists from your `tsconfig.json
3636
* `noResolve`: false
3737
* `noEmit`: false
3838
* `inlineSourceMap`: false (see [#71](https://github.com/ezolenko/rollup-plugin-typescript2/issues/71))
39-
* `outDir`: `process.cwd()`
39+
* `outDir`: `./placeholder` in cache root, see [83](https://github.com/ezolenko/rollup-plugin-typescript2/issues/83) and [Microsoft/TypeScript/issues/24715](https://github.com/Microsoft/TypeScript/issues/24715)
4040
* `declarationDir`: `process.cwd()` (*only if `useTsconfigDeclarationDir` is false in the plugin options*)
4141
* `moduleResolution`: `node` (*`classic` is [deprecated](https://www.typescriptlang.org/docs/handbook/module-resolution.html). It also breaks this plugin, see [#12](https://github.com/ezolenko/rollup-plugin-typescript2/issues/12) and [#14](https://github.com/ezolenko/rollup-plugin-typescript2/issues/14)*)
4242

dist/get-options-overrides.d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import * as tsTypes from "typescript";
22
import { IOptions } from "./ioptions";
3-
export declare function getOptionsOverrides({ useTsconfigDeclarationDir }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions;
3+
export declare function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions;

dist/rollup-plugin-typescript2.cjs.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -19938,14 +19938,14 @@ function printDiagnostics(context, diagnostics, pretty) {
1993819938
}
1993919939

1994019940
function getOptionsOverrides(_a, tsConfigJson) {
19941-
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir;
19941+
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir, cacheRoot = _a.cacheRoot;
1994219942
var overrides = {
1994319943
noEmitHelpers: false,
1994419944
importHelpers: true,
1994519945
noResolve: false,
1994619946
noEmit: false,
1994719947
inlineSourceMap: false,
19948-
outDir: process.cwd(),
19948+
outDir: cacheRoot + "/placeholder",
1994919949
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
1995019950
};
1995119951
var declaration = lodash_1(tsConfigJson, "compilerOptions.declaration", false);
@@ -20069,7 +20069,7 @@ function typescript(options) {
2006920069
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
2007020070
context.info("typescript version: " + tsModule.version);
2007120071
context.info("tslib version: " + tslibVersion);
20072-
context.info("rollup-plugin-typescript2 version: 0.14.1");
20072+
context.info("rollup-plugin-typescript2 version: 0.15.0");
2007320073
context.debug(function () { return "plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4); });
2007420074
context.debug(function () { return "rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4); });
2007520075
watchMode = process.env.ROLLUP_WATCH === "true";
@@ -20228,7 +20228,6 @@ function typescript(options) {
2022820228
declarations[key] = dts;
2022920229
});
2023020230
var bundleFile_1 = file ? file : dest; // rollup 0.48+ has 'file' https://github.com/rollup/rollup/issues/1479
20231-
var baseDeclarationDir_1 = parsedConfig.options.outDir;
2023220231
lodash_2(declarations, function (_a, key) {
2023320232
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
2023420233
var writeToPath;
@@ -20239,8 +20238,8 @@ function typescript(options) {
2023920238
else {
2024020239
// Otherwise, take the directory name from the path and make sure it is absolute.
2024120240
var destDirname = path.dirname(bundleFile_1);
20242-
var destDirectory = path.isAbsolute(bundleFile_1) ? destDirname : path.join(process.cwd(), destDirname);
20243-
writeToPath = path.join(destDirectory, path.relative(baseDeclarationDir_1, name));
20241+
var destDirectory = path.isAbsolute(destDirname) ? destDirname : path.join(process.cwd(), destDirname);
20242+
writeToPath = path.join(destDirectory, path.relative(process.cwd(), name));
2024420243
}
2024520244
context.debug(function () { return safe_5("writing declarations") + " for '" + key + "' to '" + writeToPath + "'"; });
2024620245
// Write the declaration file to disk.

dist/rollup-plugin-typescript2.cjs.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rollup-plugin-typescript2.es.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -19934,14 +19934,14 @@ function printDiagnostics(context, diagnostics, pretty) {
1993419934
}
1993519935

1993619936
function getOptionsOverrides(_a, tsConfigJson) {
19937-
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir;
19937+
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir, cacheRoot = _a.cacheRoot;
1993819938
var overrides = {
1993919939
noEmitHelpers: false,
1994019940
importHelpers: true,
1994119941
noResolve: false,
1994219942
noEmit: false,
1994319943
inlineSourceMap: false,
19944-
outDir: process.cwd(),
19944+
outDir: cacheRoot + "/placeholder",
1994519945
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
1994619946
};
1994719947
var declaration = lodash_1(tsConfigJson, "compilerOptions.declaration", false);
@@ -20065,7 +20065,7 @@ function typescript(options) {
2006520065
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
2006620066
context.info("typescript version: " + tsModule.version);
2006720067
context.info("tslib version: " + tslibVersion);
20068-
context.info("rollup-plugin-typescript2 version: 0.14.1");
20068+
context.info("rollup-plugin-typescript2 version: 0.15.0");
2006920069
context.debug(function () { return "plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4); });
2007020070
context.debug(function () { return "rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4); });
2007120071
watchMode = process.env.ROLLUP_WATCH === "true";
@@ -20224,7 +20224,6 @@ function typescript(options) {
2022420224
declarations[key] = dts;
2022520225
});
2022620226
var bundleFile_1 = file ? file : dest; // rollup 0.48+ has 'file' https://github.com/rollup/rollup/issues/1479
20227-
var baseDeclarationDir_1 = parsedConfig.options.outDir;
2022820227
lodash_2(declarations, function (_a, key) {
2022920228
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
2023020229
var writeToPath;
@@ -20235,8 +20234,8 @@ function typescript(options) {
2023520234
else {
2023620235
// Otherwise, take the directory name from the path and make sure it is absolute.
2023720236
var destDirname = dirname(bundleFile_1);
20238-
var destDirectory = isAbsolute(bundleFile_1) ? destDirname : join(process.cwd(), destDirname);
20239-
writeToPath = join(destDirectory, relative(baseDeclarationDir_1, name));
20237+
var destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
20238+
writeToPath = join(destDirectory, relative(process.cwd(), name));
2024020239
}
2024120240
context.debug(function () { return safe_5("writing declarations") + " for '" + key + "' to '" + writeToPath + "'"; });
2024220241
// Write the declaration file to disk.

dist/rollup-plugin-typescript2.es.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

+5-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rollup-plugin-typescript2",
3-
"version": "0.14.1",
3+
"version": "0.15.0",
44
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
55
"main": "dist/rollup-plugin-typescript2.cjs.js",
66
"module": "dist/rollup-plugin-typescript2.es.js",

src/get-options-overrides.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@ import * as tsTypes from "typescript";
33
import { IOptions } from "./ioptions";
44
import * as _ from "lodash";
55

6-
export function getOptionsOverrides({ useTsconfigDeclarationDir }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions
6+
export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions
77
{
88
const overrides = {
99
noEmitHelpers: false,
1010
importHelpers: true,
1111
noResolve: false,
1212
noEmit: false,
1313
inlineSourceMap: false,
14-
outDir: process.cwd(),
14+
outDir: `${cacheRoot}/placeholder`, // need an outdir that is different from source or tsconfig parsing trips up. https://github.com/Microsoft/TypeScript/issues/24715
1515
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
1616
};
1717

src/index.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ export default function typescript(options?: Partial<IOptions>)
316316

317317
const bundleFile = file ? file : dest; // rollup 0.48+ has 'file' https://github.com/rollup/rollup/issues/1479
318318

319-
const baseDeclarationDir = parsedConfig.options.outDir;
320319
_.each(declarations, ({ name, text, writeByteOrderMark }, key) =>
321320
{
322321
let writeToPath: string;
@@ -328,8 +327,8 @@ export default function typescript(options?: Partial<IOptions>)
328327
{
329328
// Otherwise, take the directory name from the path and make sure it is absolute.
330329
const destDirname = dirname(bundleFile);
331-
const destDirectory = isAbsolute(bundleFile) ? destDirname : join(process.cwd(), destDirname);
332-
writeToPath = join(destDirectory, relative(baseDeclarationDir!, name));
330+
const destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
331+
writeToPath = join(destDirectory, relative(process.cwd(), name));
333332
}
334333

335334
context.debug(() => `${blue("writing declarations")} for '${key}' to '${writeToPath}'`);

0 commit comments

Comments
 (0)