Coder Social home page Coder Social logo

Comments (9)

ofhouse avatar ofhouse commented on July 1, 2024

Difficult to say without having a reproduction at hand.
Can you tell where the node-fetch package is installed, after you have run yarn?

root/
├── node_modules/
│   └── node-fetch/ <-- Is it here
└── web/
    └── node_modules/
        └── node-fetch/ <-- Or is it here

Can you also tell me which Next.js version you are using?

Basically dependencies are bundled by a tool called nft which runs a static analysis on the actual code which dependencies are required.
Since it follows the Require.js algorithm it should be able to catch the dependencies in both cases.
You can also check the result by opening the Lambda Zip files in .next-tf/lambdas/__NEXT_PAGE_LAMBDA_XX.zip which should contain node_modules/node-fetch directory.

from terraform-aws-next-js.

JoviDeCroock avatar JoviDeCroock commented on July 1, 2024

so all the deps are in root/node_modules and we're running yarn tf-next build --skipDownload in /web and we run terraform apply in /web/.aws/deployment.

When I remove web from the root pkg.json and have my modules in web it works correctly, I can try making a reproduction. Sorry for the vague issue report, will attempt to get it reproduced

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 1, 2024

No problem, setup a repro here: https://github.com/ofhouse/repro-terraform-aws-next-js-93
Can confirm that the tracing of dependencies with --skipDownload is broken in yarn workspace environment.

Running yarn in the workspace root and after that npx tf-next build in the web/ folder.
No node_modules are bundled with the Lambda which should not be happening.

from terraform-aws-next-js.

JoviDeCroock avatar JoviDeCroock commented on July 1, 2024

Managed to bypass the issue for now by running yarn workspace <my-env> build from the root rather than in the workspace itself. Good workaround for now 😅

EDIT: this does not fully fix the issue

from terraform-aws-next-js.

JoviDeCroock avatar JoviDeCroock commented on July 1, 2024

I guess we need to detect whether or not we're in a workspace here

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 1, 2024

Yep, worked a bit with nft last week, and baseDir must be the root of the workspace: https://github.com/dealmore/terraform-aws-next-js/blob/main/packages/runtime/src/index.ts#L1125

Will try to take a closer look into this today.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 1, 2024

Okay, created a potential fix for this issue in #107.
Needs some testing, but I think this should solve the issue.

from terraform-aws-next-js.

hugheba avatar hugheba commented on July 1, 2024

Was the bug for the missing node_modules folder ever fixed?

I can build the .next-tf folder fine with the command ./node_modules/.bin/tf-next build --skipDownload but when I open the Lambda zips, they are missing the node_modules folder.

from terraform-aws-next-js.

ofhouse avatar ofhouse commented on July 1, 2024

@hugheba The location where (cwd) the tf-next build is run from is important when running from a monorepo.

tf-next build should always be executed from the path where the next.config.js (or package.json) of the Next.js app is located.

from terraform-aws-next-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.