unbuild: It's unreasonable to trigger `Inlined implicit external` warning when the related alias was configured.
Environment
Node.js version: v18.12.1
Reproduction
https://github.com/Plasticine-Yang/plasticine-monitor
run pnpm build:browser can trigger the bug.
Describe the bug
It will trigger Inlined implicit external @/sdk when I don’t config the alias for @, which is reasonable.
However, the @/sdk is a path alias point to packages/browser/src/sdk.ts, it is not a dependency package.
I also configured the paths option in tsconfig.json, but it is just for IDE and tsc to resolve the path, which is not related to the rollup under the unbuild.
So, it should be solved when I configure the alias @ pointing to packages/browser/src, but it still trigger the Inlined implicit external @/sdk warning.
I’m not sure whether it is a bug or a feature. The issue can be closed if it is a feature.
Additional context
The file imports a module with alias: packages/browser/src/plugins/error-monitor-plugin/index.ts:
import type { Plugin } from '@plasticine-monitor/core'
import { WebSDK } from '@/sdk'
import { monitorJSError } from './monitors/js-error'
/**
* @description 监听运行时错误插件
*/
const errorMonitorPlugin = (): Plugin<WebSDK> => {
return {
install(webSDK) {
monitorJSError(webSDK)
},
}
}
const __TEMP__ = WebSDK
console.log(__TEMP__)
export { errorMonitorPlugin }
The @/sdk points to packages/browser/src/sdk.ts.
build.config.ts
export default defineBuildConfig({
entries: ['./src/index'],
outDir: 'dist',
clean: true,
declaration: true,
rollup: {
emitCJS: true,
},
alias: {
'@': resolve(__dirname, 'src'),
},
})

Logs
No response
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 18 (2 by maintainers)
Commits related to this issue
- refactor: some house keeping (read desc) Use relative path in index because of unjs/unbuild#201 Remove abundant packages Rebuilt lockfile & nolyfill Template test should no longer throws when replace... — committed to NamesMT/starter-ts by deleted user 3 years ago
- chore: change build to normal bundle for unjs/unbuild#201 — committed to NamesMT/starter-ts by NamesMT 3 years ago
- fix: workaround unbuild alias implicit external bug unjs/unbuild#201 — committed to NamesMT/hono-adapter-aws-lambda by NamesMT 2 years ago
- fix: Create build.config.ts https://github.com/unjs/unbuild/issues/201 — committed to focus-at/sveltekit-sprite by focus-at 2 years ago
There’s seems to be the same issue before, and it’s fixed https://github.com/unjs/unbuild/issues/383. Checked the release note, maybe try
v3.0.0-rc2? https://github.com/unjs/unbuild/releases/tag/v3.0.0-rc.2@sechi747 My current workaround solution:
I just replace ungit with tsup.
I just add
failOnWarn: falsein build.config.ts, because the packaged files are correct. It just a warning not an error.