Currently, I am utilizing a library named sinuous, which contains a submodule known as "sinuous/map".
Interestingly, VSCode seems to lack knowledge about the type of 'map' when using
import { map } from "sinuous/map"
, but it recognizes the type in import { map } from "sinuous/src/map"
.
My development environment involves using vite for writing frontend vanilla JS with ESM support. However, upon attempting to import map
from "sinuous/src/map", vite starts throwing errors:
20:49:07 [vite] page reload user-list.js
20:49:07 [vite] Internal server error: Missing "./map.js" specifier in "sinuous" package
Plugin: vite:import-analysis
File: D:/dev/web/neohcpp-z/user-list.js
The file structure of sinuous is depicted below:
sinuous
│ package.json
│ README.md
│
├─dist
│ babel-plugin-htm.cjs
│
└─src
.eslintrc.yml
babel-plugin-htm.js
babel-plugin-htm.md
h.d.ts
h.js
htm.js
hydrate.d.ts
hydrate.js
hydrate.md
index.d.ts
index.js
jsx.d.ts
map.d.ts
map.js
observable.d.ts
observable.js
observable.md
shared.d.ts
template.d.ts
template.js
template.md
This excerpt showcases a portion of the "package.json" from sinuous within my "node_modules" directory:
{
"name": "sinuous",
"version": "0.32.1",
"description": "🧬 Small, fast, reactive render engine",
"module": "src/index.js",
"main": "src/index.js",
"types": "src/index.d.ts",
"type": "module",
// Additional configurations...
}
It appears that when importing using a path, VSCode detects the "map.d.ts" file, yet fails to do so when importing through "sinuous/map". In order to satisfy vite's requirements, I must stick to importing via
import { map } from "sinuous/map"
, despite this leading to VSCode not recognizing the types.
I have implemented a "tsconfig.json" configuration:
{
"compilerOptions": {
"module": "NodeNext",
"moduleResolution": "NodeNext"
}
}
This setup does appease TSC and facilitates visibility of "map.d.ts" content. Interestingly, although TS Compiler acknowledges the type of 'map' during imports within ".ts" files, VSCode falters to identify the types within ".js" files.