@awsless/awsless 0.0.46 → 0.0.48
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/dist/bin.js +16 -5
- package/dist/features/upload-bucket-asset.js +11 -5
- package/dist/index.d.ts +181 -0
- package/package.json +3 -3
package/dist/bin.js
CHANGED
|
@@ -798,7 +798,7 @@ var formatByteSize = (size) => {
|
|
|
798
798
|
// src/formation/resource/lambda/util/rollup.ts
|
|
799
799
|
import { rollup } from "rollup";
|
|
800
800
|
import { createHash } from "crypto";
|
|
801
|
-
import { swc } from "rollup-plugin-swc3";
|
|
801
|
+
import { swc, minify as swcMinify } from "rollup-plugin-swc3";
|
|
802
802
|
import json from "@rollup/plugin-json";
|
|
803
803
|
import commonjs from "@rollup/plugin-commonjs";
|
|
804
804
|
import nodeResolve from "@rollup/plugin-node-resolve";
|
|
@@ -822,13 +822,18 @@ var rollupBundle = ({ format: format2 = "esm", minify = true, handler = "index.d
|
|
|
822
822
|
// @ts-ignore
|
|
823
823
|
nodeResolve({ preferBuiltins: true }),
|
|
824
824
|
swc({
|
|
825
|
-
minify,
|
|
825
|
+
// minify,
|
|
826
|
+
// module: true,
|
|
826
827
|
jsc: {
|
|
827
828
|
baseUrl: dirname(input),
|
|
828
829
|
minify: { sourceMap: true }
|
|
829
830
|
},
|
|
830
831
|
sourceMaps: true
|
|
831
832
|
}),
|
|
833
|
+
minify ? swcMinify({
|
|
834
|
+
module: format2 === "esm",
|
|
835
|
+
sourceMap: true
|
|
836
|
+
}) : void 0,
|
|
832
837
|
// @ts-ignore
|
|
833
838
|
json()
|
|
834
839
|
]
|
|
@@ -1234,8 +1239,10 @@ var FunctionSchema = z6.union([
|
|
|
1234
1239
|
z6.object({
|
|
1235
1240
|
/** The file path of the function code. */
|
|
1236
1241
|
file: LocalFileSchema,
|
|
1237
|
-
|
|
1238
|
-
|
|
1242
|
+
/** The name of the exported method within your code that Lambda calls to run your function.
|
|
1243
|
+
* @default 'default'
|
|
1244
|
+
*/
|
|
1245
|
+
handler: z6.string().optional(),
|
|
1239
1246
|
/** Put the function inside your global VPC.
|
|
1240
1247
|
* @default false
|
|
1241
1248
|
*/
|
|
@@ -1297,6 +1304,10 @@ var isFunctionProps = (input) => {
|
|
|
1297
1304
|
var schema = z6.object({
|
|
1298
1305
|
defaults: z6.object({
|
|
1299
1306
|
function: z6.object({
|
|
1307
|
+
/** The name of the exported method within your code that Lambda calls to run your function.
|
|
1308
|
+
* @default 'default'
|
|
1309
|
+
*/
|
|
1310
|
+
handler: z6.string().default("default"),
|
|
1300
1311
|
/** Put the function inside your global VPC.
|
|
1301
1312
|
* @default false
|
|
1302
1313
|
*/
|
|
@@ -1421,7 +1432,7 @@ var toLambdaFunction = (ctx, id, fileOrProps) => {
|
|
|
1421
1432
|
const props = typeof fileOrProps === "string" ? { ...config.defaults?.function, file: fileOrProps } : { ...config.defaults?.function, ...fileOrProps };
|
|
1422
1433
|
const lambda = new Function(id, {
|
|
1423
1434
|
name: `${config.name}-${stack.name}-${id}`,
|
|
1424
|
-
code: Code.fromFile(id, props.file),
|
|
1435
|
+
code: Code.fromFile(id, props.file, rollupBundle({ handler: `index.${props.handler}` })),
|
|
1425
1436
|
...props,
|
|
1426
1437
|
vpc: void 0
|
|
1427
1438
|
});
|
|
@@ -9,7 +9,7 @@ import require$$0$2 from 'buffer';
|
|
|
9
9
|
import require$$0$3 from 'constants';
|
|
10
10
|
import require$$6 from 'assert';
|
|
11
11
|
import require$$0$5, { join as join$1, extname } from 'path';
|
|
12
|
-
import { readdir } from 'fs/promises';
|
|
12
|
+
import { readdir, stat } from 'fs/promises';
|
|
13
13
|
import { createHash } from 'crypto';
|
|
14
14
|
import { Upload } from '@aws-sdk/lib-storage';
|
|
15
15
|
|
|
@@ -28335,15 +28335,21 @@ const createETag = async (file)=>{
|
|
|
28335
28335
|
return hash.digest('hex');
|
|
28336
28336
|
};
|
|
28337
28337
|
const listLocalFiles = async (localDirectory)=>{
|
|
28338
|
-
const
|
|
28338
|
+
const paths = await readdir(localDirectory, {
|
|
28339
28339
|
recursive: true
|
|
28340
28340
|
});
|
|
28341
|
-
|
|
28342
|
-
|
|
28341
|
+
const files = [];
|
|
28342
|
+
await Promise.all(paths.map(async (key)=>{
|
|
28343
|
+
const stats = await stat(key);
|
|
28344
|
+
if (!stats.isFile()) {
|
|
28345
|
+
return;
|
|
28346
|
+
}
|
|
28347
|
+
files.push({
|
|
28343
28348
|
key,
|
|
28344
28349
|
etag: await createETag(join$1(localDirectory, key))
|
|
28345
|
-
};
|
|
28350
|
+
});
|
|
28346
28351
|
}));
|
|
28352
|
+
return files;
|
|
28347
28353
|
};
|
|
28348
28354
|
const listRemoteFiles = async (bucketName)=>{
|
|
28349
28355
|
const files = [];
|