Aliases in serverless-webpack are not supported
See original GitHub issueThis is a Bug Report
Description
Trying to resolve aliases through typescript and webpack with this configuration on the webpack side:
resolve: {
alias: {
'@/': path.resolve(__dirname, './src/'),
},
},
Whenever I use import syntax of import { test } from '@/folder/file'
and try to build, it throws an error
Serverless: Invoke webpack:package
Serverless: Fetch dependency graph from ....examplePath/package.json
Serverless: WARNING: Could not determine version of module @/folder
Serverless: Package lock found - Using locked versions
Serverless: Packing external modules: @/folder, source-map-support@^0.5.19
Error --------------------------------------------------
yarn install --frozen-lockfile --non-interactive failed with code 1
error An unexpected error occurred: "https://registry.yarnpkg.com/@%2fcommon: Not found".
I also have tsconfig set with these parameters:
"baseUrl": ".",
"paths": {
"~/*": ["src/*"]
}
Additional Data
- Serverless-Webpack Version you’re using: 5.3.2
- Webpack version you’re using: 4.43.0
- Serverless Framework Version you’re using: 1.72.0
- Operating System: macOS
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
Webpack resolve.alias does not work with typescript?
This solved my problem: we were using a custom module syntax which defined aliases to files other than index . Renaming the files...
Read more >Webpack alias does not work in typescript file : WEB-29207
Sample projects. In src/main.ts there is two call hello.world() which is correct and hello.notWorld() which cause compile error.
Read more >serverless-aws-alias-fixed
Serverless plugin to support AWS function aliases. Latest version: 2.0.1, last published: 2 years ago.
Read more >Serverless with Webpack and TypeScript
If you're using the de facto plugin for TypeScript, Serverless Plugin TypeScript , then at least one feature it doesn't support is path...
Read more >terraform-aws-modules/lambda/aws
Store deployment packages locally or in the S3 bucket. Support almost all features of Lambda resources (function, layer, alias, etc.) Lambda@ ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I managed to get it to work fairly easily without problems. I am not using TypeScript however.
Anyway, my config:
I think you are missing the extensions in
webpack.resolve
. I’m using typescript and aliases work fine. Here’s my config