Skip to content

Commit

Permalink
link: fix ssr sites not receiving linked values under sst dev
Browse files Browse the repository at this point in the history
  • Loading branch information
thdxr committed Jul 7, 2024
1 parent e18ddf9 commit 9f63588
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 21 deletions.
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,16 @@ export class Astro extends Component implements Link.Linkable {
path: sitePath,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down
17 changes: 0 additions & 17 deletions pkg/platform/src/components/aws/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -932,23 +932,6 @@ export class Function extends Component implements Link.Linkable, AWSLinkable {
this.fnUrl = fnUrl;

this.registerOutputs({
_receiver: args._skipMetadata
? undefined
: unsecret(
all([args.bundle, args.handler, environment, region]).apply(
([bundle, handler, env, region]) => ({
directory: bundle || handler,
links,
environment: {
...env,
AWS_REGION: region,
},
aws: {
role: role?.arn,
},
}),
),
),
_live: unsecret(
all([dev]).apply(([dev]) => {
if (!dev) return undefined;
Expand Down
24 changes: 20 additions & 4 deletions pkg/platform/src/components/aws/nextjs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import fs from "fs";
import path from "path";
import crypto from "crypto";
import { globSync } from "glob";
import { ComponentResourceOptions, Output, all } from "@pulumi/pulumi";
import { ComponentResourceOptions, Output, all, output } from "@pulumi/pulumi";
import { Size } from "../size.js";
import { Function } from "./function.js";
import {
Expand Down Expand Up @@ -470,17 +470,33 @@ export class Nextjs extends Component implements Link.Linkable {
const buildCommand = normalizeBuildCommand();
const { sitePath, partition, region } = prepare(args, opts);
if ($dev) {
const server = createDevServer(parent, name, args);
this.registerOutputs({
_metadata: {
mode: "placeholder",
path: sitePath,
server: createDevServer(parent, name, args).arn,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
dev: {
command: "npm run dev",
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
command: "npm run dev",
},
});
return;
Expand Down
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/nuxt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,16 @@ export class Nuxt extends Component implements Link.Linkable {
path: sitePath,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/react.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,16 @@ export class React extends Component implements Link.Linkable {
edge,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/remix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,16 @@ export class Remix extends Component implements Link.Linkable {
edge,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/solid-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,16 @@ export class SolidStart extends Component implements Link.Linkable {
path: sitePath,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down
10 changes: 10 additions & 0 deletions pkg/platform/src/components/aws/svelte-kit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,16 @@ export class SvelteKit extends Component implements Link.Linkable {
edge,
server: server.arn,
},
_receiver: {
directory: sitePath,
links: output(args.link || [])
.apply(Link.build)
.apply((links) => links.map((link) => link.name)),
aws: {
role: server.nodes.role.arn,
},
environment: args.environment,
},
_dev: {
directory: sitePath,
links: output(args.link || [])
Expand Down

0 comments on commit 9f63588

Please sign in to comment.