title: FOSJsRoutingBundle integration with Symfony Flex
body: <p>The issue is that I cannot get <strong><a href="https://github.com/FriendsOfSymfony/FOSJsRoutingBundle" rel="nofollow noreferrer">FOSJsRoutingBundle</a></strong> to work with <strong>Symfony Flex</strong> and <strong>Webpack</strong>. </p>
  
  <p>I've been using this bundle in Symfony 3 for a long time and there's never been an issue but with the introduction of webpack, the setup has become more complex. Unfortunately the documentation for version <code>2.2</code> isn't clear.</p>
  
  <p>You can find the current documentation for the bundle here: <a href="https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/index.html" rel="nofollow noreferrer">https://symfony.com/doc/master/bundles/FOSJsRoutingBundle/index.html</a></p>
  
  <p>As you can see it recommends the following approach for Symfony Flex, so I'm writing this in <code>code/assets/js/fos_js_routes.js</code>:</p>
  
  <pre><code>const routes = require('../../public/js/fos_js_routes.json');
  import Routing from '../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js';
  
  Routing.setRoutingData(routes);
  </code></pre>
  
  <p><br>
  with a test route in: <code>code/assets/js/fos_routing_test.js</code></p>
  
  <pre><code>Routing.generate('test_route');
  </code></pre>
  
  <p><br>
  and then including it in <code>webpack.config.js</code> as:</p>
  
  <pre><code>.addEntry('app_fos_routing', [
      './assets/js/fos_js_router.js'
  ])
  .addEntry('app_fos_generate_routes', [
      './assets/js/fos_routing_test.js'
  ])
  </code></pre>
  
  <p><br>
  and my <code>code/templates/index.html.twig</code>:</p>
  
  <pre><code>{{ encore_entry_script_tags('app_fos_routing') }}
  {{ encore_entry_script_tags('app_fos_generate_routes') }}
  </code></pre>
  
  <p><br>
  However when I implement this webpack creates the following which causes a reference error <code>ReferenceError: Routing is not defined</code></p>
  
  <pre><code>/***/ "./assets/js/fos_js_router.js":
  /*!************************************!*\
    !*** ./assets/js/fos_js_router.js ***!
    \************************************/
  /*! no exports provided */
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
  
  "use strict";
  __webpack_require__.r(__webpack_exports__);
  /* harmony import */ var _vendor_friendsofsymfony_jsrouting_bundle_Resources_public_js_router_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js */ "./vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js");
  /* harmony import */ var _vendor_friendsofsymfony_jsrouting_bundle_Resources_public_js_router_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_vendor_friendsofsymfony_jsrouting_bundle_Resources_public_js_router_js__WEBPACK_IMPORTED_MODULE_0__);
  var routes = __webpack_require__(/*! ../../public/js/fos_js_routes.json */ "./public/js/fos_js_routes.json");
  
  
  _vendor_friendsofsymfony_jsrouting_bundle_Resources_public_js_router_js__WEBPACK_IMPORTED_MODULE_0___default.a.setRoutingData(routes);
  
  /***/ }),
  </code></pre>