Comments (5)
Add class-transformer/storage
to lazyImports
https://github.com/hjf/mapped-types-bug/blob/main/webpack.config.js#L2
from mapped-types.
I spent a few hours on this particular issue, especially when using fastify
as well.
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 webpack.config.js
(targeting AWS Lambda) looked like so:
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
},
}),
],
})
from mapped-types.
https://stackoverflow.com/a/70814629
from mapped-types.
For folks looking this, the error is the following:
ERROR in ./node_modules/@nestjs/mapped-types/dist/type-helpers.utils.js 69:27-63
Module not found: Error: Can't resolve 'class-transformer/storage' in '/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist'
resolve 'class-transformer/storage' in '/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist'
Parsed request is a module
using description file: /tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/package.json (relative path: ./dist)
resolve as module
/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/dist/node_modules doesn't exist or is not a directory
/tmp/mapped-types-bug/node_modules/@nestjs/mapped-types/node_modules doesn't exist or is not a directory
/tmp/mapped-types-bug/node_modules/@nestjs/node_modules doesn't exist or is not a directory
/tmp/mapped-types-bug/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /tmp/mapped-types-bug/node_modules
/tmp/mapped-types-bug/node_modules/class-transformer doesn't exist
/tmp/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
@ ./node_modules/@nestjs/mapped-types/dist/index.js 19:27-58
@ ./node_modules/@nestjs/mapped-types/index.js 6:9-26
@ ./node_modules/@nestjs/swagger/dist/type-helpers/intersection-type.helper.js 4:23-54
@ ./node_modules/@nestjs/swagger/dist/type-helpers/index.js 13:13-50
@ ./node_modules/@nestjs/swagger/dist/index.js 18:13-38
@ ./node_modules/@nestjs/swagger/index.js 6:9-26
@ ./src/app.controller.ts 13:16-42
@ ./src/app.module.ts 11:25-52
@ ./src/main.ts 4:21-44
from mapped-types.
Why was this not fixed?
from mapped-types.
Related Issues (20)
- Class 'CreateUserDto' incorrectly extends base class 'RemoveFieldsWithType<Partial<User>, Function>'. Property 'status' is optional in type 'CreateUserDto' but required in type 'RemoveFieldsWithType<Partial<User>, Function>' HOT 6
- PartialType and IntersectionType doesn't work as expected HOT 9
- Extending using PartialType, OmitType… doesn't copy properties decorators HOT 3
- PickType ignore parent's @Transform when grandparent use @Transform
- Breaking change in 2.0.3 for override fields HOT 5
- Using a PartialType inside a PickType will result in a type error. HOT 1
- IntersectionType breaks returning value of methods HOT 4
- `PickType` doesn't carry over property level`@Expose` decorators
- Create build using latest code HOT 5
- Mapped Types are not transformed with [email protected]+ in browser HOT 1
- Can't inherit getter/setter and function HOT 2
- PartialType can't work with class-validator HOT 1
- `IntersectionType` clause for more than 4 classes is not available in the npm version HOT 4
- Remove @nestjs/common dependency HOT 2
- Could not resolve dependency: peerOptional class-validator@"^0.11.1 || ^0.12.0 || ^0.13.0" from @nestjs/[email protected] HOT 5
- Support for class-validator 0.14.0 HOT 4
- Install fails when class-validtor 0.14.0 already installed HOT 1
- Update security dependencies HOT 4
- `prettier/@typescript-eslint` in ESLint config now throws error HOT 1
- Update the class-validator dependency to 0.14.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapped-types.