@netlify/zip-it-and-ship-it 9.6.0 → 9.8.0

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/README.md CHANGED
@@ -128,7 +128,7 @@ The following properties are accepted:
128
128
  - `nodeVersion`
129
129
 
130
130
  - _Type_: `string`\
131
- - _Default value_: `16`
131
+ - _Default value_: `18`
132
132
 
133
133
  The version of Node.js to use as the compilation target for bundlers. This is also used to determine the runtime
134
134
  reported in the manifest. Any valid and supported Node.js version is accepted. Examples:
@@ -478,9 +478,9 @@ need to be the same as the one used when installing those native modules.
478
478
 
479
479
  In Netlify, this is done by ensuring that the following Node.js versions are the same:
480
480
 
481
- - Build-time Node.js version: this defaults to Node `16`, but can be
481
+ - Build-time Node.js version: this defaults to Node `18`, but can be
482
482
  [overridden with a `.nvmrc` or `NODE_VERSION` environment variable](https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript).
483
- - Function runtime Node.js version: this defaults to `nodejs16.x` but can be
483
+ - Function runtime Node.js version: this defaults to `nodejs18.x` but can be
484
484
  [overridden with a `AWS_LAMBDA_JS_RUNTIME` environment variable](https://docs.netlify.com/functions/optional-configuration/?fn-language=js#node-js-version-for-runtime-2).
485
485
 
486
486
  Note that this problem might not apply for Node.js native modules using the [N-API](https://nodejs.org/api/n-api.html).
@@ -3,6 +3,7 @@ export declare const defaultFlags: {
3
3
  readonly parseWithEsbuild: false;
4
4
  readonly traceWithNft: false;
5
5
  readonly functions_inherit_build_nodejs_version: false;
6
+ readonly zisi_log_dynamic_imports: false;
6
7
  readonly zisi_pure_esm: false;
7
8
  readonly zisi_pure_esm_mjs: false;
8
9
  readonly zisi_output_cjs_extension: false;
@@ -16,6 +17,7 @@ export declare const getFlags: (input?: Record<string, boolean>, flags?: {
16
17
  readonly parseWithEsbuild: false;
17
18
  readonly traceWithNft: false;
18
19
  readonly functions_inherit_build_nodejs_version: false;
20
+ readonly zisi_log_dynamic_imports: false;
19
21
  readonly zisi_pure_esm: false;
20
22
  readonly zisi_pure_esm_mjs: false;
21
23
  readonly zisi_output_cjs_extension: false;
@@ -8,6 +8,9 @@ export const defaultFlags = {
8
8
  traceWithNft: false,
9
9
  // Should Lambda functions inherit the build Node.js version
10
10
  functions_inherit_build_nodejs_version: false,
11
+ // Emit a system log for every path that has been included in the bundle due
12
+ // to the parsing of a dynamic import.
13
+ zisi_log_dynamic_imports: false,
11
14
  // Output pure (i.e. untranspiled) ESM files when the function file has ESM
12
15
  // syntax and the parent `package.json` file has `{"type": "module"}`.
13
16
  zisi_pure_esm: false,
package/dist/main.d.ts CHANGED
@@ -27,13 +27,13 @@ interface ListFunctionsOptions {
27
27
  parseISC?: boolean;
28
28
  }
29
29
  export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC, }?: {
30
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
30
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_log_dynamic_imports" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
31
31
  config?: Config | undefined;
32
32
  configFileDirectories?: string[] | undefined;
33
33
  parseISC?: boolean | undefined;
34
34
  }) => Promise<ListedFunction[]>;
35
35
  export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, configFileDirectories, parseISC, }?: {
36
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
36
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_log_dynamic_imports" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
37
37
  config?: Config | undefined;
38
38
  configFileDirectories?: string[] | undefined;
39
39
  parseISC?: boolean | undefined;
@@ -11,7 +11,7 @@ export declare const getFunctionsFromPaths: (paths: string[], { cache, config, c
11
11
  config?: Config | undefined;
12
12
  configFileDirectories?: string[] | undefined;
13
13
  dedupe?: boolean | undefined;
14
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
14
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_log_dynamic_imports" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
15
15
  }) => Promise<FunctionMap>;
16
16
  /**
17
17
  * Gets a list of functions found in a list of paths.
@@ -20,6 +20,6 @@ export declare const getFunctionFromPath: (path: string, { cache, config, config
20
20
  cache: RuntimeCache;
21
21
  config?: Config | undefined;
22
22
  configFileDirectories?: string[] | undefined;
23
- featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
23
+ featureFlags?: Partial<Record<"buildRustSource" | "parseWithEsbuild" | "traceWithNft" | "functions_inherit_build_nodejs_version" | "zisi_log_dynamic_imports" | "zisi_pure_esm" | "zisi_pure_esm_mjs" | "zisi_output_cjs_extension" | "zisi_functions_api_v2" | "zisi_unique_entry_file" | "zisi_use_latest_babel_version", boolean>> | undefined;
24
24
  }) => Promise<FunctionSource | undefined>;
25
25
  export {};
@@ -1,13 +1,15 @@
1
1
  import type { FunctionConfig } from '../../../../config.js';
2
2
  import { FeatureFlags } from '../../../../feature_flags.js';
3
+ import { Logger } from '../../../../utils/logger.js';
3
4
  export declare const ESBUILD_LOG_LIMIT = 10;
4
- export declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, featureFlags, ignoredModules, mainFile, name, srcDir, srcFile, }: {
5
+ export declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, featureFlags, ignoredModules, logger, mainFile, name, srcDir, srcFile, }: {
5
6
  additionalModulePaths?: string[] | undefined;
6
7
  basePath?: string | undefined;
7
8
  config: FunctionConfig;
8
9
  externalModules: string[];
9
10
  featureFlags: FeatureFlags;
10
11
  ignoredModules: string[];
12
+ logger: Logger;
11
13
  mainFile: string;
12
14
  name: string;
13
15
  srcDir: string;
@@ -17,7 +17,7 @@ export const ESBUILD_LOG_LIMIT = 10;
17
17
  // When resolving imports with no extension (e.g. require('./foo')), these are
18
18
  // the extensions that esbuild will look for, in this order.
19
19
  const RESOLVE_EXTENSIONS = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts', '.json'];
20
- export const bundleJsFile = async function ({ additionalModulePaths, basePath, config, externalModules = [], featureFlags, ignoredModules = [], mainFile, name, srcDir, srcFile, }) {
20
+ export const bundleJsFile = async function ({ additionalModulePaths, basePath, config, externalModules = [], featureFlags, ignoredModules = [], logger, mainFile, name, srcDir, srcFile, }) {
21
21
  // We use a temporary directory as the destination for esbuild files to avoid
22
22
  // any naming conflicts with files generated by other functions.
23
23
  const targetDirectory = await tmpName();
@@ -98,6 +98,11 @@ export const bundleJsFile = async function ({ additionalModulePaths, basePath, c
98
98
  const inputs = Object.keys(metafile.inputs).map((path) => resolve(path));
99
99
  const cleanTempFiles = getCleanupFunction([...bundlePaths.keys()]);
100
100
  const additionalPaths = [...dynamicImportsIncludedPaths, ...includedFilesFromModuleDetection];
101
+ if (featureFlags.zisi_log_dynamic_imports && dynamicImportsIncludedPaths.size !== 0) {
102
+ // Capping the number of paths to avoid large log volumes.
103
+ const paths = [...dynamicImportsIncludedPaths].slice(0, 20).join(', ');
104
+ logger.system(`Functions bundling included paths by parsing dynamic import: ${paths}`);
105
+ }
101
106
  return {
102
107
  additionalPaths,
103
108
  bundlePaths,
@@ -26,7 +26,7 @@ const getExternalAndIgnoredModules = async ({ config, srcDir }) => {
26
26
  const ignoredModules = [...ignoredModulesFromConfig, ...ignoredModulesFromSpecialCases];
27
27
  return { externalModules, ignoredModules };
28
28
  };
29
- const bundle = async ({ basePath, config = {}, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, repositoryRoot, runtime, srcDir, srcPath, stat, }) => {
29
+ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename, logger, mainFile, name, pluginsModulesPath, repositoryRoot, runtime, srcDir, srcPath, stat, }) => {
30
30
  const { externalModules, ignoredModules } = await getExternalAndIgnoredModules({ config, srcDir });
31
31
  const { additionalPaths, bundlePaths, cleanTempFiles, inputs, moduleFormat, nativeNodeModules = {}, nodeModulesWithDynamicImports, outputExtension, warnings, } = await bundleJsFile({
32
32
  additionalModulePaths: pluginsModulesPath ? [pluginsModulesPath] : [],
@@ -35,6 +35,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
35
35
  externalModules,
36
36
  featureFlags,
37
37
  ignoredModules,
38
+ logger,
38
39
  mainFile,
39
40
  name,
40
41
  srcDir,
@@ -4,6 +4,7 @@ import type { FeatureFlags } from '../../../feature_flags.js';
4
4
  import type { FunctionSource } from '../../../function.js';
5
5
  import { ObjectValues } from '../../../types/utils.js';
6
6
  import type { RuntimeCache } from '../../../utils/cache.js';
7
+ import { Logger } from '../../../utils/logger.js';
7
8
  import type { ModuleFormat } from '../utils/module_format.js';
8
9
  export declare const NODE_BUNDLER: {
9
10
  readonly ESBUILD: "esbuild";
@@ -21,6 +22,7 @@ export type BundleFunction = (args: {
21
22
  cache: RuntimeCache;
22
23
  config: FunctionConfig;
23
24
  featureFlags: FeatureFlags;
25
+ logger: Logger;
24
26
  pluginsModulesPath?: string;
25
27
  repositoryRoot?: string;
26
28
  runtimeAPIVersion: number;
@@ -25,7 +25,7 @@ const getSrcFilesWithBundler = async (parameters) => {
25
25
  const result = await bundler.getSrcFiles({ ...parameters, pluginsModulesPath });
26
26
  return result.srcFiles;
27
27
  };
28
- const zipFunction = async function ({ archiveFormat, basePath, cache, config = {}, destFolder, extension, featureFlags, filename, mainFile, name, repositoryRoot, runtime, srcDir, srcPath, stat, isInternal, }) {
28
+ const zipFunction = async function ({ archiveFormat, basePath, cache, config = {}, destFolder, extension, featureFlags, filename, logger, mainFile, name, repositoryRoot, runtime, srcDir, srcPath, stat, isInternal, }) {
29
29
  // If the file is a zip, we assume the function is bundled and ready to go.
30
30
  // We simply copy it to the destination path with no further processing.
31
31
  if (extension === '.zip') {
@@ -51,6 +51,7 @@ const zipFunction = async function ({ archiveFormat, basePath, cache, config = {
51
51
  extension,
52
52
  featureFlags,
53
53
  filename,
54
+ logger,
54
55
  mainFile,
55
56
  name,
56
57
  pluginsModulesPath,
@@ -1,7 +1,7 @@
1
1
  export interface NodeVersionSupport {
2
2
  esm: boolean;
3
3
  }
4
- export declare const DEFAULT_NODE_VERSION = 16;
4
+ export declare const DEFAULT_NODE_VERSION = 18;
5
5
  export declare const getNodeVersion: (configVersion?: string) => number;
6
6
  export declare const getNodeSupportMatrix: (configVersion?: string) => NodeVersionSupport;
7
7
  export declare const parseVersion: (input: string | undefined) => number | undefined;
@@ -1,6 +1,6 @@
1
1
  import semver from 'semver';
2
2
  // Must match the default version used in Bitballoon.
3
- export const DEFAULT_NODE_VERSION = 16;
3
+ export const DEFAULT_NODE_VERSION = 18;
4
4
  export const getNodeVersion = (configVersion) => parseVersion(configVersion) ?? DEFAULT_NODE_VERSION;
5
5
  export const getNodeSupportMatrix = (configVersion) => {
6
6
  const versionNumber = getNodeVersion(configVersion);
@@ -4,6 +4,7 @@ import type { FeatureFlags } from '../feature_flags.js';
4
4
  import type { FunctionSource, InvocationMode, SourceFile } from '../function.js';
5
5
  import { ObjectValues } from '../types/utils.js';
6
6
  import type { RuntimeCache } from '../utils/cache.js';
7
+ import { Logger } from '../utils/logger.js';
7
8
  import type { NodeBundlerName } from './node/bundlers/types.js';
8
9
  import type { ISCValues } from './node/in_source_config/index.js';
9
10
  export declare const RUNTIME: {
@@ -52,6 +53,7 @@ export type ZipFunction = (args: {
52
53
  config: FunctionConfig;
53
54
  destFolder: string;
54
55
  featureFlags: FeatureFlags;
56
+ logger: Logger;
55
57
  repositoryRoot?: string;
56
58
  generator?: string;
57
59
  isInternal: boolean;
package/dist/zip.js CHANGED
@@ -13,7 +13,6 @@ import { formatZipResult } from './utils/format_result.js';
13
13
  import { listFunctionsDirectories, resolveFunctionsDirectories } from './utils/fs.js';
14
14
  import { getLogger } from './utils/logger.js';
15
15
  import { nonNullable } from './utils/non_nullable.js';
16
- import { endTimer, startTimer } from './utils/timer.js';
17
16
  const DEFAULT_PARALLEL_LIMIT = 5;
18
17
  const validateArchiveFormat = (archiveFormat) => {
19
18
  if (!Object.values(ARCHIVE_FORMAT).includes(archiveFormat)) {
@@ -44,7 +43,6 @@ export const zipFunctions = async function (relativeSrcFolders, destFolder, { ar
44
43
  // extend the feature flags with `zisi_pure_esm_mjs` enabled.
45
44
  ...(func.config.nodeModuleFormat === MODULE_FORMAT.ESM ? { zisi_pure_esm_mjs: true } : {}),
46
45
  };
47
- const startIntervalTime = startTimer();
48
46
  const zipResult = await func.runtime.zipFunction({
49
47
  archiveFormat,
50
48
  basePath,
@@ -54,6 +52,7 @@ export const zipFunctions = async function (relativeSrcFolders, destFolder, { ar
54
52
  extension: func.extension,
55
53
  featureFlags: functionFlags,
56
54
  filename: func.filename,
55
+ logger,
57
56
  mainFile: func.mainFile,
58
57
  name: func.name,
59
58
  repositoryRoot,
@@ -63,14 +62,6 @@ export const zipFunctions = async function (relativeSrcFolders, destFolder, { ar
63
62
  stat: func.stat,
64
63
  isInternal: Boolean(internalFunctionsPath && isPathInside(func.srcPath, internalFunctionsPath)),
65
64
  });
66
- const durationNs = endTimer(startIntervalTime);
67
- const logObject = {
68
- name: func.name,
69
- config: func.config,
70
- featureFlags: functionFlags,
71
- durationNs,
72
- };
73
- logger.system(`Function details: ${JSON.stringify(logObject, null, 2)}`);
74
65
  return { ...zipResult, mainFile: func.mainFile, name: func.name, runtime: func.runtime };
75
66
  }, {
76
67
  concurrency: parallelLimit,
@@ -103,7 +94,6 @@ export const zipFunction = async function (relativeSrcPath, destFolder, { archiv
103
94
  // extend the feature flags with `zisi_pure_esm_mjs` enabled.
104
95
  ...(config.nodeModuleFormat === MODULE_FORMAT.ESM ? { zisi_pure_esm_mjs: true } : {}),
105
96
  };
106
- const startIntervalTime = startTimer();
107
97
  const zipResult = await runtime.zipFunction({
108
98
  archiveFormat,
109
99
  basePath,
@@ -113,6 +103,7 @@ export const zipFunction = async function (relativeSrcPath, destFolder, { archiv
113
103
  extension,
114
104
  featureFlags: functionFlags,
115
105
  filename,
106
+ logger,
116
107
  mainFile,
117
108
  name,
118
109
  repositoryRoot,
@@ -122,14 +113,6 @@ export const zipFunction = async function (relativeSrcPath, destFolder, { archiv
122
113
  stat: stats,
123
114
  isInternal: Boolean(internalFunctionsPath && isPathInside(srcPath, internalFunctionsPath)),
124
115
  });
125
- const durationNs = endTimer(startIntervalTime);
126
- const logObject = {
127
- name,
128
- config,
129
- featureFlags: functionFlags,
130
- durationNs,
131
- };
132
- logger.system(`Function details: ${JSON.stringify(logObject, null, 2)}`);
133
116
  return formatZipResult({ ...zipResult, mainFile, name, runtime });
134
117
  };
135
118
  //# sourceMappingURL=zip.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "9.6.0",
3
+ "version": "9.8.0",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "type": "module",
@@ -54,7 +54,7 @@
54
54
  "url": "https://github.com/netlify/zip-it-and-ship-it/issues"
55
55
  },
56
56
  "dependencies": {
57
- "@babel/parser_latest": "npm:@babel/parser@7.21.8",
57
+ "@babel/parser_latest": "npm:@babel/parser@7.22.4",
58
58
  "@babel/parser": "7.16.8",
59
59
  "@netlify/binary-info": "^1.0.0",
60
60
  "@netlify/esbuild": "0.14.39",
@@ -80,7 +80,7 @@
80
80
  "precinct": "^11.0.0",
81
81
  "require-package-name": "^2.0.1",
82
82
  "resolve": "^2.0.0-next.1",
83
- "semver": "^7.0.0",
83
+ "semver": "^7.3.8",
84
84
  "tmp-promise": "^3.0.2",
85
85
  "toml": "^3.0.0",
86
86
  "unixify": "^1.0.0",