unjs / unbuild

📦 An unified javascript build system
MIT License
2.19k stars 84 forks source link

Aliases doesn't work with `mkdist` builder #375

Closed RIP21 closed 4 weeks ago

RIP21 commented 3 months ago

Environment

Node: v20.11.0 Unbuild: 2.0.0

Reproduction

Config

import * as path from 'node:path'
import { defineBuildConfig } from 'unbuild'

export default defineBuildConfig({
  entries: [
    {
      builder: 'mkdist',
      input: './lib',
      outDir: './dist',
      pattern: ['**/*', '!**/*.test.{ts,tsx}', '!**/*/__tests__/**'],
      ext: 'js',
      format: 'esm',
      rootDir: '.',
    },
  ],
  alias: {
    '@lib': path.resolve(__dirname, 'lib'),
  },
  outDir: './dist',
  declaration: true,
})

Put two files into lib folder and then a reference from one another using path aliases like @lib/anyFile

Describe the bug

When using the config mentioned above, all the path aliases fail to be replaced with correct relative paths while command succeeds (there is no error messages)

Expected: Specified aliases are replaced with relative paths in the resulting files

Actual: They're kept untouched

Additional context

No response

Logs

No response

pi0 commented 4 weeks ago

Let's track via https://github.com/unjs/unbuild/issues/289