📄 tsdown.config¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 1 |
| 📦 Imports | 7 |
| 📊 Variables & Constants | 4 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 tsdown.config.ts
📦 Imports¶
| Name | Source |
|---|---|
PackageIndexes |
@vueuse/metadata |
PackageManifest |
@vueuse/metadata |
Format |
tsdown |
UserConfig |
tsdown |
globSync |
tinyglobby |
StaleGuardRecorder |
tsdown-stale-guard |
metadata |
./packages/metadata/index.json |
Variables & Constants¶
| Name | Type | Kind | Value | Exported |
|---|---|---|---|---|
functions |
PackageIndexes |
const | metadata.functions as PackageIndexes['functions'] |
✗ |
externals |
(string \| RegExp)[] |
const | [ 'vue', /@vueuse\/.*/, ] |
✓ |
attwConfig |
UserConfig['attw'] |
const | { level: 'error', profile: 'esm-only', ignoreRules: ['cjs-resolves-to-esm'], } |
✓ |
basePlugins |
UserConfig['plugins'] |
const | [ StaleGuardRecorder(), ] |
✓ |
Functions¶
createTsDownConfig(pkg: PackageManifest, copy: UserConfig['copy'], cwd: string): UserConfig[]¶
Parameters:
pkgPackageManifestcopyUserConfig['copy']cwdstring
Returns: UserConfig[]
Calls:
format.pushfunctionNames.pushglobSync( '*/index.ts', { cwd }, ).mapi.splitconfigs.pushObject.assignfunctions.find
Code
export function createTsDownConfig(
pkg: PackageManifest,
copy?: UserConfig['copy'],
cwd = process.cwd(),
) {
const { globals, external, submodules, iife, build, mjs, dts, target = 'es2018' } = pkg
if (build === false)
return []
const iifeName = 'VueUse'
const iifeGlobals = {
'vue': 'Vue',
'@vueuse/shared': 'VueUse',
'@vueuse/core': 'VueUse',
...(globals || {}),
}
const format: Format[] = []
if (mjs !== false) {
format.push('es')
}
const baseConfig: UserConfig = {
target,
dts,
platform: 'browser',
deps: {
neverBundle: [
...externals,
...(external || []),
],
},
}
const configs: UserConfig[] = []
const functionNames = ['index']
if (submodules) {
functionNames.push(...globSync(
'*/index.ts',
{ cwd },
).map(i => i.split('/')[0]))
}
const entry: Record<string, string> = {}
for (const fn of functionNames) {
const fnEntry = {
[fn]: fn === 'index' ? 'index.ts' : `${fn}/index.ts`,
}
if (iife !== false) {
const BASE_IIFE_CONFIG: UserConfig = {
...baseConfig,
entry: fnEntry,
format: 'iife',
globalName: iifeName,
outputOptions: {
extend: true,
globals: iifeGlobals,
},
}
configs.push(
BASE_IIFE_CONFIG,
{
...BASE_IIFE_CONFIG,
minify: true,
outExtensions: () => ({
js: '.min.js',
}),
},
)
}
Object.assign(entry, fnEntry)
const info = functions.find(i => i.name === fn)
if (info?.component) {
Object.assign(entry, { [`${fn}/component`]: `${fn}/component.ts` })
}
}
configs.push({
...baseConfig,
entry,
format,
copy,
attw: attwConfig,
plugins: basePlugins,
})
return configs
}
Generated by Syntax Scribe