Skip to content
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

fix(bundling): rspack should allow ES config module imports #29095

Merged
merged 2 commits into from
Jan 30, 2025

Conversation

meeroslav
Copy link
Contributor

Reproduction repo: https://github.com/olaf-cichocki/sample

Current Behavior

When using mjs config file we end up with following error:

⚠️ Unable to construct project graph.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
      An error occurred while processing files for the @nx/rspack/plugin plugin.
    - apps/appA/rspack.config.mjs: require() of ES Module /Users/miro/Dev/Testbox/sample/apps/appA/rspack.config.mjs not supported.
  Instead change the require of /Users/miro/Dev/Testbox/sample/apps/appA/rspack.config.mjs to a dynamic import() which is available in all CommonJS modules.
      Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/miro/Dev/Testbox/sample/apps/appA/rspack.config.mjs not supported.
      Instead change the require of /Users/miro/Dev/Testbox/sample/apps/appA/rspack.config.mjs to a dynamic import() which is available in all CommonJS modules.
          at resolveUserDefinedRspackConfig (/Users/miro/Dev/Testbox/sample/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_react-dom@1_7iwdcl66l7me4m7pewq22wegge/node_modules/@nx/rspack/src/utils/resolve-user-defined-rspack-config.js:19:16)
          at createRspackTargets (/Users/miro/Dev/Testbox/sample/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_react-dom@1_7iwdcl66l7me4m7pewq22wegge/node_modules/@nx/rspack/src/plugins/plugin.js:65:98)
          at createNodesInternal (/Users/miro/Dev/Testbox/sample/node_modules/.pnpm/@[email protected]_@[email protected]_@[email protected]_react-dom@1_7iwdcl66l7me4m7pewq22wegge/node_modules/@nx/rspack/src/plugins/plugin.js:51:34)
          at async /Users/miro/Dev/Testbox/sample/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/plugins/utils.js:10:27
          at async Promise.all (index 0)

Expected Behavior

Using EU module config files is supported

Related Issue(s)

Fixes #

Thank you @olaf-cichocki for reporting the issue.

@meeroslav meeroslav self-assigned this Nov 27, 2024
@meeroslav meeroslav requested a review from a team as a code owner November 27, 2024 13:43
Copy link

vercel bot commented Nov 27, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Updated (UTC)
nx-dev ⬜️ Ignored (Inspect) Visit Preview Jan 30, 2025 1:26pm

Copy link

nx-cloud bot commented Nov 27, 2024

View your CI Pipeline Execution ↗ for commit cabef38.

Command Status Duration Result
nx affected --targets=lint,test,build,e2e,e2e-c... ✅ Succeeded 12m 54s View ↗
nx run-many -t check-imports check-commit check... ✅ Succeeded 51s View ↗
nx-cloud record -- nx-cloud conformance:check ✅ Succeeded 2s View ↗
nx-cloud record -- nx format:check --base=10c14... ✅ Succeeded 21s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 20s View ↗
nx documentation --no-dte ✅ Succeeded 37s View ↗

☁️ Nx Cloud last updated this comment at 2025-01-30 13:43:04 UTC

@olaf-cichocki
Copy link

Hello 👋 Just saying we are waiting for that change 🙏

@olaf-cichocki
Copy link

Also, if making it async is hard, maybe createRequire from node:module would be easier to implement for compatibility with both ESM and CJS

@Coly010 Coly010 force-pushed the fix/rspack-custom-config branch 3 times, most recently from 262b32f to 6576619 Compare January 28, 2025 09:36
@Coly010 Coly010 force-pushed the fix/rspack-custom-config branch from 6576619 to cabef38 Compare January 30, 2025 13:24
@Coly010 Coly010 merged commit 7d864c8 into master Jan 30, 2025
5 checks passed
@Coly010 Coly010 deleted the fix/rspack-custom-config branch January 30, 2025 13:43
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

Successfully merging this pull request may close these issues.

3 participants