Skip to content

Conversation

vegerot
Copy link

@vegerot vegerot commented Aug 15, 2025

Building Rspack projects with i18next-node-fs-backend shows this warning:

warn    Build warning: 
File: /Users/bytedance/workspace/code.byted.org/i18n_ecom_fe/i18n_ecom_shop/node_modules/.pnpm/i18next-node-fs-backend@2.1.3/node_modules/i18next-node-fs-backend/lib/index.js:1:1
   Critical dependency: the request of a dependency is an expression
    ╭─[54:25]
 52    if (/^\.(js|ts)$/.test(extension)) {
 53      try {
 54        var file = require(filename);
    ·                          ─────────
 55        result = file.default ? file.default : file;
 56  
    ╰────

 @ ../../node_modules/.pnpm/i18next-node-fs-backend@2.1.3/node_modules/i18next-node-fs-backend/index.js

This comes from Rspack in https://github.com/web-infra-dev/rspack/blob/95ba587bc379dc5ae98bfd2fdcc9d81a866ab2cd/crates/rspack_plugin_javascript/src/visitors/dependency/context_dependency_helper.rs#L212

This commit works around this warning by wrapping it in a string.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin

Building Rspack projects with i18next-node-fs-backend shows this warning: 

```js
warn    Build warning: 
File: /Users/bytedance/workspace/code.byted.org/i18n_ecom_fe/i18n_ecom_shop/node_modules/.pnpm/[email protected]/node_modules/i18next-node-fs-backend/lib/index.js:1:1
  ⚠ Critical dependency: the request of a dependency is an expression
    ╭─[54:25]
 52 │   if (/^\.(js|ts)$/.test(extension)) {
 53 │     try {
 54 │       var file = require(filename);
    ·                          ─────────
 55 │       result = file.default ? file.default : file;
 56 │ 
    ╰────

 @ ../../node_modules/.pnpm/[email protected]/node_modules/i18next-node-fs-backend/index.js
```

This comes from Rspack in https://github.com/web-infra-dev/rspack/blob/95ba587bc379dc5ae98bfd2fdcc9d81a866ab2cd/crates/rspack_plugin_javascript/src/visitors/dependency/context_dependency_helper.rs#L212


This commit works around this warning by wrapping it in a string.
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.

1 participant