Instance
Source:
src/AWS/EC2/Instance.ts
An EC2 instance that can either act as a low-level compute primitive or run a bundled long-lived Effect program directly on the machine.
Launching Instances
Section titled “Launching Instances”const instance = yield* AWS.EC2.Instance("AppInstance", { imageId: AWS.EC2.amazonLinux2023(), instanceType: "t3.micro", subnetId: subnet.subnetId,});Hosting Processes
Section titled “Hosting Processes”const api = yield* Effect.gen(function* () { yield* Http.serve( HttpServerResponse.json({ ok: true }), );
return { main: import.meta.url, imageId: AWS.EC2.amazonLinux2023(), instanceType: "t3.small", subnetId: subnet.subnetId, securityGroupIds: [securityGroup.groupId], associatePublicIpAddress: true, port: 3000, };}).pipe( Effect.provide(AWS.EC2.HttpServer), AWS.EC2.Instance("ApiInstance"),);Bundling & Tree-shaking
Section titled “Bundling & Tree-shaking”main is bundled with rolldown at deploy time. Top-level calls in the
effect, @effect/*, alchemy, @alchemy.run/*, and
@distilled.cloud/* packages receive #__PURE__ annotations by
default, so anything the hosted program doesn’t use from those packages is
tree-shaken out of the bundle. Any other package — including your own
app — is left untouched unless you list it explicitly.
Treat additional packages as pure
Pass package names (or picomatch globs) via build.pure.packages to
annotate them in addition to the defaults.
{ main: import.meta.url, build: { pure: { packages: ["my-lib", "@my-scope/*"] }, },}Listing a package annotates calls whose result is bound (variable
initializers, exports) — safe anywhere. If a listed package also
declares "sideEffects": false (or []) in its package.json, that
combination opts it into full annotation: top-level calls whose result
is discarded (e.g. router.on("/path", handler) registrations) are
also marked pure and deleted under minification when unused. Only list
a sideEffects: false package if its modules really are free of
meaningful top-level side effects. The effect, alchemy, and
@distilled.cloud defaults declare exactly that, on purpose — their
modules are designed to be fully tree-shakeable.
Disable pure annotations
{ main: import.meta.url, build: { pure: false },}