FriendsOfSymfony / FOSJsRoutingBundle

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

webpack-inject-plugin.loader.js?id=webpack-inject-module-1!" contains a reference to the file "fos-router" #446

Open codegain opened 1 year ago

codegain commented 1 year ago

Hi,

I followed the instructions in the README and i get the following error on builing with webpack:

Module build failed: Module not found:
"./node_modules/webpack-inject-plugin/dist/webpack-inject-plugin.loader.js?id=webpack-inject-module-1!" contains a reference to the file "fos-router".
This file can not be found, please check it for typos or update it if the file got moved.

I added the webpack plugin (using webpack 5 with Symfony Encore) and also have a fos-router folder in the node_modules folder in my project. It just seems that the webpack plugin implementation is somewhat buggy here:

        new InjectPlugin(() => {
            return 'import Routing from "fos-router";' +
                'import routes from "' + this.finalTarget + '";' +
                'Routing.setRoutingData(routes);';
        }).apply(compiler);

Exposing routes works as expected, var/cache/fosRoutes.json also does exis and contains the exposed routes.

Any ideas?