Skip to content

Conversation

@HendricksJudy
Copy link

Fixes #777

Replace require statements with import statements in Webpack configuration files to resolve the critical dependency warning and blank page issue.

  • demo/configs/webpack/common.js

    • Replace require statements with import statements.
    • Update module.exports to export default.
  • demo/configs/webpack/dev.js

    • Replace require statements with import statements.
    • Update module.exports to export default.
  • demo/configs/webpack/prod.js

    • Replace require statements with import statements.
    • Update module.exports to export default.

Fixes facebookresearch#777

Replace `require` statements with `import` statements in Webpack configuration files to resolve the critical dependency warning and blank page issue.

* **`demo/configs/webpack/common.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/dev.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.

* **`demo/configs/webpack/prod.js`**
  - Replace `require` statements with `import` statements.
  - Update `module.exports` to `export default`.
@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Oct 21, 2024
@snk8828912
Copy link

@HendricksJudy yarn build ,and error like this

[webpack-cli] Failed to load 'D:\ai\sam\segment-anything\demo\configs\webpack\prod.js' config
[webpack-cli] Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'D:\ai\sam\segment-anything\demo\configs\webpack\common' imported from D:\ai\sam\segment-anything\demo\configs\webpack\prod.js
    at new NodeError (node:internal/errors:372:5)
    at finalizeResolution (node:internal/modules/esm/resolve:437:11)
    at moduleResolve (node:internal/modules/esm/resolve:1009:10)
    at defaultResolve (node:internal/modules/esm/resolve:1218:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:580:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:294:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:80:40)
    at link (node:internal/modules/esm/module_job:78:36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

@z416479660
Copy link

z416479660 commented Mar 11, 2025

Fixes #777

Replace require statements with import statements in Webpack configuration files to resolve the critical dependency warning and blank page issue.

  • demo/configs/webpack/common.js

    • Replace require statements with import statements.
    • Update module.exports to export default.
  • demo/configs/webpack/dev.js

    • Replace require statements with import statements.
    • Update module.exports to export default.
  • demo/configs/webpack/prod.js

    • Replace require statements with import statements.
    • Update module.exports to export default.

it didn't work
image
yarn version 1.22.22
node 22.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEMO WARNING: Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

4 participants