I have project folder like this:
.dist
classes
namespace1
module.js
public
routes
index.js
app.js
config.js
src
classes
namespace1
module.ts
public
routes
index.ts
app.ts
config.ts
the .dist is a folder that hold all transpiled files, and completely generated by typescript.
Now, I need to refer that config.ts / config.js file from throughout project. I could find 'config' using baseurl from tsconfig.json, and tsc finishes transpiled all src ts files, but it generates error when served through .dist folder using node ./.dist/app.js
It looks very ugly to
import config from '../../../config
from module.ts
. Is there any elegant way to do that? I know I can wrap require
function from js, with for example, load()
and then write it as load('module')
rather than require('module')
is there a way to do that in typescript? Or perhaps set a search path? I've tried rootdirs but doesn't work well. BaseUrl was fine, but the .js files generated errors.
Thank you