Setting the file. One moment.
Subchapter 8.25
references/option-root.mdMarkdown2 KBView on GitHub
The root option is similar to TypeScript’s rootDir. It determines how entry file paths map to output paths. By default, tsdown computes the root as the common base directory of all entry files. Setting root explicitly lets you override this behavior.
tsdown --root srcexport default defineConfig({
entry: ['src/index.ts', 'src/utils/helper.ts'],
root: 'src',
})Given entries src/index.ts and src/utils/helper.ts, the common base directory is src/:
dist/
├── index.js
└── utils/
└── helper.jsSetting root to the project directory preserves the src/ prefix:
dist/
└── src/
├── index.js
└── utils/
└── helper.jsroot for output filenamespreserveModulesRoot, controlling output structure when unbundle: trueexport default defineConfig({
entry: ['src/**/*.ts', '!**/*.test.ts'],
root: '.',
unbundle: true,
})export default defineConfig({
entry: ['src/index.ts'],
root: 'src',
unbundle: true,
})