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

tf-next: Adds support for yarn workspaces #107

Merged
merged 9 commits into from
Apr 10, 2021

Conversation

ofhouse
Copy link
Member

@ofhouse ofhouse commented Apr 6, 2021

Adds support for yarn workspaces to tf-next build command.

ToDo

  • Make yarn workspace example working
    The thing is that we should should not change the original CWD (So entrypoint is always /package.json etc.), instead we should search for a yarn workspace root, and pass it as basedir when it exists.

Fixes #93.

@JoviDeCroock
Copy link

JoviDeCroock commented Apr 7, 2021

Hmm, https://github.com/dealmore/terraform-aws-next-js/pull/107/checks?check_run_id=2279172762#step:6:810 seems like the failing tests seem related to them resolving to the correct directory but the base being different.
Or the config.xRoutes added a prefix 😅

@ofhouse
Copy link
Member Author

ofhouse commented Apr 7, 2021

Yeah the issue is that the sub-directory of the package ends up as prefix in the route config. 🙈
So when the Next.js app is in a packages/webapp/ directory, every route gets this prefix, e.g. example.com/packages/webapp/.

Will take another look soon. 😅

@JoviDeCroock
Copy link

JoviDeCroock commented Apr 8, 2021

Nice one, thank you for all the effort. Tried it out locally and the lambda is now reporting a 403 - Missing authentication token. This error seemed to be an issue with aws-sam, renaming index.tsx to hello.tsx makes it run, you also have to change the probe to be /hello

This brings us one step closer, now we're at, we could be facing an issue where transpilation of node_modules gets us, when evaluating the file it looks legit.

{
   "errorType":"SyntaxError",
   "errorMessage":"Unexpected token '.'",
   "trace":[
      "/var/task/e46a782de0c6d67299f11ffc507ec41cb6cb9af0/node_modules/@jimmy/common:1",
      "../../packages/common",
      "^",
      "",
      "SyntaxError: Unexpected token '.'",
      "    at wrapSafe (internal/modules/cjs/loader.js:979:16)",
      "    at Module._compile (internal/modules/cjs/loader.js:1027:27)",
      "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)",
      "    at Module.load (internal/modules/cjs/loader.js:928:32)",
      "    at Function.Module._load (internal/modules/cjs/loader.js:769:14)",
      "    at Module.require (internal/modules/cjs/loader.js:952:19)",
      "    at require (internal/modules/cjs/helpers.js:88:18)",
      "    at Object.Xh0v (/var/task/e46a782de0c6d67299f11ffc507ec41cb6cb9af0/packages/web/.next/serverless/pages/hello.js:1325:18)",
      "    at __webpack_require__ (/var/task/e46a782de0c6d67299f11ffc507ec41cb6cb9af0/packages/web/.next/serverless/pages/hello.js:23:31)",
      "    at Module.uVm6 (/var/task/e46a782de0c6d67299f11ffc507ec41cb6cb9af0/packages/web/.next/serverless/pages/hello.js:1879:15)"
   ]
}

@ofhouse
Copy link
Member Author

ofhouse commented Apr 9, 2021

Yep, we currently only create /__NEXT_PAGE_LAMBDA_0/{proxy+} routes for the lambdas in the SAM template.
Unfortunately this does not cover the root route /__NEXT_PAGE_LAMBDA_0/ since it has no proxy part.
Created an upstream issue in sammy: milliHQ/sammy#3

@ofhouse
Copy link
Member Author

ofhouse commented Apr 9, 2021

Okay, sammy is fixed now and now also supports index routes.
The issue itself is fixed when a more current version of next is used (was 9.1.4).

@ofhouse
Copy link
Member Author

ofhouse commented Apr 9, 2021

lol, now another test is failing (╯°□°)╯︵ ┻━┻ 😅

@ofhouse ofhouse merged commit 3925c4a into main Apr 10, 2021
@ofhouse ofhouse deleted the tf-next/yarn-workspace-support branch April 10, 2021 12:38
@ofhouse
Copy link
Member Author

ofhouse commented Apr 10, 2021

Now released in tf-next@0.7.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Yarn workspace issue with node-fetch
2 participants