Skip to content

[Bug]: Strict SSG build failed by circular references, "ReferenceError: Cannot access 'src_rslib_entry_' before initialization" #1922

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Folyd opened this issue Mar 7, 2025 · 6 comments

Comments

@Folyd
Copy link

Folyd commented Mar 7, 2025

export default {
  ssg: {
    strict: true,
  },
};

Version

Rspress v1.43.1

Details

info Rendering pages...
error Failed to load SSG bundle: /home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs.
error Pages render error: ReferenceError: Cannot access 'src_rslib_entry_' before initialization
at /home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:67684:42
at /home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:107008:3
at Object. (/home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:107011:3)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at cjsLoader (node:internal/modules/esm/translators:346:17)
at ModuleWrap. (node:internal/modules/esm/translators:286:7)
at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
at async renderPages (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/@RsPress+core@1.43.1_webpack@5.98.0/node_modules/@rspress/core/dist/index.js:1598:45)
at async build (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/@RsPress+core@1.43.1_webpack@5.98.0/node_modules/@rspress/core/dist/index.js:1683:5)
at async CAC. (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/rspress@1.43.1_webpack@5.98.0/node_modules/rspress/dist/index.js:166:5)
node:internal/process/promises:391
triggerUncaughtException(err, true /* fromPromise */);
^

ReferenceError: Cannot access 'src_rslib_entry_' before initialization
at /home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:67684:42
at /home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:107008:3
at Object. (/home/runner/work/aiscript-docs/aiscript-docs/doc_build/ssr/main.cjs:107011:3)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1548:10)
at Module.load (node:internal/modules/cjs/loader:1288:32)
at Module._load (node:internal/modules/cjs/loader:1104:12)
at cjsLoader (node:internal/modules/esm/translators:346:17)
at ModuleWrap. (node:internal/modules/esm/translators:286:7)
at ModuleJob.run (node:internal/modules/esm/module_job:234:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:473:24)
at async renderPages (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/@RsPress+core@1.43.1_webpack@5.98.0/node_modules/@rspress/core/dist/index.js:1598:45)
at async build (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/@RsPress+core@1.43.1_webpack@5.98.0/node_modules/@rspress/core/dist/index.js:1683:5)
at async CAC. (file:///home/runner/work/aiscript-docs/aiscript-docs/node_modules/.pnpm/rspress@1.43.1_webpack@5.98.0/node_modules/rspress/dist/index.js:166:5)

Node.js v20.18.3
 ELIFECYCLE  Command failed with exit code 1.

Reproduce link

https://github.com/aiscriptdev/aiscript-docs/actions/runs/13720978629/job/38376189127

Reproduce Steps

See GitHub Action link

@GZTimeWalker
Copy link

Same here since 1.42.1, also reproduce without this ssg option.

Action: https://github.com/GZCTF/website/actions/runs/13561878659/job/37906463158

@GZTimeWalker
Copy link

Same here since 1.42.1, also reproduce without this ssg option.

So I upgrade to v2.0.0-alpha.0, it works fine.

@Folyd
Copy link
Author

Folyd commented Mar 7, 2025

Not working for me after upgrade to v2.0.0-alpha.0, see https://aiscript.dev/

Image

My theme:

import { Layout as BasicLayout } from 'rspress/theme';
import { Content } from 'rspress/runtime';
import { HomeLayout } from './pages/index';
const Layout = () => <BasicLayout><Content /></BasicLayout>;


export default {
    Layout,
    HomeLayout,
};

export * from 'rspress/theme';

@CoffeeChaton
Copy link

import { Layout as BasicLayout } from 'rspress/theme';
import { Content } from 'rspress/runtime';
import { HomeLayout } from './pages/index';
const Layout = () => ;

export default {
Layout,
HomeLayout,
};

export * from 'rspress/theme';

#1891 (comment)

try to use named export, not export default at v2.0.0-alpha?

@Folyd
Copy link
Author

Folyd commented Mar 8, 2025

Sorry, My bad. It fixed now. Thanks.

@Folyd Folyd closed this as completed Mar 8, 2025
@SoonIter SoonIter changed the title [Bug]: Strict SSG build failed [Bug]: Strict SSG build failed by circular references, "ReferenceError: Cannot access 'src_rslib_entry_' before initialization" Mar 11, 2025
@SoonIter
Copy link
Member

Sorry, Rspress guys, it is introduced in #1863 and shown within ">=1.42.0"

I refactored route-related codes in #1863, but it did not introduce any new circular references; this circular reference was already there but had not caused any problems until I organize the imports order in #1863. 🙇🏻I'm so sorry

I have removed the circular reference and it is fixed by #1922 in ">=2.0.0-alpha.0"

if anyone among you is interested in this issue, you can continue to explore it.

@SoonIter SoonIter pinned this issue Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants