Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: dts facade generator did not support deep links #19723

Merged
merged 1 commit into from
Nov 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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