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

feat: add support for NextJS in SST & remove CJS support #482

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
}
}
],
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/ban-ts-comment": "warn",
"@typescript-eslint/no-this-alias": "warn",
"@typescript-eslint/explicit-member-accessibility": [
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ runs:

- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"
cache: "pnpm"

- run: pnpm install --frozen-lockfile
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: arn:aws:iam::593491530938:role/githubActionStack-githubactionroleA106E4DC-14SHKLVA61IN4
aws-region: us-east-1
Expand All @@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: arn:aws:iam::593491530938:role/githubActionStack-githubactionroleA106E4DC-14SHKLVA61IN4
aws-region: us-east-1
Expand All @@ -64,7 +64,7 @@ jobs:
- run: |
echo "TEST_ROLE_ARN=$(node -p 'JSON.parse(require("fs").readFileSync("${{ steps.deployment-output.outputs.download-path }}/outputs.json"))["eventual-tests"].roleArn')" >> $GITHUB_ENV
- name: Configure Test Role Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: ${{ env.TEST_ROLE_ARN }}
aws-region: us-east-1
Expand All @@ -88,7 +88,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: arn:aws:iam::593491530938:role/githubActionStack-githubactionroleA106E4DC-14SHKLVA61IN4
aws-region: us-east-1
Expand All @@ -102,7 +102,7 @@ jobs:
- run: |
echo "TEST_ROLE_ARN=$(node -p 'JSON.parse(require("fs").readFileSync("${{ steps.deployment-output.outputs.download-path }}/outputs.json"))["eventual-tests"].roleArn')" >> $GITHUB_ENV
- name: Configure Test Role Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: ${{ env.TEST_ROLE_ARN }}
aws-region: us-east-1
Expand All @@ -126,7 +126,7 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions/build
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: arn:aws:iam::593491530938:role/githubActionStack-githubactionroleA106E4DC-14SHKLVA61IN4
aws-region: us-east-1
Expand All @@ -140,7 +140,7 @@ jobs:
- run: |
echo "TEST_ROLE_ARN=$(node -p 'JSON.parse(require("fs").readFileSync("${{ steps.deployment-output.outputs.download-path }}/outputs.json"))["eventual-tests"].roleArn')" >> $GITHUB_ENV
- name: Configure Test Role Credentials
uses: aws-actions/configure-aws-credentials@v1-node16
uses: aws-actions/configure-aws-credentials@v3-node20
with:
role-to-assume: ${{ env.TEST_ROLE_ARN }}
aws-region: us-east-1
Expand Down
5 changes: 1 addition & 4 deletions apps/test-app-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@
"devDependencies": {
"@eventual/cli": "workspace:^",
"@types/aws-lambda": "^8.10.115",
"@types/jest": "^29.5.1",
"@types/ms": "^0.7.31",
"@types/node": "^18",
"aws-embedded-metrics": "^4.1.0",
"jest": "^29",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"ts-node": "^10.9.1"
},
"jest": {
"preset": "ts-jest",
Expand Down
1 change: 0 additions & 1 deletion apps/test-app-runtime/src/my-workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { task, workflow } from "@eventual/core";

export default workflow("my-workflow", async ({ name }: { name: string }) => {
const result = await Promise.all([hello(name), hello2(name)]);
console.log(result);
const result2 = await hello(name);
return `you said ${result2} ${result}`;
});
Expand Down
6 changes: 1 addition & 5 deletions apps/test-app-runtime/src/parent-child-com.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ export const workflow1 = workflow("workflow1", async () => {
while (true) {
const n = await mySignal.expectSignal();

console.log(n);

if (n > 10) {
child.sendSignal(doneSignal);
break;
Expand All @@ -32,7 +30,7 @@ export const workflow1 = workflow("workflow1", async () => {
*/
export const workflow2 = workflow(
"workflow2",
async (input: { name: string }, { execution: { parentId } }) => {
async (_input: { name: string }, { execution: { parentId } }) => {
let block = false;
let done = false;
let last = 0;
Expand All @@ -41,8 +39,6 @@ export const workflow2 = workflow(
throw new Error("I need an adult");
}

console.log(`Hi, I am ${input.name}`);

mySignal.onSignal((n) => {
last = n;
block = false;
Expand Down
6 changes: 3 additions & 3 deletions apps/test-app-sst/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
"@serverless-stack/cli": "^1.18.4",
"@serverless-stack/core": "^1.18.4",
"@serverless-stack/resources": "^1.18.4",
"@tsconfig/node18": "^1.0.1",
"aws-cdk-lib": "2.102.0",
"@tsconfig/node20": "^1.0.1",
"aws-cdk-lib": "2.110.1",
"chalk": "^5.2.0",
"fs-extra": "^11.1.0",
"typescript": "^5",
"typescript": "^5.3.3",
"vitest": "^0.26.2"
},
"dependencies": {
Expand Down
4 changes: 1 addition & 3 deletions apps/test-app-sst/services/functions/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ api.post("/work", async (request) => {
});

export const myWorkflow = workflow("myWorkflow", async (items: string[]) => {
const results = await Promise.all(items.map(doWork));
const results = await Promise.all(items.map((item) => doWork(item)));

await workDone.emit({
outputs: results,
Expand All @@ -23,8 +23,6 @@ export const myWorkflow = workflow("myWorkflow", async (items: string[]) => {
});

export const doWork = task("work", async (work: string) => {
console.log("Doing Work", work);

return work.length;
});

Expand Down
2 changes: 1 addition & 1 deletion apps/test-app-sst/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"extends": "@tsconfig/node18/tsconfig.json",
"extends": "@tsconfig/node20/tsconfig.json",
"include": ["stacks"]
}
2 changes: 1 addition & 1 deletion apps/test-app/cdk.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"app": "ts-node ./src/app.ts",
"app": "tsx ./src/app.ts",
"watch": "."
}
13 changes: 6 additions & 7 deletions apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"name": "test-app",
"private": true,
"version": "0.0.0",
"main": "lib/index.js",
"type": "module",
"module": "lib/index.js",
"scripts": {
"test": "cdk synth",
"cdk": "cdk",
Expand All @@ -14,20 +15,18 @@
},
"dependencies": {
"@eventual/aws-cdk": "workspace:^",
"aws-cdk-lib": "2.102.0",
"constructs": "10.1.154"
"aws-cdk-lib": "2.110.1",
"constructs": "10.3.0"
},
"devDependencies": {
"@eventual/cli": "workspace:^",
"@types/jest": "^29.5.1",
"@types/node": "^18",
"aws-cdk": "2.102.0",
"aws-cdk": "2.110.1",
"esbuild": "^0.17.4",
"jest": "^29",
"test-app-runtime": "workspace:^",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"tsx": "^4.7.0"
},
"jest": {
"preset": "ts-jest",
Expand Down
3 changes: 3 additions & 0 deletions apps/test-app/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ import { App, CfnOutput, Duration, Stack } from "aws-cdk-lib/core";

import * as eventual from "@eventual/aws-cdk";
import { ServiceDashboard } from "@eventual/aws-cdk";
import { createRequire } from "module";

const require = createRequire(import.meta.url);

const app = new App();

Expand Down
7 changes: 4 additions & 3 deletions apps/test-app/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
{
"extends": "../../tsconfig-base.cjs",
"extends": "../../tsconfig-base",
"include": ["src"],
"exclude": ["lib", "node_modules"],
"compilerOptions": {
"outDir": "lib",
"rootDir": "src"
"rootDir": "src",
"esModuleInterop": true
},
"references": [
{ "path": "../../packages/@eventual/aws-cdk" },
{ "path": "../../packages/@eventual/aws-cdk/tsconfig.json" },
{ "path": "../test-app-runtime" }
]
}
2 changes: 1 addition & 1 deletion apps/tests/aws-runtime-cdk/cdk.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"app": "ts-node --esm ./src/app.mts",
"app": "tsx ./src/app.mts",
"watch": "."
}
2 changes: 1 addition & 1 deletion apps/tests/aws-runtime-cdk/eventual.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projectType": "aws-cdk",
"synth": "npx cdk synth --app \"ts-node --esm ./src/app.mts\"",
"synth": "npx cdk synth --app \"tsx ./src/app.mts\"",
"deploy": "../aws-runtime/scripts/deploy"
}
15 changes: 6 additions & 9 deletions apps/tests/aws-runtime-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,25 @@
"main": "lib/index.js",
"scripts": {
"cdk": "cdk",
"nag": "ts-node-esm ./scripts/report-violations.ts"
"nag": "tsx ./scripts/report-violations.ts"
},
"dependencies": {
"@aws-cdk/aws-apigatewayv2-alpha": "^2.102.0-alpha.0",
"aws-cdk-lib": "2.102.0",
"@aws-cdk/aws-apigatewayv2-alpha": "^2.110.1-alpha.0",
"aws-cdk-lib": "2.110.1",
"cdk-nag": "^2.27.164",
"constructs": "10.1.154"
"constructs": "10.3.0"
},
"devDependencies": {
"@aws-sdk/client-sts": "3.341.0",
"@eventual/aws-cdk": "workspace:^",
"@eventual/cli": "workspace:^",
"@eventual/core": "workspace:^",
"@types/jest": "^29.5.1",
"@types/node": "^18",
"aws-cdk": "^2.102.0",
"aws-cdk": "^2.110.1",
"esbuild": "^0.17.4",
"jest": "^29",
"tests-runtime": "workspace:^",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"tsx": "^4.7.0"
},
"jest": {
"preset": "ts-jest",
Expand Down
2 changes: 1 addition & 1 deletion apps/tests/aws-runtime/eventual.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"projectType": "aws-cdk",
"synth": "npx cdk synth --app \"ts-node --esm ../aws-runtime-cdk/src/app.mts\"",
"synth": "npx cdk synth --app \"tsx ../aws-runtime-cdk/src/app.mts\"",
"deploy": "./scripts/deploy"
}
11 changes: 7 additions & 4 deletions apps/tests/aws-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@
"@aws-sdk/types": "^3.341.0",
"@jest/globals": "^29.5.0",
"@types/aws-lambda": "^8.10.115",
"@types/jest": "^29.5.1",
"@types/node": "^18",
"@types/uuid": "^9.0.4",
"@types/ws": "^8.5.5",
"aws-cdk": "^2.102.0",
"aws-cdk": "^2.110.1",
"esbuild": "^0.17.4",
"jest": "^29",
"node-fetch": "^3.3.0",
"openapi3-ts": "^3.1.2",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"typescript": "^5.0.4"
"tsx": "^4.7.0"
},
"jest": {
"displayName": "workspace",
Expand All @@ -55,6 +53,11 @@
"extensionsToTreatAsEsm": [
".ts"
],
"transformIgnorePatterns": [
"node_modules/",
"node_modules/@eventual/core/lib/",
"node_modules/@eventual/client/lib/"
],
"moduleNameMapper": {
"^(\\.{1,2}/.*)\\.js$": "$1"
},
Expand Down
2 changes: 1 addition & 1 deletion apps/tests/aws-runtime/scripts/deploy
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

set -ex

npx cdk deploy --app "ts-node --esm ../aws-runtime-cdk/src/app.mts" --hotswap-fallback ${CI:+false} --require-approval never --outputs-file ${OUTPUTS_FILE:-/dev/null}
npx cdk deploy --app "tsx ../aws-runtime-cdk/src/app.mts" --hotswap-fallback ${CI:+false} --require-approval never --outputs-file ${OUTPUTS_FILE:-/dev/null}
8 changes: 4 additions & 4 deletions apps/tests/aws-runtime/scripts/test-create
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ cd ./.eventual
echo "Testing Create-Eventual with AWS CDK"

PROJECT_NAME="testme"
EVENTUAL_PACKAGES=("@eventual/core" "@eventual/core-runtime" "@eventual/aws-client" "@eventual/cli" "@eventual/client" "@eventual/aws-runtime" "@eventual/testing" "@eventual/compiler" "@eventual/integrations-slack" "@eventual/aws-cdk" "@eventual/timeline" "@eventual/project")
EVENTUAL_PACKAGES=("@eventual/core" "@eventual/core-runtime" "@eventual/aws-client" "@eventual/cli" "@eventual/client" "@eventual/aws-runtime" "@eventual/testing" "@eventual/compiler" "@eventual/integrations-slack" "@eventual/aws-cdk" "@eventual/project" "@eventual/sst")

rm -rf $PROJECT_NAME
../../../../packages/create-eventual/bin/index.js $PROJECT_NAME --target aws-cdk --serviceName test-service --skip-install --no-git --package-manager pnpm
../../../../packages/create-eventual/bin/index.mjs $PROJECT_NAME --target aws-cdk --serviceName test-service --skip-install --no-git --package-manager pnpm
cd $PROJECT_NAME

pnpm link ${EVENTUAL_PACKAGES[@]/"@"/"../../../../../packages/@"}

# CDK doesn't like mis-matched versions...
cd ./infra
pnpm install aws-cdk@2.79.1 aws-cdk-lib@2.79.1 constructs@10.1.154
pnpm install aws-cdk@2.110.1 aws-cdk-lib@2.110.1 constructs@10.3.0
pnpm link ${EVENTUAL_PACKAGES[@]/"@"/"../../../../../../packages/@"}
cd ..

Expand All @@ -42,7 +42,7 @@ cd ../
echo "Testing Create-Eventual with AWS SST"

rm -rf $PROJECT_NAME
../../../../packages/create-eventual/bin/index.js $PROJECT_NAME --target sst --serviceName test-service
../../../../packages/create-eventual/bin/index.mjs $PROJECT_NAME --target sst --serviceName test-service

# sst's "build" also bootstraps and needs permissions to get parameters.
# There seems to be no good way to test the build/synth without network/account access :(.
Expand Down
Loading
Loading