Skip to content
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
9 changes: 5 additions & 4 deletions src/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,19 @@ export function parseTasks(

for (const dep of dependencies) {
const depName = typeof dep === 'string' ? dep : dep.name;
const dtsOnly = typeof dep === 'string' ? false : (dep.dtsOnly ?? false);
const importPath = join(cwd, DIST_DIR, depName);
const distPath = join(cwd, DIST_DIR, depName);
const depPath = findDepPath(depName);
const depPath = dtsOnly ? null : findDepPath(depName);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Resolve dependency path for dtsOnly tasks

parseTasks now sets depPath to an empty string whenever dtsOnly is true, but prebundle still uses task.depPath as the source root in emitPackageJson and emitDts (src/prebundle.ts). In dts-only mode this makes those steps read from the repository root (package.json, LICENSE, and globbed .d.ts files) instead of the target dependency, so generated metadata/types can be incorrect for resolvable packages.

Useful? React with 👍 / 👎.


if (!depPath) {
if (!depPath && !dtsOnly) {
throw new Error(`Failed to resolve dependency: ${depName}`);
}

const depEntry = require.resolve(depName, { paths: [cwd] });
const depEntry = dtsOnly ? '' : require.resolve(depName, { paths: [cwd] });

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve entry resolution for dtsOnly type discovery

Setting depEntry to '' in dts-only mode removes the findDirectTypeFile(task.depEntry) fallback used by emitDts (src/prebundle.ts) when a package has declarations adjacent to its runtime entry but no explicit types field. In that case declaration bundling can regress to the default export = any output even though valid types are present.

Useful? React with 👍 / 👎.

const info = {
Comment on lines 61 to 72
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change adds new behavior for dtsOnly parsing but there’s no test coverage exercising a type-only package (one that cannot be require.resolve’d as JS). Consider adding an integration test fixture dependency with dtsOnly: true (and assertions that the dist output is correct for dts-only bundles) to prevent regressions in path resolution and type bundling.

Copilot uses AI. Check for mistakes.
depName,
depPath,
depPath: depPath ?? '',
depEntry,
Comment on lines +65 to 75
Copy link

Copilot AI Mar 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For dtsOnly dependencies this sets depPath to null and then coerces it to an empty string (depPath: depPath ?? ''). Downstream code (e.g. emitDts, emitPackageJson, emitLicense) uses task.depPath to read package.json, glob/copy declaration files, and copy LICENSE; an empty string will make those operations target the current working directory and/or throw. dtsOnly should still produce a real package root path; if the goal is to avoid resolving a JS entrypoint, consider resolving the package root via ${depName}/package.json (or a dedicated helper) and only skipping require.resolve(depName) for depEntry.

Copilot uses AI. Check for mistakes.
distPath,
importPath,
Expand Down