typescript
typescript copied to clipboard
Problem importing React component (Cannot find module...)
I'm working on an existing project that uses Blaze and I'm trying to create a couple of React Components. I have something like this:
packages/
implementation/
ui/
components/
ComponentA.tsx
ComponentB.tsx
some-blaze-component/
some-blaze-component.js
some-blaze-component imports ComponentA via a relative import (import ComponentA from '../components/ComponentA') which works fine.
The issue is when trying to import ComponentB from ComponentA using import ComponentB from './ComponentB'. I get an error in the browser stating Cannot find module '/ndm_implementation/ui/components/ComponentB'.
Inside project_path\.meteor\local\build\programs\web.browser\packages\ndm_implementation.js if I change that reference from '/ndm_implementation/ui/components/ComponentB' to ./ComponentB' and do a hard reaload it works.
My .tsconfig:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"lib": [
"dom",
"es2017"
],
"jsx": "react",
"strict": true,
"allowJs": true
}
},
"include": [
"packages/implementation/**/*"
],
"exclude": [
"node_modules",
".meteor"
]
}