sst 2.0.0-rc.15 → 2.0.0-rc.17
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.
- package/cli/local/server.js +4 -9
- package/constructs/NextjsSite.d.ts +1 -1
- package/constructs/ReactStaticSite.d.ts +1 -1
- package/constructs/ReactStaticSite.js +2 -1
- package/constructs/SsrSite.d.ts +6 -3
- package/constructs/SsrSite.js +6 -6
- package/constructs/StaticSite.d.ts +3 -3
- package/constructs/StaticSite.js +8 -8
- package/constructs/ViteStaticSite.d.ts +1 -1
- package/constructs/ViteStaticSite.js +2 -1
- package/package.json +1 -1
- package/sst.mjs +9 -0
package/cli/local/server.js
CHANGED
|
@@ -23,17 +23,12 @@ export async function useLocalServer(opts) {
|
|
|
23
23
|
functions: {},
|
|
24
24
|
};
|
|
25
25
|
const rest = express();
|
|
26
|
-
/*
|
|
27
26
|
rest.all(`/ping`, (req, res) => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
req.header("access-control-request-headers")
|
|
33
|
-
);
|
|
34
|
-
res.sendStatus(200);
|
|
27
|
+
res.header("Access-Control-Allow-Origin", "*");
|
|
28
|
+
res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
|
|
29
|
+
res.header("Access-Control-Allow-Headers", req.header("access-control-request-headers"));
|
|
30
|
+
res.sendStatus(200);
|
|
35
31
|
});
|
|
36
|
-
*/
|
|
37
32
|
rest.all(`/proxy*`, express.raw({
|
|
38
33
|
type: "*/*",
|
|
39
34
|
limit: "1024mb",
|
|
@@ -16,7 +16,7 @@ export interface NextjsSiteProps extends Omit<SsrSiteProps, "edge"> {
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare class NextjsSite extends SsrSite {
|
|
19
|
-
constructor(scope: Construct, id: string, props
|
|
19
|
+
constructor(scope: Construct, id: string, props?: NextjsSiteProps);
|
|
20
20
|
protected initBuildConfig(): {
|
|
21
21
|
serverBuildOutputFile: string;
|
|
22
22
|
clientBuildOutputDir: string;
|
|
@@ -16,5 +16,5 @@ export declare type ReactStaticSiteProps = StaticSiteProps;
|
|
|
16
16
|
* ```
|
|
17
17
|
*/
|
|
18
18
|
export declare class ReactStaticSite extends StaticSite implements SSTConstruct {
|
|
19
|
-
constructor(scope: Construct, id: string, props
|
|
19
|
+
constructor(scope: Construct, id: string, props?: ReactStaticSiteProps);
|
|
20
20
|
}
|
|
@@ -19,7 +19,8 @@ import { StaticSite } from "./StaticSite.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export class ReactStaticSite extends StaticSite {
|
|
21
21
|
constructor(scope, id, props) {
|
|
22
|
-
const { path:
|
|
22
|
+
const { path: pathRaw, environment } = props || {};
|
|
23
|
+
const sitePath = pathRaw || ".";
|
|
23
24
|
// Validate environment
|
|
24
25
|
Object.keys(environment || {}).forEach((key) => {
|
|
25
26
|
if (!key.startsWith("REACT_APP_")) {
|
package/constructs/SsrSite.d.ts
CHANGED
|
@@ -28,8 +28,9 @@ export interface SsrSiteProps {
|
|
|
28
28
|
edge?: boolean;
|
|
29
29
|
/**
|
|
30
30
|
* Path to the directory where the app is located.
|
|
31
|
+
* @default "."
|
|
31
32
|
*/
|
|
32
|
-
path
|
|
33
|
+
path?: string;
|
|
33
34
|
/**
|
|
34
35
|
* The command for building the website
|
|
35
36
|
* @default `npm run build`
|
|
@@ -161,7 +162,9 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
161
162
|
*/
|
|
162
163
|
certificate?: acm.ICertificate;
|
|
163
164
|
};
|
|
164
|
-
protected props: SsrSiteProps
|
|
165
|
+
protected props: Omit<SsrSiteProps, "path"> & {
|
|
166
|
+
path: string;
|
|
167
|
+
};
|
|
165
168
|
/**
|
|
166
169
|
* Determines if a placeholder site should be deployed instead. We will set
|
|
167
170
|
* this to `true` by default when performing local development, although the
|
|
@@ -176,7 +179,7 @@ export declare class SsrSite extends Construct implements SSTConstruct {
|
|
|
176
179
|
private serverLambdaForEdge?;
|
|
177
180
|
protected serverLambdaForRegional?: lambda.Function;
|
|
178
181
|
private awsCliLayer;
|
|
179
|
-
constructor(scope: Construct, id: string, props
|
|
182
|
+
constructor(scope: Construct, id: string, props?: SsrSiteProps);
|
|
180
183
|
/**
|
|
181
184
|
* The CloudFront URL of the website.
|
|
182
185
|
*/
|
package/constructs/SsrSite.js
CHANGED
|
@@ -60,13 +60,13 @@ export class SsrSite extends Construct {
|
|
|
60
60
|
serverLambdaForRegional;
|
|
61
61
|
awsCliLayer;
|
|
62
62
|
constructor(scope, id, props) {
|
|
63
|
-
super(scope, props
|
|
64
|
-
this.id = id;
|
|
63
|
+
super(scope, props?.cdk?.id || id);
|
|
65
64
|
const app = scope.node.root;
|
|
65
|
+
this.id = id;
|
|
66
|
+
this.props = { path: ".", ...props };
|
|
66
67
|
this.isPlaceholder =
|
|
67
|
-
(app.local || app.skipBuild) && !props.disablePlaceholder;
|
|
68
|
+
(app.local || app.skipBuild) && !this.props.disablePlaceholder;
|
|
68
69
|
this.sstBuildDir = useProject().paths.artifacts;
|
|
69
|
-
this.props = props;
|
|
70
70
|
this.cdk = {};
|
|
71
71
|
this.awsCliLayer = new AwsCliLayer(this, "AwsCliLayer");
|
|
72
72
|
this.validateSiteExists();
|
|
@@ -79,7 +79,7 @@ export class SsrSite extends Construct {
|
|
|
79
79
|
// Create Bucket which will be utilised to contain the statics
|
|
80
80
|
this.cdk.bucket = this.createS3Bucket();
|
|
81
81
|
// Create Server functions
|
|
82
|
-
if (props.edge) {
|
|
82
|
+
if (this.props.edge) {
|
|
83
83
|
this.serverLambdaForEdge = this.createFunctionForEdge();
|
|
84
84
|
this.createFunctionPermissionsForEdge();
|
|
85
85
|
}
|
|
@@ -99,7 +99,7 @@ export class SsrSite extends Construct {
|
|
|
99
99
|
const s3deployCR = this.createS3Deployment(assets);
|
|
100
100
|
// Create CloudFront
|
|
101
101
|
this.validateCloudFrontDistributionSettings();
|
|
102
|
-
if (props.edge) {
|
|
102
|
+
if (this.props.edge) {
|
|
103
103
|
this.cdk.distribution = this.isPlaceholder
|
|
104
104
|
? this.createCloudFrontDistributionForStub()
|
|
105
105
|
: this.createCloudFrontDistributionForEdge();
|
|
@@ -14,7 +14,7 @@ export interface StaticSiteFileOptions {
|
|
|
14
14
|
export interface StaticSiteProps {
|
|
15
15
|
/**
|
|
16
16
|
* Path to the directory where the website source is located.
|
|
17
|
-
*
|
|
17
|
+
* @default "."
|
|
18
18
|
* @example
|
|
19
19
|
* ```js
|
|
20
20
|
* new StaticSite(stack, "Site", {
|
|
@@ -22,7 +22,7 @@ export interface StaticSiteProps {
|
|
|
22
22
|
* });
|
|
23
23
|
* ```
|
|
24
24
|
*/
|
|
25
|
-
path
|
|
25
|
+
path?: string;
|
|
26
26
|
/**
|
|
27
27
|
* The name of the index page (e.g. "index.html") of the website.
|
|
28
28
|
* @default "index.html"
|
|
@@ -300,7 +300,7 @@ export declare class StaticSite extends Construct implements SSTConstruct {
|
|
|
300
300
|
private assets;
|
|
301
301
|
private filenamesAsset?;
|
|
302
302
|
private awsCliLayer;
|
|
303
|
-
constructor(scope: Construct, id: string, props
|
|
303
|
+
constructor(scope: Construct, id: string, props?: StaticSiteProps);
|
|
304
304
|
/**
|
|
305
305
|
* The CloudFront URL of the website.
|
|
306
306
|
*/
|
package/constructs/StaticSite.js
CHANGED
|
@@ -51,19 +51,19 @@ export class StaticSite extends Construct {
|
|
|
51
51
|
filenamesAsset;
|
|
52
52
|
awsCliLayer;
|
|
53
53
|
constructor(scope, id, props) {
|
|
54
|
-
super(scope, props
|
|
54
|
+
super(scope, props?.cdk?.id || id);
|
|
55
|
+
const app = scope.node.root;
|
|
55
56
|
this.id = id;
|
|
56
|
-
|
|
57
|
+
this.props = { path: ".", ...props };
|
|
58
|
+
this.cdk = {};
|
|
57
59
|
// Local development or skip build => stub asset
|
|
58
60
|
this.isPlaceholder =
|
|
59
|
-
(
|
|
60
|
-
const fileSizeLimit =
|
|
61
|
+
(app.local || app.skipBuild) && !this.props.disablePlaceholder;
|
|
62
|
+
const fileSizeLimit = app.isRunningSSTTest()
|
|
61
63
|
? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
62
64
|
// @ts-ignore: "sstTestFileSizeLimitOverride" not exposed in props
|
|
63
|
-
props.sstTestFileSizeLimitOverride || 200
|
|
65
|
+
this.props.sstTestFileSizeLimitOverride || 200
|
|
64
66
|
: 200;
|
|
65
|
-
this.props = props;
|
|
66
|
-
this.cdk = {};
|
|
67
67
|
this.awsCliLayer = new AwsCliLayer(this, "AwsCliLayer");
|
|
68
68
|
this.registerSiteEnvironment();
|
|
69
69
|
// Validate input
|
|
@@ -237,7 +237,7 @@ interface ImportMeta {
|
|
|
237
237
|
throw new Error(`No build output found at "${siteOutputPath}" for the "${this.node.id}" StaticSite.`);
|
|
238
238
|
}
|
|
239
239
|
// create zip files
|
|
240
|
-
const script = path.join(__dirname, "../support/base-site-archiver.
|
|
240
|
+
const script = path.join(__dirname, "../support/base-site-archiver.mjs");
|
|
241
241
|
const zipPath = path.resolve(path.join(useProject().paths.artifacts, `StaticSite-${this.node.id}-${this.node.addr}`));
|
|
242
242
|
// clear zip path to ensure no partX.zip remain from previous build
|
|
243
243
|
fs.rmSync(zipPath, {
|
|
@@ -28,5 +28,5 @@ export interface ViteStaticSiteProps extends StaticSiteProps {
|
|
|
28
28
|
* ```
|
|
29
29
|
*/
|
|
30
30
|
export declare class ViteStaticSite extends StaticSite {
|
|
31
|
-
constructor(scope: Construct, id: string, props
|
|
31
|
+
constructor(scope: Construct, id: string, props?: ViteStaticSiteProps);
|
|
32
32
|
}
|
|
@@ -19,7 +19,8 @@ import { StaticSite } from "./StaticSite.js";
|
|
|
19
19
|
*/
|
|
20
20
|
export class ViteStaticSite extends StaticSite {
|
|
21
21
|
constructor(scope, id, props) {
|
|
22
|
-
const { path:
|
|
22
|
+
const { path: pathRaw, environment, typesPath } = props || {};
|
|
23
|
+
const sitePath = pathRaw || ".";
|
|
23
24
|
// generate buildCommand
|
|
24
25
|
let defaultBuildCommand = "npm run build";
|
|
25
26
|
if (fs.existsSync(path.join(sitePath, "yarn.lock"))) {
|
package/package.json
CHANGED
package/sst.mjs
CHANGED
|
@@ -20263,6 +20263,15 @@ async function useLocalServer(opts) {
|
|
|
20263
20263
|
functions: {}
|
|
20264
20264
|
};
|
|
20265
20265
|
const rest = express2();
|
|
20266
|
+
rest.all(`/ping`, (req, res) => {
|
|
20267
|
+
res.header("Access-Control-Allow-Origin", "*");
|
|
20268
|
+
res.header("Access-Control-Allow-Methods", "GET, PUT, PATCH, POST, DELETE");
|
|
20269
|
+
res.header(
|
|
20270
|
+
"Access-Control-Allow-Headers",
|
|
20271
|
+
req.header("access-control-request-headers")
|
|
20272
|
+
);
|
|
20273
|
+
res.sendStatus(200);
|
|
20274
|
+
});
|
|
20266
20275
|
rest.all(
|
|
20267
20276
|
`/proxy*`,
|
|
20268
20277
|
express2.raw({
|