-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
@aws-cdk/aws-lambda-nodejsbugThis issue is a bug.This issue is a bug.in-progressThis issue is being actively worked on.This issue is being actively worked on.p2
Description
NodejsFunction
from @aws-cdk/aws-lambda-nodejs
which is using Parcel to bundle dependencies does that incorrectly, I'm not sure why. I've tried putting function dependencies both at the root of the project and inside function directory.
However, it works correctly when I cd
into function directory, run NODE_ENV=production parcel build function.ts"
and point NodeJSFunction entry
to the built function.
Reproduction Steps
https://github.com/RafalWilinski/cdk-nodejs-function-parcel-bug
const graphql = new NodejsFunction(this, 'yourlambda', {
entry: './src/graphql-server/function.ts', // Typescript source - does not work
});
But
const graphql = new NodejsFunction(this, 'yourlambda', {
entry: './src/graphql-server/dist/function.js', // after building using parcel manually - works
});
Error Log
After invocation:
{"errorType":"Error","errorMessage":"Cannot use e \"__Schema\" from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\nhttps://yarnpkg.com/en/docs/selective-version-resolutions\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.","trace":["Error: Cannot use e \"__Schema\" from another module or realm.","","Ensure that there is only one instance of \"graphql\" in the node_modules","directory. If different versions of \"graphql\" are the dependencies of other","relied on modules, use \"resolutions\" to ensure only one version is installed.","","https://yarnpkg.com/en/docs/selective-version-resolutions","","Duplicate \"graphql\" modules cannot be used at the same time since different","versions may have different capabilities and behavior. The data from one","version used in the function from another could produce confusing and","spurious results."," at e (/var/task/index.js:64:273)"," at L (/var/task/index.js:78:2521)"," at b (/var/task/index.js:78:2330)"," at $ (/var/task/index.js:78:4892)"," at ee (/var/task/index.js:78:4923)"," at new H (/var/task/index.js:78:4713)"," at H (/var/task/index.js:78:4692)"," at Object.parcelRequire.Y3NB.../polyfills/objectValues.mjs (/var/task/index.js:96:11150)"," at f (/var/task/index.js:1:468)"," at p (/var/task/index.js:1:544)"]}
Environment
- CLI Version : 1.38
- Framework Version: 1.38
- OS : Mac OS
- Language : English
This is 🐛 Bug Report
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-lambda-nodejsbugThis issue is a bug.This issue is a bug.in-progressThis issue is being actively worked on.This issue is being actively worked on.p2