FriendsOfSymfony / FOSJsRoutingBundle

A pretty nice way to expose your Symfony routing to client applications.
1.48k stars 260 forks source link

webpack problem /FosRouting.js" contains a reference to the file .... #456

Open grekpg opened 1 year ago

grekpg commented 1 year ago
Running webpack ...

 ERROR  Failed to compile with 4 errors                                                                                                                                          2:56:44 PM

Module build failed: Module not found:
"./vendor/friendsofsymfony/jsrouting-bundle/Resources/webpack/FosRouting.js" contains a reference to the file "fs".
This file can not be found, please check it for typos or update it if the file got moved.

"./vendor/friendsofsymfony/jsrouting-bundle/Resources/webpack/FosRouting.js" contains a reference to the file "path".
This file can not be found, please check it for typos or update it if the file got moved.

"./vendor/friendsofsymfony/jsrouting-bundle/Resources/webpack/FosRouting.js" contains a reference to the file "child_process".
This file can not be found, please check it for typos or update it if the file got moved.

"./node_modules/webpack-inject-plugin/dist/main.js" contains a reference to the file "path".
This file can not be found, please check it for typos or update it if the file got moved.

symfony 6

{ "devDependencies": { "@babel/core": "^7.17.0", "@babel/plugin-syntax-dynamic-import": "^7.8.3", "@babel/preset-env": "^7.16.0", "@hotwired/stimulus": "^3.0.0", "@symfony/stimulus-bridge": "^3.2.0", "@symfony/webpack-encore": "^4.2.0", "core-js": "^3.23.0", "fos-router": "file:vendor/friendsofsymfony/jsrouting-bundle/Resources", "fs": "^0.0.1-security", "node-sass": "^8.0.0", "regenerator-runtime": "^0.13.9", "sass": "^1.60.0", "sass-loader": "^13.2.2", "webpack": "^5.74.0", "webpack-cli": "^4.10.0", "webpack-notifier": "^1.15.0" }, "license": "UNLICENSED", "private": true, "scripts": { "dev-server": "encore dev-server", "dev": "encore dev", "watch": "encore dev --watch", "build": "encore production --progress" }, "dependencies": { "@fontsource/montserrat": "^4.5.14", "@popperjs/core": "^2.11.6", "bootstrap": "^5.2.3", "datatables.net": "^1.13.4", "datatables.net-bs5": "^1.13.4", "datatables.net-buttons": "^2.3.6", "datatables.net-buttons-bs5": "^2.3.6", "event-source-polyfill": "^1.0.31", "popper": "^1.0.1", "popper.js": "^1.16.1" } }

i fund some solution

const config = Encore.getWebpackConfig();

config.resolve = config.resolve || {};
config.resolve.fallback = {
  fs: false,
  path: false,
  child_process: false,
};

module.exports = config;

build work but in browser

Uncaught TypeError: util.promisify is not a function
    js FosRouting.js:10
    Webpack 9
[FosRouting.js:10:22](webpack:///vendor/friendsofsymfony/jsrouting-bundle/Resources/webpack/FosRouting.js)
    js FosRouting.js:10
    Webpack 10