Skip to content

[Bug]: ESModulesLinkingError while importing a re-exported variable from a different module #10919

Open
@smeng9

Description

@smeng9

System Info

System:
OS: macOS 14.5
CPU: (8) arm64 Apple M2
Memory: 95.41 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 23.10.0 - /usr/local/bin/node
Yarn: 1.22.21 - /usr/local/bin/yarn
npm: 10.9.2 - /usr/local/bin/npm
pnpm: 8.12.0 - /usr/local/bin/pnpm
Browsers:
Safari: 17.5

Details

We are using a package unist-util-visit (https://www.npmjs.com/package/unist-util-visit?activeTab=code) that internally reexports CONTINUE, EXIT, SKIP from its './lib/index.js' which is originally from unist-util-visit-parents

This seems is not resolved correctly.

➜ docusaurus git:(main) ✗ yarn build
[INFO] [en] Creating an optimized production build...
● Client ██████████████████████████████████████████████████ (93%) sealing after
● Server ██████████████████████████████████████████████████ (93%) sealing after [ERROR] Client bundle compiled with errors therefore further build is impossible.
× ESModulesLinkingError: export 'CONTINUE' (reexported as 'CONTINUE') was not found in './lib/index.js' (possible exports: visit)
╭─[2:0]
1 │ // Note: types exported from index.d.ts
2 │ export {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'
· ──────────────────────────────────────────────────────────
╰────


× ESModulesLinkingError: export 'EXIT' (reexported as 'EXIT') was not found in './lib/index.js' (possible exports: visit)
╭─[2:0]
1 │ // Note: types exported from index.d.ts
2 │ export {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'
· ──────────────────────────────────────────────────────────
╰────


× ESModulesLinkingError: export 'SKIP' (reexported as 'SKIP') was not found in './lib/index.js' (possible exports: visit)
╭─[2:0]
1 │ // Note: types exported from index.d.ts
2 │ export {CONTINUE, EXIT, SKIP, visit} from './lib/index.js'
· ──────────────────────────────────────────────────────────
╰────

Reproduce link

https://stackblitz.com/edit/new-project-jdzhrcqv?file=testsrc%2Ftest%2Fsrc%2FApp.tsx%3AL4

Reproduce Steps

I used yarn create rsbuild with the following configuration
◆ Create Rsbuild Project

◇ Project name or path
│ test

◇ Select framework
│ React 19

◇ Select language
│ TypeScript

◇ Select additional tools (Use to select, to continue)
│ none

I then cd into the project and yarn set version canary to set yarn version to 4.9.2

I added the additional dependency which will trigger a bug yarn add unist-util-visit

Finally I modified the App.tsx in src folder to include the following and performed yarn dev

import { CONTINUE } from 'unist-util-visit';

console.log(CONTINUE);

This issues seems only happen with yarn, not npm

Metadata

Metadata

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions