Skip to content

Commit

Permalink
Merge pull request #19723 from storybookjs/fix/no-link-bundle-fix
Browse files Browse the repository at this point in the history
Fix: dts facade generator did not support deep links
  • Loading branch information
IanVS authored Nov 2, 2022
2 parents 03ec21a + a18424a commit e414b9e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions scripts/prepare/bundle.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit e414b9e

Please sign in to comment.