Closed mathiaslaramee closed 5 months ago
Hello @mathiaslaramee, sorry we can't investigate the problem further without reproduction demo, please provide a repro demo by forking rspack-repro, or provide a minimal GitHub repository by yourself. Issues labeled by need reproduction
will be closed if no activities in 14 days.
Could you provide a minimal reproduction?
I cannot create a repo to reproduce since it's happening in a prod app at my company but I did boil it down to the failure happening in an internal npm-package handling INTL.
When doing this inline require inside an NPM-package, so basically from node_modules in the failing application
return (
<TranslationContext.Provider
value={{
translateText,
translateDate,
translateNumber,
isLanguage,
locale
}}
>
<IntlProvider
locale={lang}
timeZone={timeZone}
messages={require(`/src/i18n/${languagePath}/${translationsFileName}.json`)}
>
<IntlSetter setIntl={setIntl} />
{intl ? children : null}
</IntlProvider>
</TranslationContext.Provider>
);
Then it fails. We've later upgraded this package to handle this differently so the messages are passed as a prop to this npm-package component instead of letting the Provider handle it.
This is how it was used in the failing app
<TranslationsProvider
supportedLocales={supportedLanguages}
ranslationsFileName="translations"
>
<AuthenticationProvider>
<App />
</AuthenticationProvider>
</TranslationsProvider>
Could you change 'require(`/src/i18n/${languagePath}/${translationsFileName}.json`)' to a relative path and see whether the problem still exists?
If still exists then I can't help more without a minimal reproduction, I suggest try to extract this into a separate demo.
I changed it so it wasn't the npm packages job to get the json file but the consuming application itself and then it passes it on to the npm package and now it works. So looks like the absolute require form within node_modules broke the build step. Thanks for your help and time 😄
Good to hear
System Info
System: OS: Windows 10 10.0.19045 CPU: (16) x64 AMD Ryzen 7 PRO 6850U with Radeon Graphics Memory: 12.01 GB / 31.31 GB Binaries: Node: 18.19.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD npm: 10.2.3 - C:\Program Files\nodejs\npm.CMD Browsers: Edge: Chromium (120.0.2210.121)
Details
Following the guide on rsbuild.dev migrating from an existing MF CRA (not ejected) app to rsbuild. Got this error in the terminal when running
rsbuild dev
- It told me to create an issue hereUsing: "@rsbuild/core": "^0.3.1", "@rsbuild/plugin-react": "^0.3.1",
rsbuild.config.ts:
modulefederation.config.js:
Reproduce link
No response
Reproduce Steps
Install @rsbuild/core & @rsbuild/plugin-react run yarn rsbuild dev