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: revert to node16, build to mjs, and use more modern ulid package #28

Merged
merged 1 commit into from
Nov 19, 2022
Merged
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
3 changes: 1 addition & 2 deletions apps/test-app-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"@aws-sdk/client-lambda": "^3.204.0",
"@aws-sdk/lib-dynamodb": "^3.204.0",
"@eventual/aws-runtime": "workspace:^",
"@eventual/core": "workspace:^",
"ulid": "^2.3.0"
"@eventual/core": "workspace:^"
},
"devDependencies": {
"@eventual/compiler": "workspace:^",
Expand Down
3 changes: 1 addition & 2 deletions apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
},
"dependencies": {
"aws-cdk-lib": "^2.50.0",
"constructs": "^10.1.154",
"ulid": "^2.3.0"
"constructs": "^10.1.154"
},
"devDependencies": {
"@eventual/aws-cdk": "workspace:^",
Expand Down
3 changes: 1 addition & 2 deletions packages/@eventual/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"dependencies": {
"@aws-cdk/aws-apigatewayv2-authorizers-alpha": "2.50.0-alpha.0",
"@eventual/aws-runtime": "workspace:^",
"@eventual/compiler": "workspace:^",
"ulid": "^2.3.0"
"@eventual/compiler": "workspace:^"
},
"peerDependencies": {
"aws-cdk-lib": "^2.50.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/@eventual/aws-cdk/src/workflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
Function,
Code,
IFunction,
Runtime,
} from "aws-cdk-lib/aws-lambda";
import { Construct } from "constructs";
import { Bucket, IBucket } from "aws-cdk-lib/aws-s3";
Expand All @@ -25,7 +26,6 @@ import { SqsEventSource } from "aws-cdk-lib/aws-lambda-event-sources";
import path from "path";
import { execSync } from "child_process";
import { IGrantable, IPrincipal } from "aws-cdk-lib/aws-iam";
import { NODE_18_X } from "./utils";

export interface WorkflowProps {
entry: string;
Expand Down Expand Up @@ -109,7 +109,7 @@ export class Workflow extends Construct implements IGrantable {
"../../esm/functions/start-workflow.js"
),
handler: "handle",
runtime: NODE_18_X,
runtime: Runtime.NODEJS_16_X,
architecture: Architecture.ARM_64,
bundling: {
// https://github.com/aws/aws-cdk/issues/21329#issuecomment-1212336356
Expand Down Expand Up @@ -151,7 +151,7 @@ export class Workflow extends Construct implements IGrantable {
code: Code.fromAsset(path.join(outDir, "activity-worker")),
// the bundler outputs activity-worker/index.js
handler: "index.default",
runtime: NODE_18_X,
runtime: Runtime.NODEJS_16_X,
memorySize: 512,
environment: {
NODE_OPTIONS: "--enable-source-maps",
Expand All @@ -173,7 +173,7 @@ export class Workflow extends Construct implements IGrantable {
code: Code.fromAsset(path.join(outDir, "orchestrator")),
// the bundler outputs orchestrator/index.js
handler: "index.default",
runtime: NODE_18_X,
runtime: Runtime.NODEJS_16_X,
memorySize: 512,
environment: {
NODE_OPTIONS: "--enable-source-maps",
Expand Down
2 changes: 1 addition & 1 deletion packages/@eventual/aws-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"aws-lambda": "^1.0.7",
"fast-equals": "^4.0.3",
"micro-memoize": "^4.0.11",
"ulid": "^2.3.0",
"ulidx": "^0.3.0",
"aws-embedded-metrics": "^4.0.0"
},
"peerDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
isHistoryEvent,
WorkflowEvent,
} from "@eventual/core";
import { ulid } from "ulid";
import { ulid } from "ulidx";

export interface ExecutionHistoryClientProps {
readonly dynamo: DynamoDBClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
WorkflowEventType,
HistoryStateEvents,
} from "@eventual/core";
import { ulid } from "ulid";
import { ulid } from "ulidx";
import { ExecutionHistoryClient } from "./execution-history-client.js";

export interface WorkflowClientProps {
Expand Down
27 changes: 21 additions & 6 deletions packages/@eventual/compiler/src/eventual-bundle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ async function main() {
conditions: ["module", "import", "require"],
// supported with NODE_18.x runtime
// TODO: make this configurable.
external: ["@aws-sdk"],
// external: ["@aws-sdk"],
platform: "node",
format: "cjs",
format: "esm",
metafile: true,
bundle: true,
entryPoints: [
Expand All @@ -44,7 +44,9 @@ async function main() {
"../../esm/entry/orchestrator.js"
),
],
outfile: path.join(outDir, "orchestrator/index.js"),
// // ulid
banner: esmPolyfillRequireBanner(),
outfile: path.join(outDir, "orchestrator/index.mjs"),
})
.then(writeEsBuildMetafile(path.join(outDir, "orchestrator/meta.json"))),
esbuild
Expand All @@ -59,9 +61,9 @@ async function main() {
conditions: ["module", "import", "require"],
// supported with NODE_18.x runtime
// TODO: make this configurable.
external: ["@aws-sdk"],
// external: ["@aws-sdk"],
platform: "node",
format: "cjs",
format: "esm",
metafile: true,
bundle: true,
entryPoints: [
Expand All @@ -70,14 +72,27 @@ async function main() {
"../../esm/entry/activity-worker.js"
),
],
outfile: path.join(outDir, "activity-worker/index.js"),
banner: esmPolyfillRequireBanner(),
outfile: path.join(outDir, "activity-worker/index.mjs"),
})
.then(
writeEsBuildMetafile(path.join(outDir, "activity-worker/meta.json"))
),
]);
}

/**
* Allows ESM module bundles to support dynamo requires when necessary.
*/
function esmPolyfillRequireBanner() {
return {
js: [
`import { createRequire as topLevelCreateRequire } from 'module'`,
`const require = topLevelCreateRequire(import.meta.url)`,
].join("\n"),
};
}
Comment on lines +84 to +94
Copy link
Owner

Choose a reason for hiding this comment

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

Does this mess with source maps

Copy link
Contributor Author

Choose a reason for hiding this comment

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

evanw/esbuild#531

Looks like it will not break them


function writeEsBuildMetafile(path: string) {
return (
esbuildResult: esbuild.BuildResult & { metafile: esbuild.Metafile }
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.