2
0

aliases.js 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. // @ts-check
  2. // these aliases are shared between vitest and rollup
  3. import { readdirSync, statSync } from 'node:fs'
  4. import path from 'node:path'
  5. import { fileURLToPath } from 'node:url'
  6. const resolveEntryForPkg = p =>
  7. path.resolve(
  8. fileURLToPath(import.meta.url),
  9. `../../packages/${p}/src/index.ts`
  10. )
  11. const dirs = readdirSync(new URL('../packages', import.meta.url))
  12. const entries = {
  13. vue: resolveEntryForPkg('vue'),
  14. 'vue/compiler-sfc': resolveEntryForPkg('compiler-sfc'),
  15. 'vue/server-renderer': resolveEntryForPkg('server-renderer'),
  16. '@vue/compat': resolveEntryForPkg('vue-compat')
  17. }
  18. const nonSrcPackages = [
  19. 'sfc-playground',
  20. 'size-check',
  21. 'template-explorer',
  22. 'dts-test'
  23. ]
  24. for (const dir of dirs) {
  25. const key = `@vue/${dir}`
  26. if (
  27. dir !== 'vue' &&
  28. !nonSrcPackages.includes(dir) &&
  29. !(key in entries) &&
  30. statSync(new URL(`../packages/${dir}`, import.meta.url)).isDirectory()
  31. ) {
  32. entries[key] = resolveEntryForPkg(dir)
  33. }
  34. }
  35. export { entries }