Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit 9f63588

Browse files
committed
link: fix ssr sites not receiving linked values under sst dev
1 parent e18ddf9 commit 9f63588

File tree

8 files changed

+80
-21
lines changed

8 files changed

+80
-21
lines changed

pkg/platform/src/components/aws/astro.ts

+10
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,16 @@ export class Astro extends Component implements Link.Linkable {
340340
path: sitePath,
341341
server: server.arn,
342342
},
343+
_receiver: {
344+
directory: sitePath,
345+
links: output(args.link || [])
346+
.apply(Link.build)
347+
.apply((links) => links.map((link) => link.name)),
348+
aws: {
349+
role: server.nodes.role.arn,
350+
},
351+
environment: args.environment,
352+
},
343353
_dev: {
344354
directory: sitePath,
345355
links: output(args.link || [])

pkg/platform/src/components/aws/function.ts

-17
Original file line numberDiff line numberDiff line change
@@ -932,23 +932,6 @@ export class Function extends Component implements Link.Linkable, AWSLinkable {
932932
this.fnUrl = fnUrl;
933933

934934
this.registerOutputs({
935-
_receiver: args._skipMetadata
936-
? undefined
937-
: unsecret(
938-
all([args.bundle, args.handler, environment, region]).apply(
939-
([bundle, handler, env, region]) => ({
940-
directory: bundle || handler,
941-
links,
942-
environment: {
943-
...env,
944-
AWS_REGION: region,
945-
},
946-
aws: {
947-
role: role?.arn,
948-
},
949-
}),
950-
),
951-
),
952935
_live: unsecret(
953936
all([dev]).apply(([dev]) => {
954937
if (!dev) return undefined;

pkg/platform/src/components/aws/nextjs.ts

+20-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import fs from "fs";
22
import path from "path";
33
import crypto from "crypto";
44
import { globSync } from "glob";
5-
import { ComponentResourceOptions, Output, all } from "@pulumi/pulumi";
5+
import { ComponentResourceOptions, Output, all, output } from "@pulumi/pulumi";
66
import { Size } from "../size.js";
77
import { Function } from "./function.js";
88
import {
@@ -470,17 +470,33 @@ export class Nextjs extends Component implements Link.Linkable {
470470
const buildCommand = normalizeBuildCommand();
471471
const { sitePath, partition, region } = prepare(args, opts);
472472
if ($dev) {
473+
const server = createDevServer(parent, name, args);
473474
this.registerOutputs({
474475
_metadata: {
475476
mode: "placeholder",
476477
path: sitePath,
477-
server: createDevServer(parent, name, args).arn,
478+
server: server.arn,
479+
},
480+
_receiver: {
481+
directory: sitePath,
482+
links: output(args.link || [])
483+
.apply(Link.build)
484+
.apply((links) => links.map((link) => link.name)),
485+
aws: {
486+
role: server.nodes.role.arn,
487+
},
488+
environment: args.environment,
478489
},
479490
_dev: {
480491
directory: sitePath,
481-
dev: {
482-
command: "npm run dev",
492+
links: output(args.link || [])
493+
.apply(Link.build)
494+
.apply((links) => links.map((link) => link.name)),
495+
aws: {
496+
role: server.nodes.role.arn,
483497
},
498+
environment: args.environment,
499+
command: "npm run dev",
484500
},
485501
});
486502
return;

pkg/platform/src/components/aws/nuxt.ts

+10
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,16 @@ export class Nuxt extends Component implements Link.Linkable {
330330
path: sitePath,
331331
server: server.arn,
332332
},
333+
_receiver: {
334+
directory: sitePath,
335+
links: output(args.link || [])
336+
.apply(Link.build)
337+
.apply((links) => links.map((link) => link.name)),
338+
aws: {
339+
role: server.nodes.role.arn,
340+
},
341+
environment: args.environment,
342+
},
333343
_dev: {
334344
directory: sitePath,
335345
links: output(args.link || [])

pkg/platform/src/components/aws/react.ts

+10
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,16 @@ export class React extends Component implements Link.Linkable {
347347
edge,
348348
server: server.arn,
349349
},
350+
_receiver: {
351+
directory: sitePath,
352+
links: output(args.link || [])
353+
.apply(Link.build)
354+
.apply((links) => links.map((link) => link.name)),
355+
aws: {
356+
role: server.nodes.role.arn,
357+
},
358+
environment: args.environment,
359+
},
350360
_dev: {
351361
directory: sitePath,
352362
links: output(args.link || [])

pkg/platform/src/components/aws/remix.ts

+10
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,16 @@ export class Remix extends Component implements Link.Linkable {
341341
edge,
342342
server: server.arn,
343343
},
344+
_receiver: {
345+
directory: sitePath,
346+
links: output(args.link || [])
347+
.apply(Link.build)
348+
.apply((links) => links.map((link) => link.name)),
349+
aws: {
350+
role: server.nodes.role.arn,
351+
},
352+
environment: args.environment,
353+
},
344354
_dev: {
345355
directory: sitePath,
346356
links: output(args.link || [])

pkg/platform/src/components/aws/solid-start.ts

+10
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,16 @@ export class SolidStart extends Component implements Link.Linkable {
331331
path: sitePath,
332332
server: server.arn,
333333
},
334+
_receiver: {
335+
directory: sitePath,
336+
links: output(args.link || [])
337+
.apply(Link.build)
338+
.apply((links) => links.map((link) => link.name)),
339+
aws: {
340+
role: server.nodes.role.arn,
341+
},
342+
environment: args.environment,
343+
},
334344
_dev: {
335345
directory: sitePath,
336346
links: output(args.link || [])

pkg/platform/src/components/aws/svelte-kit.ts

+10
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,16 @@ export class SvelteKit extends Component implements Link.Linkable {
342342
edge,
343343
server: server.arn,
344344
},
345+
_receiver: {
346+
directory: sitePath,
347+
links: output(args.link || [])
348+
.apply(Link.build)
349+
.apply((links) => links.map((link) => link.name)),
350+
aws: {
351+
role: server.nodes.role.arn,
352+
},
353+
environment: args.environment,
354+
},
345355
_dev: {
346356
directory: sitePath,
347357
links: output(args.link || [])

0 commit comments

Comments
 (0)