iTwin / auth-clients

MIT License
6 stars 3 forks source link

Unable to import ElectronRendererAuthorization after recent subpaths change #205

Closed GintV closed 9 months ago

GintV commented 10 months ago

I am unable to import ElectronRendererAuthorization on @itwin/electron-authorization v0.16.0 . I think it is related with #195 . I tried importing it in all sorts of ways and paths, but webpack fails to find it. Trying to import it using the @itwin/electron-authorization/Renderer path, I am getting this message from webpack

image

It is funny that it mentions exports field since I am importing based on that export field. I am using Bentley fork of react-scripts to build frontend.

aruniverse commented 10 months ago

I tried importing it in all sorts of ways and paths

can you please share what you tried?

GintV commented 9 months ago

I tried

... from "@itwin/electron-authorization/Renderer";
... from "@itwin/electron-authorization/lib/esm/renderer/Client";
... from "@itwin/electron-authorization";

This is our tsconfig.json used for Bentley fork of react-scritps

{
  "extends": "./node_modules/@itwin/build-tools/tsconfig-base.json",
  "compilerOptions": {
    "allowJs": true,
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "declarationMap": false,
    "esModuleInterop": true,
    "isolatedModules": true,
    "jsx": "react-jsx",
    "lib": [
      "dom",
      "dom.iterable",
      "esnext"
    ],
    "module": "esnext",
    "noEmit": true,
    "outDir": "./lib",
    "plugins": [
      {
        "name": "typescript-plugin-css-modules"
      }
    ],
    "types": [
      "@bentley/react-scripts",
    ],
  },
  "include": [
    "./src/common/**/*.ts",
    "./src/frontend/**/*.ts",
    "./src/frontend/**/*.tsx"
  ],
  "exclude": [
    "./src/backend/**/*.ts"
  ]
}
aruniverse commented 9 months ago

Use the following recommended tsconfigs:

Frontend:

    "module": "ESNext",
    "moduleResolution": "Bundler",

ESNext Bundler

Backend:

    "module": "NodeNext",
    "moduleResolution": "NodeNext",

NodeNext NodeNext

Everything should compile fine. I will note, vscode intellisense will still complain tho

aruniverse commented 9 months ago

take a look at this example: https://github.com/iTwin/itwinjs-core/pull/6058

GintV commented 9 months ago

We recently made the tsconfig updates and I thought that it might allow us to use latest electron-auth package version. I just tested and everything works now. I am closing this issue.