-
-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
imports not working in typescript project #124
Comments
you can find the repo here: https://github.com/oakgary/serverless-bundle-import-issue steps to reproduce:
|
I'm having the exact same issue.. |
Hey mate @oakgary , try using |
@jponc Thanks for the reply. Will give it another try once someone looked deeper into this. I had to switch back my typescript-services to serverless-webpack for now, as I needed a stable version for production. |
@oakgary Thanks for putting together the repo. I'll have a look. |
I figured out the problem with the repo. It has to do with the location of the tsconfig.json. It's placed outside the root of the service. If it is moved to You can see it here https://github.com/oakgary/serverless-bundle-import-issue/pull/1/files @jponc Are you doing something similar too? |
just gave it another shot setting sourcemaps: false (custom:bundle:sourcemaps:false) in the serverless.yml of the affected service did fix the problem for me |
@jayair Did you manage to figure it out? I can also take a look, but yeah I think it's pretty common to have a shared tsconfig.json especially when dealing with monorepo setup |
Getting back to this. @oakgary Did my PR not work for you? Because it worked for me. If it is because of the location of the |
no, if i remember correctly it did not solve the problem for me
but i am not sure anymore if i used exactly your tsconfig.json or if i adjusted my own nevertheless i have been using serverless-bundle for the last 2-3 weeks with typescript in production now using the hotfix @jponc provided which is setting the sourcemaps value to false |
Yeah I'm digging into this issue now. It seems related to the babel loader that we are running |
I had the same issue but setting sourcemaps:false as @jponc suggested fixed it for me. |
same issue, |
spent whole day figuring out why its not working and stumbled upon this. |
I've been spending some time on this one. I think I've got a sense for what is going on. Are you all using
in your |
@jayair I have the same problem. |
@andrey-k Can you also set this in your custom:
bundle:
caching: false |
@jayair
Do you need any additional information? |
@andrey-k I might need a sample repo from you. I tried @oakgary's repo (https://github.com/oakgary/serverless-bundle-import-issue) with the following steps and it worked. $ git clone https://github.com/oakgary/serverless-bundle-import-issue.git
$ yarn
# Remove "module": "commonjs" from tsconfig.json
$ cd services/my_service
$ serverless invoke local -f myLambda |
@jayair actually a combination of |
Yeah the issue is that with If some of the other folks in this thread can confirm, then I'll document this issue and possibly add a warning if |
@andrey-k Btw, you can remove the |
I should also mention this for anybody testing the |
If folks can confirm that the above solves their issue, we can either document this or add a check while building. |
I can confirm that removing |
For me the removal of "commonjs" wasn't an option. It seems to be common to set the
For reference: serverless-heaven/serverless-webpack#23 |
@Luke-Rhodes-RDSLE4 How come removing |
Pushed a new release that shows a warning if https://github.com/AnomalyInnovations/serverless-bundle/releases/tag/v4.0.0 https://github.com/AnomalyInnovations/serverless-bundle#module-and-targets |
Just pushed a patch to handle non standard JSON tsconfigs. https://github.com/AnomalyInnovations/serverless-bundle/releases/tag/v4.0.1 |
Hello @jayair 👋 Is there a reason why there's a warning emitted instead of throwing an error? Does it still work with warning or user can expect "bad things" to happen at a later point in time? If the second case is expected, maybe it should unconditionally throw there? |
/file_a.ts
/file_b.ts
Executing the handler of file_b (using sls offline or deploying to aws) leads to something like:
Both eslint and typescript are not showing any errors. The code is compiling fine.
I assume it has something to do with webpack or babel.
That is the issue I am facing right now in a nutshell.
I will try to create a small repo to reproduce this error.
The text was updated successfully, but these errors were encountered: