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'),
  },
})

image

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

Most upvoted comments

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:

// build.config.ts

import { defineBuildConfig } from "unbuild";

export default defineBuildConfig({
  failOnWarn: false,
});

Same for me, have you resolved it?

I just replace ungit with tsup.

Same for me, have you resolved it?

Not yet. No one responded to me, I could only cancel the alias.

I just add failOnWarn: false in build.config.ts, because the packaged files are correct. It just a warning not an error.