sst 2.7.2 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,101 @@
1
+ import fs from "fs";
2
+ import path from "path";
3
+ import { SsrSite } from "./SsrSite.js";
4
+ import { SsrFunction } from "./SsrFunction.js";
5
+ import { EdgeFunction } from "./EdgeFunction.js";
6
+ /**
7
+ * The `SvelteKitSite` construct is a higher level CDK construct that makes it easy to create a SvelteKit app.
8
+ * @example
9
+ * Deploys a SvelteKit app in the `my-svelte-app` directory.
10
+ *
11
+ * ```js
12
+ * new SvelteKitSite(stack, "web", {
13
+ * path: "my-svelte-app/",
14
+ * });
15
+ * ```
16
+ */
17
+ export class SvelteKitSite extends SsrSite {
18
+ initBuildConfig() {
19
+ return {
20
+ typesPath: "src",
21
+ serverBuildOutputFile: ".svelte-kit-sst/server/lambda-handler/index.js",
22
+ // Note: form action requests contain "/" in request query string
23
+ // ie. POST request with query string "?/action"
24
+ // CloudFront does not allow query string with "/". It needs to be encoded.
25
+ serverCFFunctionInjection: `
26
+ for (var key in request.querystring) {
27
+ if (key.includes("/")) {
28
+ request.querystring[encodeURIComponent(key)] = request.querystring[key];
29
+ delete request.querystring[key];
30
+ }
31
+ }
32
+ `,
33
+ clientBuildOutputDir: ".svelte-kit-sst/client",
34
+ clientBuildVersionedSubDir: "_app",
35
+ prerenderedBuildOutputDir: ".svelte-kit-sst/prerendered",
36
+ };
37
+ }
38
+ createFunctionForRegional() {
39
+ const { runtime, timeout, memorySize, permissions, environment, nodejs, bind, cdk, } = this.props;
40
+ const ssrFn = new SsrFunction(this, `ServerFunction`, {
41
+ description: "Server handler for SvelteKit",
42
+ handler: path.join(this.props.path, ".svelte-kit-sst", "server", "lambda-handler", "index.handler"),
43
+ runtime,
44
+ memorySize,
45
+ timeout,
46
+ bind,
47
+ environment,
48
+ permissions,
49
+ nodejs: {
50
+ format: "esm",
51
+ ...nodejs,
52
+ esbuild: {
53
+ minify: process.env.SST_DEBUG ? false : true,
54
+ sourcemap: process.env.SST_DEBUG ? "inline" : false,
55
+ define: {
56
+ "process.env.SST_DEBUG": process.env.SST_DEBUG ? "true" : "false",
57
+ },
58
+ ...nodejs?.esbuild,
59
+ },
60
+ },
61
+ copyFiles: [
62
+ {
63
+ from: path.join(this.props.path, ".svelte-kit-sst", "prerendered"),
64
+ to: "prerendered",
65
+ },
66
+ ],
67
+ ...cdk?.server,
68
+ });
69
+ return ssrFn.function;
70
+ }
71
+ createFunctionForEdge() {
72
+ const { runtime, timeout, memorySize, bind, permissions, environment, nodejs, } = this.props;
73
+ return new EdgeFunction(this, `Server`, {
74
+ scopeOverride: this,
75
+ handler: path.join(this.props.path, ".svelte-kit-sst", "server", "lambda-handler", "index.handler"),
76
+ runtime,
77
+ timeout,
78
+ memorySize,
79
+ bind,
80
+ environment,
81
+ permissions,
82
+ nodejs: {
83
+ format: "esm",
84
+ ...nodejs,
85
+ esbuild: {
86
+ minify: process.env.SST_DEBUG ? false : true,
87
+ sourcemap: process.env.SST_DEBUG ? "inline" : false,
88
+ define: {
89
+ "process.env.SST_DEBUG": process.env.SST_DEBUG ? "true" : "false",
90
+ },
91
+ ...nodejs?.esbuild,
92
+ },
93
+ },
94
+ });
95
+ }
96
+ generateBuildId() {
97
+ const filePath = path.join(this.props.path, ".svelte-kit-sst/client/_app/version.json");
98
+ const content = fs.readFileSync(filePath).toString();
99
+ return JSON.parse(content).version;
100
+ }
101
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./SvelteKitSite.js";
2
+ export * from "./SsrSite.js";
@@ -0,0 +1,2 @@
1
+ export * from "./SvelteKitSite.js";
2
+ export * from "./SsrSite.js";
@@ -309,7 +309,7 @@ export class NextjsSite extends Construct {
309
309
  // Create function asset
310
310
  const assetPath = hasRealCode && this.buildOutDir
311
311
  ? path.join(this.buildOutDir, handlerPath)
312
- : path.join(__dirname, "../../support/sls-nextjs-site-function-stub");
312
+ : path.join(__dirname, "../../support/ssr-site-function-stub");
313
313
  const asset = new s3Assets.Asset(this, `${name}FunctionAsset`, {
314
314
  path: assetPath,
315
315
  });
@@ -22,6 +22,7 @@ export * from "./NextjsSite.js";
22
22
  export * from "./RemixSite.js";
23
23
  export * from "./SolidStartSite.js";
24
24
  export * from "./StaticSite.js";
25
+ export * from "./SvelteKitSite.js";
25
26
  export * from "./util/size.js";
26
27
  export * from "./util/duration.js";
27
28
  export * from "./util/permission.js";
@@ -22,6 +22,7 @@ export * from "./NextjsSite.js";
22
22
  export * from "./RemixSite.js";
23
23
  export * from "./SolidStartSite.js";
24
24
  export * from "./StaticSite.js";
25
+ export * from "./SvelteKitSite.js";
25
26
  export * from "./util/size.js";
26
27
  export * from "./util/duration.js";
27
28
  export * from "./util/permission.js";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,51 @@
1
+ const a = [
2
+ "_app/immutable/assets/_layout.2f593b13.css",
3
+ "_app/immutable/assets/_page.265a38f0.css",
4
+ "_app/immutable/assets/_page.89a9e780.css",
5
+ "_app/immutable/assets/_page.9d501049.css",
6
+ "_app/immutable/assets/fira-mono-all-400-normal.1e3b098c.woff",
7
+ "_app/immutable/assets/fira-mono-cyrillic-400-normal.c7d433fd.woff2",
8
+ "_app/immutable/assets/fira-mono-cyrillic-ext-400-normal.3df7909e.woff2",
9
+ "_app/immutable/assets/fira-mono-greek-400-normal.a8be01ce.woff2",
10
+ "_app/immutable/assets/fira-mono-greek-ext-400-normal.9e2fe623.woff2",
11
+ "_app/immutable/assets/fira-mono-latin-400-normal.e43b3538.woff2",
12
+ "_app/immutable/assets/fira-mono-latin-ext-400-normal.6bfabd30.woff2",
13
+ "_app/immutable/assets/github.1ea8d62e.svg",
14
+ "_app/immutable/assets/svelte-logo.87df40b8.svg",
15
+ "_app/immutable/assets/svelte-welcome.6c300099.png",
16
+ "_app/immutable/assets/svelte-welcome.c18bcf5a.webp",
17
+ "_app/immutable/assets/_layout.fa9427ff.css",
18
+ "_app/immutable/chunks/0.7f85a543.js",
19
+ "_app/immutable/chunks/1.738ccc86.js",
20
+ "_app/immutable/chunks/2.d07a3f09.js",
21
+ "_app/immutable/chunks/3.0efc1f6a.js",
22
+ "_app/immutable/chunks/4.bfbd068e.js",
23
+ "_app/immutable/chunks/5.2a8a9ad4.js",
24
+ "_app/immutable/chunks/_page.1806d283.js",
25
+ "_app/immutable/chunks/_page.40474c2a.js",
26
+ "_app/immutable/chunks/_page.da46b06b.js",
27
+ "_app/immutable/chunks/environment.9aa685ef.js",
28
+ "_app/immutable/chunks/index.b0aa1c80.js",
29
+ "_app/immutable/chunks/index.cb779306.js",
30
+ "_app/immutable/chunks/parse.d12b0d5b.js",
31
+ "_app/immutable/chunks/singletons.f0ecbf4a.js",
32
+ "_app/immutable/chunks/stores.c25ce8c1.js",
33
+ "_app/immutable/entry/_layout.svelte.831a1d97.js",
34
+ "_app/immutable/entry/_page.svelte.097e6a34.js",
35
+ "_app/immutable/entry/_page.ts.9c5eea7e.js",
36
+ "_app/immutable/entry/about-page.svelte.adb87672.js",
37
+ "_app/immutable/entry/about-page.ts.13bb5e39.js",
38
+ "_app/immutable/entry/app.dc82e134.js",
39
+ "_app/immutable/entry/error.svelte.02b0c44a.js",
40
+ "_app/immutable/entry/start.ace7d4ec.js",
41
+ "_app/immutable/entry/sverdle-how-to-play-page.svelte.2a60bb43.js",
42
+ "_app/immutable/entry/sverdle-how-to-play-page.ts.13bb5e39.js",
43
+ "_app/immutable/entry/sverdle-page.svelte.e6b731c7.js",
44
+ "_app/version.json",
45
+ "favicon.png",
46
+ "robots.txt",
47
+ "about.html",
48
+ "index.html",
49
+ "sverdle/how-to-play.html",
50
+ ];
51
+ export {};
@@ -8,15 +8,6 @@ Object.assign(Config, metadata, parameters, secrets);
8
8
  // Functions
9
9
  ///////////////
10
10
  function parseMetadataEnvironment() {
11
- // If SST_APP and SST_STAGE are not set, it is likely the
12
- // user is using an older version of SST.
13
- const errorMsg = "This is usually the case when you are using an older version of SST. Please update SST to the latest version to use the SST Config feature.";
14
- if (!process.env.SST_APP) {
15
- throw new Error(`Cannot find the SST_APP environment variable. ${errorMsg}`);
16
- }
17
- if (!process.env.SST_STAGE) {
18
- throw new Error(`Cannot find the SST_STAGE environment variable. ${errorMsg}`);
19
- }
20
11
  return {
21
12
  APP: process.env.SST_APP,
22
13
  STAGE: process.env.SST_STAGE,
@@ -1,18 +1,18 @@
1
1
  export interface StaticSiteResources {
2
2
  }
3
- export interface ReactStaticSiteResources {
4
- }
5
- export interface ViteStaticSiteResources {
6
- }
7
3
  export interface NextjsSiteResources {
8
4
  }
5
+ export interface AstroSiteResources {
6
+ }
9
7
  export interface RemixSiteResources {
10
8
  }
11
9
  export interface SolidStartSiteResources {
12
10
  }
11
+ export interface SvelteKitSiteResources {
12
+ }
13
13
  export declare const StaticSite: StaticSiteResources;
14
- export declare const ReactStaticSite: ReactStaticSiteResources;
15
- export declare const ViteStaticSite: ViteStaticSiteResources;
14
+ export declare const AstroSite: AstroSiteResources;
16
15
  export declare const RemixSite: RemixSiteResources;
17
16
  export declare const NextjsSite: NextjsSiteResources;
18
17
  export declare const SolidStartSite: SolidStartSiteResources;
18
+ export declare const SvelteKitSite: SvelteKitSiteResources;
@@ -1,12 +1,9 @@
1
1
  import { createProxy } from "../util/index.js";
2
2
  export const StaticSite =
3
3
  /* @__PURE__ */ createProxy("StaticSite");
4
- export const ReactStaticSite =
4
+ export const AstroSite =
5
5
  /* @__PURE__ */
6
- createProxy("ReactStaticSite");
7
- export const ViteStaticSite =
8
- /* @__PURE__ */
9
- createProxy("ViteStaticSite");
6
+ createProxy("AstroSite");
10
7
  export const RemixSite =
11
8
  /* @__PURE__ */
12
9
  createProxy("RemixSite");
@@ -16,3 +13,6 @@ createProxy("NextjsSite");
16
13
  export const SolidStartSite =
17
14
  /* @__PURE__ */
18
15
  createProxy("SolidStartSite");
16
+ export const SvelteKitSite =
17
+ /* @__PURE__ */
18
+ createProxy("SvelteKitSite");
@@ -17,6 +17,17 @@ export function createProxy(constructName) {
17
17
  const result = new Proxy({}, {
18
18
  get(target, prop) {
19
19
  if (typeof prop === "string") {
20
+ // If SST_APP and SST_STAGE are not set, it is likely the
21
+ // user is using an older version of SST.
22
+ // Note: cannot run this check at the top level b/c SvelteKit
23
+ // run code analysis after build. The code analysis runs
24
+ // the top level code, and would fail b/c "SST_APP" and
25
+ // "SST_STAGE" are undefined at build time.
26
+ for (const builtInEnv of ["SST_APP", "SST_STAGE"]) {
27
+ if (!process.env[builtInEnv]) {
28
+ throw new Error(`Cannot find the ${builtInEnv} environment variable. This is usually the case when you are using an older version of SST. Please update SST to the latest version to use the SST Config feature.`);
29
+ }
30
+ }
20
31
  // normalize prop to convert kebab cases like `my-table` to `my_table`
21
32
  const normProp = normalizeId(prop);
22
33
  if (!(normProp in target)) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "sideEffects": false,
3
3
  "name": "sst",
4
- "version": "2.7.2",
4
+ "version": "2.8.1",
5
5
  "bin": {
6
6
  "sst": "cli/sst.js"
7
7
  },
@@ -10,7 +10,7 @@
10
10
  "license": "MIT",
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git+https://github.com/estyrke/serverless-stack.git",
13
+ "url": "git+https://github.com/serverless-stack/sst.git",
14
14
  "directory": "packages/cli"
15
15
  },
16
16
  "exports": {
package/sst.mjs CHANGED
@@ -6731,7 +6731,7 @@ var init_config = __esm({
6731
6731
  async function restart(keys) {
6732
6732
  const metadata3 = await stacks_exports.metadata();
6733
6733
  const siteData = Object.values(metadata3).flat().filter(
6734
- (c) => c.type === "AstroSite" || c.type === "NextjsSite" || c.type === "RemixSite" || c.type === "SolidStartSite"
6734
+ (c) => c.type === "AstroSite" || c.type === "NextjsSite" || c.type === "RemixSite" || c.type === "SolidStartSite" || c.type === "SvelteKitSite"
6735
6735
  ).filter((c) => keys.some((key) => c.data.secrets.includes(key)));
6736
6736
  const siteDataPlaceholder = siteData.filter(
6737
6737
  (c) => c.data.mode === "placeholder"
@@ -7038,7 +7038,7 @@ var dev = (program2) => program2.command(
7038
7038
  if (!lastDeployed) {
7039
7039
  await saveAppMetadata2({ mode: "dev" });
7040
7040
  useSites().all.filter(({ props }) => props.dev?.deploy !== true).forEach(({ type, props }) => {
7041
- const framework = type === "AstroSite" ? "Astro" : type === "NextjsSite" ? "Next.js" : type === "RemixSite" ? "Remix" : type === "SolidStartSite" ? "SolidStart" : void 0;
7041
+ const framework = type === "AstroSite" ? "Astro" : type === "NextjsSite" ? "Next.js" : type === "RemixSite" ? "Remix" : type === "SolidStartSite" ? "SolidStart" : type === "SvelteKitSite" ? "SvelteKit" : void 0;
7042
7042
  if (framework) {
7043
7043
  const cdCmd = path20.resolve(props.path) === process.cwd() ? "" : `cd ${props.path} && `;
7044
7044
  Colors2.line(
@@ -7351,6 +7351,7 @@ var bind = (program2) => program2.command(
7351
7351
  "AstroSite",
7352
7352
  "RemixSite",
7353
7353
  "SolidStartSite",
7354
+ "SvelteKitSite",
7354
7355
  "SlsNextjsSite"
7355
7356
  ].includes(c.type)
7356
7357
  ).find((c) => {
@@ -7914,6 +7915,7 @@ var PACKAGE_MATCH = [
7914
7915
  "aws-cdk",
7915
7916
  "@aws-cdk",
7916
7917
  "constructs",
7918
+ "svelte-kit-sst",
7917
7919
  "solid-start-sst"
7918
7920
  ];
7919
7921
  var FIELDS = ["dependencies", "devDependencies"];