Skip to content

Commit

Permalink
fix: set types declarationDir based on cwd (developit#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
katywings committed Jun 2, 2020
1 parent 436498f commit ac307a8
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,21 @@ async function getOutput({ cwd, output, pkgMain, pkgName }) {
return main;
}

function getDeclarationDir({ options, pkg }) {
const { cwd, output } = options;

let result = output;

if (pkg.types || pkg.typings) {
result = pkg.types || pkg.typings;
result = resolve(cwd, result);
}

result = dirname(result);

return result;
}

async function getEntries({ input, cwd }) {
let entries = (
await map([].concat(input), async file => {
Expand Down Expand Up @@ -567,9 +582,7 @@ function createConfig(options, entry, format, writeMeta) {
compilerOptions: {
sourceMap: options.sourcemap,
declaration: true,
declarationDir: dirname(
pkg.types || pkg.typings || options.output,
),
declarationDir: getDeclarationDir({ options, pkg }),
jsx: 'react',
jsxFactory:
// TypeScript fails to resolve Fragments when jsxFactory
Expand Down

0 comments on commit ac307a8

Please sign in to comment.