Skip to content
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

fix: Serverless Deployment provider packs correctly #10646

Merged

Conversation

jwwisgerhof
Copy link
Contributor

Fixes #10528

Simple fix that restores Serverless deployment functionality.

@dthyresson
Copy link
Contributor

Thanks @jwwisgerhof for fixing! I don't have a serverless deployed app to test this. Could you provide the logs are some evidence of this fixing working (redacted for any sensitive info) so we can review approve and merge.

@dthyresson dthyresson self-assigned this May 20, 2024
@dthyresson dthyresson self-requested a review May 20, 2024 12:54
@jwwisgerhof
Copy link
Contributor Author

Hard to provide logs that show a definite fix, but have tested this on our enterprise app and am using it live at the moment. WIthout fix:

[STARTED] Checking if Serverless framework is installed...
Framework Core: 3.38.0 (local)
Plugin: 7.2.0
SDK: 4.5.1

[COMPLETED] Checking if Serverless framework is installed...
[STARTED] Building api...
❯ Generating Prisma Client...
✔ Generating Prisma Client...
❯ Verifying graphql schema...
✔ Verifying graphql schema...
❯ Building API...
✔ Building API...
[COMPLETED] Building api...
[STARTED] Packing Functions...
[FAILED] undefined is not a function
undefined is not a function

With my branch built and lifted into our project:

[STARTED] Checking if Serverless framework is installed...
Framework Core: 3.38.0 (local)
Plugin: 7.2.0
SDK: 4.5.1

[COMPLETED] Checking if Serverless framework is installed...
[STARTED] Building api...
❯ Generating Prisma Client...
✔ Generating Prisma Client...
❯ Verifying graphql schema...
✔ Verifying graphql schema...
❯ Building API...
✔ Building API...
[COMPLETED] Building api...
[STARTED] Packing Functions...
[COMPLETED] Packing Functions...
[STARTED] Deploying api....
[SKIPPED] Finishing early due to --pack-only flag. Your Redwood project is packaged and ready to deploy

I'll set up a test repo with minimal code and link it here.

@jwwisgerhof
Copy link
Contributor Author

jwwisgerhof commented May 20, 2024

Alright @dthyresson - gutted our repo quickly, probably a bit messy but it serves the purpose.
Working repo on 6.4: https://github.com/jwwisgerhof/rw-75-sls-test
Upgraded repo to 7.5.1: https://github.com/jwwisgerhof/rw-75-sls-test/tree/RW-75

To reproduce in either repo:

  • yarn install
  • yarn rw deploy sls --stage uat --pack-only --side api

Succeeds on main, fails on RW-75 branch. Build my PR and copy dist over to RW-75 branch and deploy command succeeds.

Let me know if you need more info :)

EDIT: Tests failing as it was watching the export. Will look into this later when I get a chance
EDIT2: Tests fixed as well using recommended self-import method to spy on functions

@thedavidprice
Copy link
Contributor

Thank you for working on this @jwwisgerhof!

@@ -7,6 +7,8 @@ import fse from 'fs-extra'
import { findApiDistFunctions } from '@redwoodjs/internal/dist/files'
import { ensurePosixPath, getPaths } from '@redwoodjs/project-config'

import * as nftPacker from '../packing/nft'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any idea about what changed and broke this in the first place? This is a surprising fix given that the error showed up after a minor release... Assuming the culprit could be with the NFT package itself. 🤷‍♂️

No need to hold up the PR to try and figure it out — goal here is simple + efficient. Just thought it was worth asking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% sure - I got to this fix by simple trial and error, realizing eventually that "exports" is undefined. Having a look around the web now , it has to do with how the JS is compiled / emitted. Modern versions don't allow the exports.xxx syntax depending on module resolution.

I am not familiar enough with the RW codebase to see what change might have caused this. I did go through our build log and can confirm that in @redwoodjs/cli@npm:7.2.0-rc.53 this still worked and packed correctly.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to do with how the JS is compiled / emitted

Yeah, this is the kind of thing that has me thinking a bit; one of our related build dependencies could have been updated behind the scenes and introduced a behavior change that's breaking.

Again, not a critical priority to figure out. Appreciate you taking time to reply 👍

Copy link
Contributor

@dthyresson dthyresson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very much appreciated!

@dthyresson dthyresson changed the title Fixed function calls in serverless deployment fix: Fixed Packing during Serverless deployment May 22, 2024
@dthyresson dthyresson changed the title fix: Fixed Packing during Serverless deployment fix: Serverless Deployment provider packs correctly May 22, 2024
@dthyresson dthyresson added the release:fix This PR is a fix label May 22, 2024
@dthyresson dthyresson added this to the next-release-patch milestone May 22, 2024
@dthyresson
Copy link
Contributor

@jwwisgerhof One last thing before I can merge. Might you add a changeset so the details of this fix gets into the release notes?

See: https://github.com/redwoodjs/redwood/blob/main/.changesets/10668.md for examples.

Appreciate it!

@jwwisgerhof
Copy link
Contributor Author

Thanks @dthyresson - have added that now. Looking forward to getting this released and upgrading to RW7!

@dthyresson dthyresson merged commit 902d006 into redwoodjs:main May 23, 2024
46 checks passed
@jwwisgerhof jwwisgerhof deleted the jwwisgerhof-serverless-pack-fix branch May 26, 2024 23:59
Josh-Walker-GM pushed a commit that referenced this pull request May 30, 2024
Fixes #10528

Simple fix that restores Serverless deployment functionality.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Josh-Walker-GM pushed a commit that referenced this pull request Jun 3, 2024
Fixes #10528

Simple fix that restores Serverless deployment functionality.

---------

Co-authored-by: David Thyresson <dthyresson@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug?]: nftPack: undefined is not a function
4 participants