FOSJsRoutingBundle icon indicating copy to clipboard operation
FOSJsRoutingBundle copied to clipboard

Cannot use in typescript + vite environnement

Open xlaussel opened this issue 2 years ago • 1 comments

I try to use the router in a typescript + vite environnement. I import the library like:

import {Routing} from '~/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router'

(~ is an alias to the root folder)

But when executing I have the following error in the console: Uncaught SyntaxError: The requested module '/@fs/data/xlextent/srcs/financile/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js' does not provide an export named 'Routing' (at routing.ts:3:1)

When I do:

import Routing from '~/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router'

I have the error:

But when executing I have the following error in the console: Uncaught SyntaxError: The requested module '/@fs/data/xlextent/srcs/financile/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js' does not provide an export named 'default' (at routing.ts:3:1)

Here is my tsconfig.json with esModuleInterop ans allowJs set:

{
  "extends": "@vue/tsconfig/tsconfig.web.json",
  "include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
  "compilerOptions": {
    "esModuleInterop": true,
    "allowJs": true,
    "paths": {
      "@/*": ["./src/*"],
      "~/*": ["../*"],
    }
  },

  "references": [
    {
      "path": "./tsconfig.config.json"
    }
  ]
}

What can I do?

xlaussel avatar Jun 07 '22 12:06 xlaussel

So strange. It most definitely has a Router export, but I have not checked the transpiled code.

fatso83 avatar Jun 28 '22 09:06 fatso83