Skip to content

Commit

Permalink
[cli]: pass buildDir to exports of package.json
Browse files Browse the repository at this point in the history
  • Loading branch information
zgid123 committed Jun 12, 2024
1 parent 009a194 commit 68a136f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@grpc.ts/cli",
"version": "1.2.2",
"version": "1.2.3",
"license": "MIT",
"directories": {
"lib": "lib"
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface IMonorepoOutputProps {

export interface IConfigProps {
output?: string;
buildDir?: string;
external?: string[];
paths?: string | string[];
monorepo?: IMonorepoOutputProps;
Expand Down Expand Up @@ -49,8 +50,11 @@ export interface INamespaceDataProps {

export type TParseNamespaceReturn = [string, INamespaceDataProps];

export type TConfigParams = Omit<Required<IConfigProps>, 'monorepo'> &
Pick<IConfigProps, 'monorepo'>;
export type TConfigParams = Omit<
Required<IConfigProps>,
'monorepo' | 'buildDir'
> &
Pick<IConfigProps, 'monorepo' | 'buildDir'>;

export interface IProtoDataProps {
filePath: string;
Expand Down
13 changes: 9 additions & 4 deletions packages/cli/src/tasks/createContent/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export async function createContent(
groupedData: IProtoDataProps[][],
config: TConfigParams,
): Promise<void> {
const { output, monorepo } = config;
const { output, buildDir = 'dist', monorepo } = config;
const cachedTypes: ICachedTypesProps = {};
const cachedPackageOutputs: ICachedPackageOutputsProps = {};
let outputDir = output;
Expand Down Expand Up @@ -134,8 +134,13 @@ export async function createContent(

if (monorepo) {
const { multiEntries, compiler } = monorepo;
const { engine } = compiler || {};
const { engine, options } = compiler || {};
const hasEngine = !!engine;
let buildDirectory = buildDir;

if (options?.outDir) {
buildDirectory = options.outDir;
}

await createCompilerConfig({
config: monorepo,
Expand All @@ -151,10 +156,10 @@ export async function createContent(
result.content.push(`export * from './${filename}';`);

result.exports[`./${packageName}`] =
`./${filename}.${hasEngine ? 'js' : 'ts'}`;
`./${buildDirectory}/${filename}.${hasEngine ? 'js' : 'ts'}`;

result.typesVersions[`${packageName}`] = [
`./${filename}.${hasEngine ? 'd.ts' : 'ts'}`,
`./${buildDirectory}/${filename}.${hasEngine ? 'd.ts' : 'ts'}`,
];

return result;
Expand Down

0 comments on commit 68a136f

Please sign in to comment.