Skip to content

[Bug]: Can't resolve self-referencing #98

Open
@fi3ework

Description

@fi3ework

Version

/

Details

Given a package named @monorepo/self for example. If trying to bare import package itself. webpack / Rspack can't resolve the package. It works in webpack / Rspack with exports field when exports target could be resolved. But when not, for example the source is TS, it will failed to resolve.

// index.js
import { a } from './a.js'
import { b } from './b.js'

export { a, b }
// a.js
export const a = 1
// b.js
import { a } from '@monorepo/self'

export const b = 1 + a

error message:

> @monorepo/self@ build:webpack /Users/bytedance/Projects/webpack-test-out-library-esm-output/packages/self-import
> webpack --config rspack.config.mjs

asset main.mjs 2.07 KiB [compared for emit] [javascript module] (name: main)
runtime modules 670 bytes 3 modules
orphan modules 78 bytes [orphan] 2 modules
./src/index.mjs + 2 modules 141 bytes [built] [code generated]

ERROR in ./src/b.js 1:0-34
Module not found: Error: Can't resolve '@monorepo/self' in '/Users/bytedance/Projects/webpack-test-out-library-esm-output/packages/self-import/src'
 @ ./src/index.mjs 2:0-22 4:0-15

ERROR in ./src/index.mjs 4:0-15
export 'default' (reexported as 'a') was not found in './a.js' (possible exports: a)

ERROR in ./src/index.mjs 4:0-15
export 'default' (reexported as 'b') was not found in './b.js' (possible exports: b)

1 error has detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.93.0 compiled with 3 errors in 48 ms
 ELIFECYCLE  Command failed with exit code 1.

Reproduce link

/

Reproduce Steps

/

Metadata

Metadata

Assignees

No one assigned

    Labels

    RspackRspack related issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions