From a18424ab8a19e5272396ecd3bce349c58d4fbcd6 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Nov 2022 16:15:04 +0100 Subject: [PATCH] fix a bug me and ian found Co-authored-by: Ian VanSchooten --- scripts/prepare/bundle.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 6f1258804de3..9689079b4c66 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -1,7 +1,7 @@ #!/usr/bin/env ../../node_modules/.bin/ts-node import fs from 'fs-extra'; -import path, { join } from 'path'; +import path, { dirname, join, relative } from 'path'; import { build } from 'tsup'; import aliasPlugin from 'esbuild-plugin-alias'; import dedent from 'ts-dedent'; @@ -36,21 +36,25 @@ const run = async ({ cwd, flags }: { cwd: string; flags: string[] }) => { await Promise.all( entries.map(async (file: string) => { console.log(`skipping generating types for ${file}`); - const { name: entryName } = path.parse(file); - - const pathName = join(process.cwd(), 'dist', `${entryName}.d.ts`); + const { name: entryName, dir } = path.parse(file); + + const pathName = join(process.cwd(), dir.replace('./src', 'dist'), `${entryName}.d.ts`); + const srcName = join(process.cwd(), file); + + const rel = relative(dirname(pathName), dirname(srcName)); + await fs.ensureFile(pathName); await fs.writeFile( pathName, dedent` // devmode - export * from '../src/${entryName}' + export * from '${rel}/${entryName}'; ` ); }) ); } - + const tsConfigPath = join(cwd, 'tsconfig.json'); const tsConfigExists = await fs.pathExists(tsConfigPath); await Promise.all([