β
Prerequisites
π Description
I'm currently exploring how my team can integrate Magic into an existing web app which was using Node16 module resolution. I found that if I tried to import any @magic-ext/* packages then I would get an error with some variation on:
src/main.ts:15:18 - error TS7016: Could not find a declaration file for module '@magic-ext/oidc'. '/Users/bob/code/work/canvas/magic-module-import-reproduce/node_modules/.pnpm/@magic-ext+oidc@4.3.0/node_modules/@magic-ext/oidc/dist/es/index.mjs' implicitly has an 'any' type.
There are types at '/Users/bob/code/work/canvas/magic-module-import-reproduce/node_modules/@magic-ext/oidc/dist/types/index.d.ts', but this result could not be resolved when respecting package.json "exports". The '@magic-ext/oidc' library may need to update its package.json or typings.
15 import oidc from "@magic-ext/oidc"
~~~~~~~~~~~~~~~~~
replacing "@magic-ext/oidc" with the particular module being imported.
I think this is a pretty big deal - if we want Magic to be supported by modern web apps then we should be supporting more recent module resolution methods. I'm happy to make a PR for this.
π§© Steps to Reproduce
- Create a Typescript project that uses
Node16 or NodeNext for the module and moduleResolution settings in tsconfig.json
- Try to import something from
@magic-ext/*
You should see an error in tsc looking something like the quoted text in the description of this issue.
π» Code Sample
I've created a repo that provides a minimal example that triggers this error.
https://github.com/rjwebb/magic-module-import-reproduce
π Environment
| Software |
Version(s) |
magic-sdk |
N/A |
| Browser |
N/A |
yarn |
I used pnpm 8.10.0 |
| Operating System |
Mac OS |
Solution?
I think I know how to solve this - we just need to add a types value to the exports object in package.json for the affected packages, i.e. copy the fix in #626
β Prerequisites
magic-sdk)?π Description
I'm currently exploring how my team can integrate Magic into an existing web app which was using
Node16module resolution. I found that if I tried to import any@magic-ext/*packages then I would get an error with some variation on:replacing "@magic-ext/oidc" with the particular module being imported.
I think this is a pretty big deal - if we want Magic to be supported by modern web apps then we should be supporting more recent module resolution methods. I'm happy to make a PR for this.
π§© Steps to Reproduce
Node16orNodeNextfor the module and moduleResolution settings in tsconfig.json@magic-ext/*You should see an error in tsc looking something like the quoted text in the description of this issue.
π» Code Sample
I've created a repo that provides a minimal example that triggers this error.
https://github.com/rjwebb/magic-module-import-reproduce
π Environment
magic-sdkyarnSolution?
I think I know how to solve this - we just need to add a
typesvalue to theexportsobject inpackage.jsonfor the affected packages, i.e. copy the fix in #626