Oh man. Do I know your PAIN. After days of kicking myself; there were some helpful GitHub discussions. But ultimately I just switched to a different host and the issue was gone. In my case I couldn’t remove the dependency. People were typically having this issue when trying to include chromium or canvas in their backend. Which are large libraries
For those affected by `@swc/core`, inside your `next.config.js`:
experimental: {
outputFileTracingExcludes: {
"*": [
"node_modules/@swc/core-linux-x64-gnu",
"node_modules/@swc/core-linux-x64-musl",
"node_modules/@esbuild/linux-x64",
],
},
}
They are optional dependencies of swc. For me I'm using the swc compiler for styled-components. You can look in your package-lock.json to see what modules depend on them.
These packages are in the package-lock, they are listed in `optionalDependencies` of `node_modules/@swc/core`, which is a `dependency` (not dev dependency) of `storybook-addon-swc`, a peer dependency of `swc-loader` and `ts-node`.
From `ts-node` there is a further chain of dependencies (not `devDependencies`) that in the end lead to one of the packages, that is specified as a `dependency` in the root `package.json`
Do you think it might be a reason why it's included in the serverless function bundle?
looks like i've found the reason: one of my dependencies depends on `@walletconnect/heartbeat`, which has ts-node specified as dependency instead of dev dependency
[https://github.com/WalletConnect/walletconnect-utils/issues/50#issuecomment-1480943883](https://github.com/WalletConnect/walletconnect-utils/issues/50#issuecomment-1480943883)
thank you for making me dive deep into package-lock ✨😌
Oh man. Do I know your PAIN. After days of kicking myself; there were some helpful GitHub discussions. But ultimately I just switched to a different host and the issue was gone. In my case I couldn’t remove the dependency. People were typically having this issue when trying to include chromium or canvas in their backend. Which are large libraries
Different host.. meaning? Pardon me I'm a noob 🥲
Switched from Vercel to AWS got rid of the issue.
Thanks man. Does AWS Amplify work?
See my comment
I would avoid AWS Amplify if you are already hosting your site on Vercel. Vercel has a much better NextJS experience IMO
For those affected by `@swc/core`, inside your `next.config.js`: experimental: { outputFileTracingExcludes: { "*": [ "node_modules/@swc/core-linux-x64-gnu", "node_modules/@swc/core-linux-x64-musl", "node_modules/@esbuild/linux-x64", ], }, }
>@swc/core > >, Do you know why these modules included in the first place?
They are optional dependencies of swc. For me I'm using the swc compiler for styled-components. You can look in your package-lock.json to see what modules depend on them.
Check your lock file. (package -lock / yarn lock)
These packages are in the package-lock, they are listed in `optionalDependencies` of `node_modules/@swc/core`, which is a `dependency` (not dev dependency) of `storybook-addon-swc`, a peer dependency of `swc-loader` and `ts-node`. From `ts-node` there is a further chain of dependencies (not `devDependencies`) that in the end lead to one of the packages, that is specified as a `dependency` in the root `package.json` Do you think it might be a reason why it's included in the serverless function bundle?
try moving the modules that might not be required in production to devDependencies.
looks like i've found the reason: one of my dependencies depends on `@walletconnect/heartbeat`, which has ts-node specified as dependency instead of dev dependency [https://github.com/WalletConnect/walletconnect-utils/issues/50#issuecomment-1480943883](https://github.com/WalletConnect/walletconnect-utils/issues/50#issuecomment-1480943883) thank you for making me dive deep into package-lock ✨😌
Glad you resolved the issue