You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running the sanity schema extract command fails when using the modern NodeNext module resolution in TypeScript. NodeNext resolution (which is required for correctly loading/recognising package.json export maps) requires *.ts files to be written with a *.js extension, as TypeScript doesn't rewrite paths as part of the compilation process. This extension mismatch causes the schema extract command to fail with a Cannot find module error.
To Reproduce
Steps to reproduce the behavior:
Create a new TypeScript Sanity project.
Set the "type" in package.json to "module".
Change the "module" and "moduleResolution" fields in tsconfig.json to `"NodeNext"
Correct the arising TypeScript errors related to .js extensions.
Run sanity schema extract.
The extraction process will fail to find the .js modules.
You're probably better off using moduleResolution: "bundler", it's like moduleResolution: "nodenext" but doesn't have the drawbacks that comes with nodenext, i.e. it doesn't require .js extensions.
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.
Describe the bug
Running the
sanity schema extract
command fails when using the modernNodeNext
module resolution in TypeScript. NodeNext resolution (which is required for correctly loading/recognising package.json export maps) requires*.ts
files to be written with a*.js
extension, as TypeScript doesn't rewrite paths as part of the compilation process. This extension mismatch causes theschema extract
command to fail with aCannot find module
error.To Reproduce
Steps to reproduce the behavior:
"type"
inpackage.json
to"module"
."module"
and"moduleResolution"
fields intsconfig.json
to `"NodeNext".js
extensions.sanity schema extract
..js
modules.A starter project showing this issue has been created here:
https://github.com/james-camilleri/sanity-typegen-reproduction
The commit showing the config to reproduce is here:
james-camilleri/sanity-typegen-reproduction@7e70266
Expected behavior
Schema generation should work as expected with older resolution mechanisms.
Which versions of Sanity are you using?
What operating system are you using?
Windows 10.
Which versions of Node.js / npm are you running?
The text was updated successfully, but these errors were encountered: