@awsless/cli 0.0.40 → 0.0.42

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 CHANGED
@@ -1205,6 +1205,9 @@ var LayersSchema = z15.string().array().describe(
1205
1205
  var FileCodeSchema = z15.object({
1206
1206
  file: LocalFileSchema.describe("The file path of the function code."),
1207
1207
  minify: MinifySchema.optional().default(true),
1208
+ moduleSideEffects: RelativePathSchema.array().default([]).describe(
1209
+ `A list of glob patterns for modules that should be flagged as having potential side effects. For example "./.svelte-kit/**" will flag every file inside the .svelte-kit folder.`
1210
+ ),
1208
1211
  external: z15.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`),
1209
1212
  importAsString: z15.string().array().optional().describe(`A list of glob patterns, which specifies the files that should be imported as string.`)
1210
1213
  });
@@ -3726,18 +3729,30 @@ var zipBundle = async ({ directory }) => {
3726
3729
 
3727
3730
  // src/feature/function/build/typescript/rolldown.ts
3728
3731
  import { createHash as createHash2 } from "crypto";
3732
+ import { Minimatch } from "minimatch";
3729
3733
  import { rolldown } from "rolldown";
3730
3734
  import { importAsString } from "rollup-plugin-string-import";
3735
+ var createModuleMatcher = (patterns = []) => {
3736
+ const globs = patterns.map((pattern) => {
3737
+ return new Minimatch(pattern.replaceAll("\\", "/"), { dot: true });
3738
+ });
3739
+ return (id) => {
3740
+ const path = id.replaceAll("\\", "/");
3741
+ return globs.some((glob6) => glob6.match(path));
3742
+ };
3743
+ };
3731
3744
  var bundleTypeScriptWithRolldown = async ({
3732
3745
  format: format3 = "esm",
3733
3746
  minify = true,
3734
3747
  file,
3735
3748
  nativeDir,
3736
3749
  external,
3750
+ moduleSideEffects,
3737
3751
  externalAwsSdk = true,
3738
3752
  codeSplitting = true,
3739
3753
  importAsString: importAsStringList
3740
3754
  }) => {
3755
+ const hasModuleSideEffects = createModuleMatcher(moduleSideEffects);
3741
3756
  const bundle = await rolldown({
3742
3757
  input: file,
3743
3758
  platform: "node",
@@ -3748,7 +3763,7 @@ var bundleTypeScriptWithRolldown = async ({
3748
3763
  debugError(error.message);
3749
3764
  },
3750
3765
  treeshake: {
3751
- moduleSideEffects: (id) => file === id
3766
+ moduleSideEffects: (id) => file === id || hasModuleSideEffects(id)
3752
3767
  },
3753
3768
  plugins: [
3754
3769
  // nodeResolve({ preferBuiltins: true }),
@@ -3836,6 +3851,7 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
3836
3851
  ...fileCode.external ?? [],
3837
3852
  ...(props.layers ?? []).flatMap((id2) => ctx.shared.entry("layer", `packages`, id2))
3838
3853
  ],
3854
+ moduleSideEffects: fileCode.moduleSideEffects,
3839
3855
  minify: fileCode.minify,
3840
3856
  nativeDir: temp.path,
3841
3857
  importAsString: fileCode.importAsString
@@ -259,6 +259,9 @@ var LayersSchema = z11.string().array().describe(
259
259
  var FileCodeSchema = z11.object({
260
260
  file: LocalFileSchema.describe("The file path of the function code."),
261
261
  minify: MinifySchema.optional().default(true),
262
+ moduleSideEffects: RelativePathSchema.array().default([]).describe(
263
+ `A list of glob patterns for modules that should be flagged as having potential side effects. For example "./.svelte-kit/**" will flag every file inside the .svelte-kit folder.`
264
+ ),
262
265
  external: z11.string().array().optional().describe(`A list of external packages that won't be included in the bundle.`),
263
266
  importAsString: z11.string().array().optional().describe(`A list of glob patterns, which specifies the files that should be imported as string.`)
264
267
  });
@@ -1993,6 +1996,7 @@ var generateJsonSchema = (props) => {
1993
1996
  var appendDefaults = (object) => {
1994
1997
  if (Array.isArray(object)) {
1995
1998
  object.forEach(appendDefaults);
1999
+ return;
1996
2000
  }
1997
2001
  if (typeof object === "object" && object !== null) {
1998
2002
  if ("default" in object && "type" in object) {
Binary file
Binary file
Binary file
Binary file
package/dist/prebuild.js CHANGED
@@ -12,6 +12,7 @@ import { join } from "path";
12
12
 
13
13
  // src/feature/function/build/typescript/rolldown.ts
14
14
  import { createHash } from "crypto";
15
+ import { Minimatch } from "minimatch";
15
16
  import { rolldown } from "rolldown";
16
17
  import { importAsString } from "rollup-plugin-string-import";
17
18
 
@@ -45,16 +46,27 @@ var debugError = (error) => {
45
46
  };
46
47
 
47
48
  // src/feature/function/build/typescript/rolldown.ts
49
+ var createModuleMatcher = (patterns = []) => {
50
+ const globs = patterns.map((pattern) => {
51
+ return new Minimatch(pattern.replaceAll("\\", "/"), { dot: true });
52
+ });
53
+ return (id) => {
54
+ const path = id.replaceAll("\\", "/");
55
+ return globs.some((glob) => glob.match(path));
56
+ };
57
+ };
48
58
  var bundleTypeScriptWithRolldown = async ({
49
59
  format = "esm",
50
60
  minify = true,
51
61
  file,
52
62
  nativeDir,
53
63
  external,
64
+ moduleSideEffects,
54
65
  externalAwsSdk = true,
55
66
  codeSplitting = true,
56
67
  importAsString: importAsStringList
57
68
  }) => {
69
+ const hasModuleSideEffects = createModuleMatcher(moduleSideEffects);
58
70
  const bundle = await rolldown({
59
71
  input: file,
60
72
  platform: "node",
@@ -65,7 +77,7 @@ var bundleTypeScriptWithRolldown = async ({
65
77
  debugError(error.message);
66
78
  },
67
79
  treeshake: {
68
- moduleSideEffects: (id) => file === id
80
+ moduleSideEffects: (id) => file === id || hasModuleSideEffects(id)
69
81
  },
70
82
  plugins: [
71
83
  // nodeResolve({ preferBuiltins: true }),