-
Notifications
You must be signed in to change notification settings - Fork 62
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
Cannot build with Webpack #486
Comments
For folks looking this, the error is the following:
|
Add |
I spent a few hours on this particular issue, especially when using This feels like a potential gap in the existing NestJS serverless documentation. Would a pull request be accepted to update the documentation with the following example? For those still wrestling with this issue, my const path = require('path')
// Documentation:
// https://docs.nestjs.com/faq/serverless#serverless
// https://github.com/nestjs/swagger/issues/1334#issuecomment-836488125
// Tell webpack to ignore specific imports that aren't
// used by our Lambda but imported by NestJS (can cause packing errors).
const lazyImports = [
'@nestjs/microservices/microservices-module',
'@nestjs/websockets/socket-module',
'@nestjs/platform-express',
'swagger-ui-express',
'class-transformer/storage' // https://github.com/nestjs/mapped-types/issues/486#issuecomment-932715880
]
module.exports = (options, webpack) => ({
...options,
mode: 'production',
target: 'node14',
entry: {
index: './lib/lambda.js',
},
output: {
filename: '[name].js',
libraryTarget: 'umd',
path: path.join(process.cwd(), 'build/dist'),
},
externals: {
'aws-sdk': 'aws-sdk',
},
plugins: [
...options.plugins,
new webpack.IgnorePlugin({
checkResource(resource) {
if (lazyImports.includes(resource)) {
try {
require.resolve(resource)
} catch (err) {
return true
}
}
return false
},
}),
],
}) |
Is there an existing issue for this?
Current behavior
When running with nest start, it works as expected. When running with build --webpack, it fails because it cannot find some path. This seems to have been removed by upstream (typestack/class-transformer#563)
Implemented the proposed solution in the link
Minimum reproduction code
https://github.com/hjf/mapped-types-bug
Steps to reproduce
Expected behavior
It should build with no errors
Package version
1.0.0
Node.js version
14.17.4
In which operating systems have you tested?
Other
No response
The text was updated successfully, but these errors were encountered: