serverless-plugin-typescript
serverless-plugin-typescript copied to clipboard
User defined path shortcuts defined in tsconfig.json are not resolved in transpiled code
Hi there!
I am using shortcut paths in my tsconfig.json
file. For example:
{
"compilerOptions": {
...
"paths": {
"@app/*": ["./src/*"],
}
}
}
Paths are not expanded/resolved in transpiled code. This is a known feature/bug of Typescript https://github.com/microsoft/TypeScript/issues/26722
There are a few workarounds as discussed in the issue above. One suggestion is to resolve the problem at the level of the output bundler (e.g. webpack and, in our case, this plugin).
I was just wondering if this plugin could resolve shortcuts before/after transpiling the code.
thanks
please add this!
Any news on adding this feature? Thanks :)
Here's a quick fork off v1.1.7 to resolve this
npm install @theslyone/[email protected]
.
It's somewhat of a hack but works, ensure .serverless and .build directories are deleted before running
any news on this issue?
Same issue with baseUrl. My absolute imports won't work. For now I'll switch to relative imports because it's a small project. But would be nice to have something more robust here.
If you are using serverless-webpack (installed by default if you used sls create --template aws-nodejs-typescript
)
In your webpack.config.js
// webpack.config.js
resolve: {
extensions: ['.ts'],
alias: {
'@app': path.resolve(__dirname, './src'),
},
},
// tsconfig.json
"baseUrl": "./src/",
"paths": {
"@app/*": ["./*"]
},
Will this feature be implemented?
Sent a PR implementing this is #241 ... but like my other PRs to this repo, there is no sign of it ever getting merged in...
Would be super useful to have this! +1