-
Notifications
You must be signed in to change notification settings - Fork 34
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
[BUG] External dependencies are unavailable after deploying #86
Comments
i am investigating into this. Will find some free time this week to debug, thanks for the repo i can reproduce it now |
I've ran into this in the past (on older versions) and your triage is spot on, though the root cause may be different. My gut feeling is that it's coming from webpack's packaging, beyond that right now I'm not sure, I'll defer to Wick for now :) |
Any progress on this? This is happening for me with my dependencies. I did some debugging, and it looks like the following is causing me issues.
My webpack stats do not have modules within each of the chunks. Instead each of my modules have chunks within them. {
"errors": [],
"warnings": [],
"hash": "",
"builtAt": 1626391702947,
"publicPath": "",
"outputPath": "",
"entrypoints": {},
"namedChunkGroups": {},
"chunks": [
{
"id": "src/app/common/core/jwt-authorizer",
"rendered": true,
"initial": true,
"entry": true,
"size": 7825,
"names": [
"src/app/common/core/jwt-authorizer"
],
"files": [
"src/app/common/core/jwt-authorizer.js"
],
"hash": "cf21867fdbf405864441",
"siblings": [],
"parents": [],
"children": [],
"childrenByOrder": {}
},
...
],
"modules": [
{
"id": "aws-sdk",
"identifier": "external \"aws-sdk\"",
"name": "external \"aws-sdk\"",
"index": 7,
"index2": 5,
"size": 42,
"built": true,
"optional": false,
"prefetched": false,
"chunks": [
"src/app/controllers/location"
],
"issuer": "",
"issuerId": "",
"issuerName": "",
"issuerPath": [
{
"id": "",
"identifier": "",
"name": "",
"profile": {
"factory": 17,
"building": 323
}
},
{
"id": "",
"identifier": "",
"name": "",
"profile": {
"factory": 56,
"building": 279,
"dependencies": 277
}
}
],
"profile": {
"factory": 1,
"building": 0
},
"failed": false,
"errors": 0,
"warnings": 0,
"assets": [],
"providedExports": null,
"optimizationBailout": [],
"depth": 2
},
{
"id": "crypto",
"identifier": "external \"crypto\"",
"name": "external \"crypto\"",
"index": 4,
"index2": 2,
"size": 42,
"built": true,
"optional": false,
"prefetched": false,
"chunks": [
"src/app/common/core/jwt-authorizer",
"src/app/controllers/location"
],
"issuer": "",
"issuerId": "",
"issuerName": "",
"issuerPath": [
{
"id": "",
"identifier": "",
"name": "",
"profile": {
"factory": 73,
"building": 321,
"dependencies": 7
}
},
{
"id": "",
"identifier": "",
"name": "",
"profile": {
"factory": 9,
"building": 397
}
}
],
"profile": {
"factory": 0,
"building": 0
},
"failed": false,
"errors": 0,
"warnings": 0,
"assets": [],
"providedExports": null,
"optimizationBailout": [],
"depth": 2
},
...
],
"filteredModules": 0,
"logging": {
"webpack.buildChunkGraph.visitModules": {
"entries": [],
"filteredEntries": 2,
"debug": false
}
}
} Changing if (!stats.chunks) {
return [];
}
const externals = new Set();
for (const module of stats.modules) {
if (this.isExternalModule(module) && module.chunks) {
for (const chunkId of module.chunks) {
if (stats.chunks.find((chunk) => chunk.id === chunkId)) {
externals.add({
origin: module.issuer,
external: this.getExternalModuleName(module),
});
}
}
}
}
return Array.from(externals); seems to properly add the dependencies to the generated package.json, subsequently allowing the builder to install them into the dist folder for deployment. |
did #89 solve this issue? I'm seeing a valid package.json now, but the dependencies are not making it into the artifacts. |
It worked for me. |
Describe the bug
I tried adding
date-fns
as a dependency and it worked fine running my function locally:npx nx run graphql:serve
But after deploying to AWS and testing I get an error because
date-fns
is missing:The lambda logs:
From what I understand after going through the README and the code, this plugin should generate a
package.json
withdate-fns
indist/.serverlessPackages
, right?But the resulting
package.json
is:To Reproduce
Clone my repo: https://github.com/iquabius/flow-nx-serverless-external-deps-bug
And:
npm i
npx nx run graphql:deploy
"Internal server error"
Expected behavior
The function should return
"Today is a <day of week>"
Screenshots
If applicable, add screenshots to help explain your problem.
Check which provider is affected:
[x] AWS
[] Azure
[] Google Cloud Platform
Check which framework is affected:
[] Angular
[] Nodejs
[x] Serverless
[] Lambda
[] Infrastructure as a code
Additional context
Add any other context about the problem here.
The text was updated successfully, but these errors were encountered: