Skip to content

Commit

Permalink
fix(bundling): declaration:true should find the correct package root …
Browse files Browse the repository at this point in the history
…regardless of cwd #26261
  • Loading branch information
Coly010 committed Aug 21, 2024
1 parent 2065033 commit 1d02baf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 5 additions & 3 deletions packages/esbuild/src/executors/esbuild/esbuild.impl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
} from './lib/build-esbuild-options';
import { getExtraDependencies } from './lib/get-extra-dependencies';
import { DependentBuildableProjectNode } from '@nx/js/src/utils/buildable-libs-utils';
import { join } from 'path';
import { join, relative } from 'path';

const BUILD_WATCH_FAILED = `[ ${chalk.red(
'watch'
Expand Down Expand Up @@ -58,6 +58,7 @@ export async function* esbuildExecutor(
});
}
return acc;
return acc;
}, []);

if (!options.thirdParty) {
Expand Down Expand Up @@ -210,6 +211,7 @@ function getTypeCheckOptions(
context: ExecutorContext
) {
const { watch, tsConfig, outputPath } = options;
const projectRoot = context.projectGraph.nodes[context.projectName].data.root;

const typeCheckOptions: TypeCheckOptions = {
...(options.declaration
Expand All @@ -220,9 +222,9 @@ function getTypeCheckOptions(
: {
mode: 'noEmit',
}),
tsConfigPath: tsConfig,
tsConfigPath: relative(process.cwd(), join(context.root, tsConfig)),
workspaceRoot: context.root,
rootDir: options.declarationRootDir ?? context.root,
rootDir: options.declarationRootDir ?? join(context.root, projectRoot),
};

if (watch) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import {
joinPathFragments,
normalizePath,
ProjectGraphProjectNode,
workspaceRoot,
} from '@nx/devkit';

import { getClientEnvironment } from '../../../utils/environment-variables';
import { NormalizedEsBuildExecutorOptions } from '../schema';
import { getEntryPoints } from '../../../utils/get-entry-points';
import { join, relative } from 'path';

const ESM_FILE_EXTENSION = '.js';
const CJS_FILE_EXTENSION = '.cjs';
Expand Down Expand Up @@ -38,7 +40,7 @@ export function buildEsbuildOptions(
platform: options.platform,
target: options.target,
metafile: options.metafile,
tsconfig: options.tsConfig,
tsconfig: relative(process.cwd(), join(context.root, options.tsConfig)),
sourcemap:
(options.sourcemap ?? options.userDefinedBuildOptions?.sourcemap) ||
false,
Expand Down

0 comments on commit 1d02baf

Please sign in to comment.