Skip to content

Commit

Permalink
- outDir placeholder other than cwd, fix for #83
Browse files Browse the repository at this point in the history
  • Loading branch information
ezolenko committed Jun 6, 2018
1 parent b9a93eb commit d289d3f
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 35 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -36,7 +36,7 @@ The plugin inherits all compiler options and file lists from your `tsconfig.json
* `noResolve`: false
* `noEmit`: false
* `inlineSourceMap`: false (see [#71](https://github.com/ezolenko/rollup-plugin-typescript2/issues/71))
* `outDir`: `process.cwd()`
* `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)
* `declarationDir`: `process.cwd()` (*only if `useTsconfigDeclarationDir` is false in the plugin options*)
* `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)*)

Expand Down
2 changes: 1 addition & 1 deletion dist/get-options-overrides.d.ts
@@ -1,3 +1,3 @@
import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
export declare function getOptionsOverrides({ useTsconfigDeclarationDir }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions;
export declare function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions;
11 changes: 5 additions & 6 deletions dist/rollup-plugin-typescript2.cjs.js
Expand Up @@ -19938,14 +19938,14 @@ function printDiagnostics(context, diagnostics, pretty) {
}

function getOptionsOverrides(_a, tsConfigJson) {
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir;
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir, cacheRoot = _a.cacheRoot;
var overrides = {
noEmitHelpers: false,
importHelpers: true,
noResolve: false,
noEmit: false,
inlineSourceMap: false,
outDir: process.cwd(),
outDir: cacheRoot + "/placeholder",
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
};
var declaration = lodash_1(tsConfigJson, "compilerOptions.declaration", false);
Expand Down Expand Up @@ -20069,7 +20069,7 @@ function typescript(options) {
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
context.info("typescript version: " + tsModule.version);
context.info("tslib version: " + tslibVersion);
context.info("rollup-plugin-typescript2 version: 0.14.1");
context.info("rollup-plugin-typescript2 version: 0.15.0");
context.debug(function () { return "plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4); });
context.debug(function () { return "rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4); });
watchMode = process.env.ROLLUP_WATCH === "true";
Expand Down Expand Up @@ -20228,7 +20228,6 @@ function typescript(options) {
declarations[key] = dts;
});
var bundleFile_1 = file ? file : dest; // rollup 0.48+ has 'file' https://github.com/rollup/rollup/issues/1479
var baseDeclarationDir_1 = parsedConfig.options.outDir;
lodash_2(declarations, function (_a, key) {
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
var writeToPath;
Expand All @@ -20239,8 +20238,8 @@ function typescript(options) {
else {
// Otherwise, take the directory name from the path and make sure it is absolute.
var destDirname = path.dirname(bundleFile_1);
var destDirectory = path.isAbsolute(bundleFile_1) ? destDirname : path.join(process.cwd(), destDirname);
writeToPath = path.join(destDirectory, path.relative(baseDeclarationDir_1, name));
var destDirectory = path.isAbsolute(destDirname) ? destDirname : path.join(process.cwd(), destDirname);
writeToPath = path.join(destDirectory, path.relative(process.cwd(), name));
}
context.debug(function () { return safe_5("writing declarations") + " for '" + key + "' to '" + writeToPath + "'"; });
// Write the declaration file to disk.
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.cjs.js.map

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions dist/rollup-plugin-typescript2.es.js
Expand Up @@ -19934,14 +19934,14 @@ function printDiagnostics(context, diagnostics, pretty) {
}

function getOptionsOverrides(_a, tsConfigJson) {
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir;
var useTsconfigDeclarationDir = _a.useTsconfigDeclarationDir, cacheRoot = _a.cacheRoot;
var overrides = {
noEmitHelpers: false,
importHelpers: true,
noResolve: false,
noEmit: false,
inlineSourceMap: false,
outDir: process.cwd(),
outDir: cacheRoot + "/placeholder",
moduleResolution: tsModule.ModuleResolutionKind.NodeJs,
};
var declaration = lodash_1(tsConfigJson, "compilerOptions.declaration", false);
Expand Down Expand Up @@ -20065,7 +20065,7 @@ function typescript(options) {
context = new ConsoleContext(pluginOptions.verbosity, "rpt2: ");
context.info("typescript version: " + tsModule.version);
context.info("tslib version: " + tslibVersion);
context.info("rollup-plugin-typescript2 version: 0.14.1");
context.info("rollup-plugin-typescript2 version: 0.15.0");
context.debug(function () { return "plugin options:\n" + JSON.stringify(pluginOptions, function (key, value) { return key === "typescript" ? "version " + value.version : value; }, 4); });
context.debug(function () { return "rollup config:\n" + JSON.stringify(rollupOptions, undefined, 4); });
watchMode = process.env.ROLLUP_WATCH === "true";
Expand Down Expand Up @@ -20224,7 +20224,6 @@ function typescript(options) {
declarations[key] = dts;
});
var bundleFile_1 = file ? file : dest; // rollup 0.48+ has 'file' https://github.com/rollup/rollup/issues/1479
var baseDeclarationDir_1 = parsedConfig.options.outDir;
lodash_2(declarations, function (_a, key) {
var name = _a.name, text = _a.text, writeByteOrderMark = _a.writeByteOrderMark;
var writeToPath;
Expand All @@ -20235,8 +20234,8 @@ function typescript(options) {
else {
// Otherwise, take the directory name from the path and make sure it is absolute.
var destDirname = dirname(bundleFile_1);
var destDirectory = isAbsolute(bundleFile_1) ? destDirname : join(process.cwd(), destDirname);
writeToPath = join(destDirectory, relative(baseDeclarationDir_1, name));
var destDirectory = isAbsolute(destDirname) ? destDirname : join(process.cwd(), destDirname);
writeToPath = join(destDirectory, relative(process.cwd(), name));
}
context.debug(function () { return safe_5("writing declarations") + " for '" + key + "' to '" + writeToPath + "'"; });
// Write the declaration file to disk.
Expand Down
2 changes: 1 addition & 1 deletion dist/rollup-plugin-typescript2.es.js.map

Large diffs are not rendered by default.

18 changes: 5 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "rollup-plugin-typescript2",
"version": "0.14.1",
"version": "0.15.0",
"description": "Seamless integration between Rollup and TypeScript. Now with errors.",
"main": "dist/rollup-plugin-typescript2.cjs.js",
"module": "dist/rollup-plugin-typescript2.es.js",
Expand Down
4 changes: 2 additions & 2 deletions src/get-options-overrides.ts
Expand Up @@ -3,15 +3,15 @@ import * as tsTypes from "typescript";
import { IOptions } from "./ioptions";
import * as _ from "lodash";

export function getOptionsOverrides({ useTsconfigDeclarationDir }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions
export function getOptionsOverrides({ useTsconfigDeclarationDir, cacheRoot }: IOptions, tsConfigJson?: any): tsTypes.CompilerOptions
{
const overrides = {
noEmitHelpers: false,
importHelpers: true,
noResolve: false,
noEmit: false,
inlineSourceMap: false,
outDir: process.cwd(),
outDir: `${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,
};

Expand Down
5 changes: 2 additions & 3 deletions src/index.ts
Expand Up @@ -316,7 +316,6 @@ export default function typescript(options?: Partial<IOptions>)

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

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

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

0 comments on commit d289d3f

Please sign in to comment.