Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 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: 9 additions & 0 deletions packages/core/__tests__/build-artifacts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,13 @@ describe('build artifacts', () => {
expect(content).toContain('__dirname');
expect(content).toContain('__filename');
});

it('should include tsdown client.d.ts in dist/tsdown for pack/client support', () => {
const clientPath = path.join(distDir, 'tsdown/client.d.ts');
expect(fs.existsSync(clientPath), `${clientPath} should exist`).toBe(true);

const content = fs.readFileSync(clientPath, 'utf8');
expect(content).toContain('ImportMeta');
expect(content).toContain('glob');
Comment on lines +25 to +26
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I've added some tests to handle file copying and validation based on tsdown/client.d.ts to make sure everything is working as expected.

https://github.com/rolldown/tsdown/blob/main/client.d.ts#L35-L58

});
});
4 changes: 4 additions & 0 deletions packages/core/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ async function bundleTsdown() {
// tsdown resolves this file via path.resolve(import.meta.dirname, '..', 'esm-shims.js'),
// which means it expects the file at dist/esm-shims.js (one level up from dist/tsdown/).
await copyFile(join(tsdownSourceDir, 'esm-shims.js'), join(projectDir, 'dist/esm-shims.js'));

// Copy client.d.ts to dist/tsdown/ to expose it as the vite-plus/pack/client entry point,
// equivalent to tsdown/client for registering bundler type features with TypeScript.
await copyFile(join(tsdownSourceDir, 'client.d.ts'), join(projectDir, 'dist/tsdown/client.d.ts'));
}

async function brandTsdown() {
Expand Down
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@
"default": "./dist/tsdown/index.js",
"types": "./dist/tsdown/index-types.d.ts"
},
"./pack/client": {
Comment thread
fengmk2 marked this conversation as resolved.
"types": "./dist/tsdown/client.d.ts"
},
"./package.json": "./package.json",
"./rolldown": {
"default": "./dist/rolldown/index.mjs",
Expand Down
Loading