@netlify/zip-it-and-ship-it 5.6.0 → 5.7.3

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.
Files changed (91) hide show
  1. package/README.md +19 -38
  2. package/dist/archive.d.ts +6 -8
  3. package/dist/bin.js +2 -1
  4. package/dist/config.d.ts +7 -7
  5. package/dist/feature_flags.d.ts +4 -6
  6. package/dist/feature_flags.js +3 -3
  7. package/dist/function.d.ts +3 -4
  8. package/dist/main.d.ts +4 -5
  9. package/dist/main.js +4 -4
  10. package/dist/manifest.d.ts +3 -4
  11. package/dist/runtimes/detect_runtime.d.ts +1 -2
  12. package/dist/runtimes/go/builder.d.ts +1 -2
  13. package/dist/runtimes/go/builder.js +1 -1
  14. package/dist/runtimes/index.d.ts +3 -3
  15. package/dist/runtimes/node/bundlers/esbuild/bundler.d.ts +2 -3
  16. package/dist/runtimes/node/bundlers/esbuild/bundler.js +3 -4
  17. package/dist/runtimes/node/bundlers/esbuild/bundler_target.d.ts +2 -2
  18. package/dist/runtimes/node/bundlers/esbuild/index.js +1 -0
  19. package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.d.ts +1 -2
  20. package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.d.ts +1 -2
  21. package/dist/runtimes/node/bundlers/esbuild/plugin_node_builtin.d.ts +1 -2
  22. package/dist/runtimes/node/bundlers/esbuild/special_cases.d.ts +1 -2
  23. package/dist/runtimes/node/bundlers/esbuild/special_cases.js +1 -10
  24. package/dist/runtimes/node/bundlers/esbuild/src_files.d.ts +1 -2
  25. package/dist/runtimes/node/bundlers/index.d.ts +13 -7
  26. package/dist/runtimes/node/bundlers/index.js +21 -1
  27. package/dist/runtimes/node/bundlers/nft/es_modules.d.ts +9 -3
  28. package/dist/runtimes/node/bundlers/nft/es_modules.js +34 -5
  29. package/dist/runtimes/node/bundlers/nft/index.js +15 -4
  30. package/dist/runtimes/node/bundlers/nft/transpile.d.ts +1 -2
  31. package/dist/runtimes/node/bundlers/zisi/index.js +1 -0
  32. package/dist/runtimes/node/bundlers/zisi/list_imports.d.ts +1 -2
  33. package/dist/runtimes/node/bundlers/zisi/list_imports.js +6 -2
  34. package/dist/runtimes/node/bundlers/zisi/nested.d.ts +2 -3
  35. package/dist/runtimes/node/bundlers/zisi/nested.js +8 -4
  36. package/dist/runtimes/node/bundlers/zisi/published.d.ts +1 -2
  37. package/dist/runtimes/node/bundlers/zisi/resolve.d.ts +2 -3
  38. package/dist/runtimes/node/bundlers/zisi/resolve.js +6 -4
  39. package/dist/runtimes/node/bundlers/zisi/side_files.d.ts +1 -2
  40. package/dist/runtimes/node/bundlers/zisi/src_files.d.ts +1 -2
  41. package/dist/runtimes/node/bundlers/zisi/traverse.d.ts +1 -2
  42. package/dist/runtimes/node/bundlers/zisi/traverse.js +3 -3
  43. package/dist/runtimes/node/bundlers/zisi/tree_files.d.ts +1 -2
  44. package/dist/runtimes/node/bundlers/zisi/tree_shake.d.ts +1 -2
  45. package/dist/runtimes/node/finder.d.ts +2 -3
  46. package/dist/runtimes/node/finder.js +1 -1
  47. package/dist/runtimes/node/in_source_config/index.d.ts +5 -7
  48. package/dist/runtimes/node/in_source_config/index.js +5 -6
  49. package/dist/runtimes/node/index.d.ts +1 -2
  50. package/dist/runtimes/node/index.js +4 -22
  51. package/dist/runtimes/node/parser/exports.d.ts +1 -2
  52. package/dist/runtimes/node/parser/helpers.d.ts +3 -4
  53. package/dist/runtimes/node/parser/imports.d.ts +1 -2
  54. package/dist/runtimes/node/parser/index.d.ts +2 -3
  55. package/dist/runtimes/node/utils/base_path.d.ts +1 -2
  56. package/dist/runtimes/node/utils/detect_es_module.d.ts +1 -2
  57. package/dist/runtimes/node/utils/detect_native_module.d.ts +1 -2
  58. package/dist/runtimes/node/utils/entry_file.d.ts +12 -0
  59. package/dist/runtimes/node/utils/entry_file.js +24 -0
  60. package/dist/runtimes/node/utils/included_files.d.ts +2 -3
  61. package/dist/runtimes/node/utils/module.d.ts +1 -2
  62. package/dist/runtimes/node/utils/module_format.d.ts +1 -0
  63. package/dist/runtimes/node/utils/module_format.js +3 -0
  64. package/dist/runtimes/node/utils/node_version.d.ts +9 -5
  65. package/dist/runtimes/node/utils/node_version.js +11 -4
  66. package/dist/runtimes/node/utils/normalize_path.d.ts +5 -0
  67. package/dist/runtimes/node/utils/normalize_path.js +20 -0
  68. package/dist/runtimes/node/utils/package_json.d.ts +4 -4
  69. package/dist/runtimes/node/utils/package_json.js +14 -4
  70. package/dist/runtimes/node/utils/plugin_modules_path.d.ts +2 -3
  71. package/dist/runtimes/node/utils/traversal_cache.d.ts +2 -3
  72. package/dist/runtimes/node/utils/zip.d.ts +5 -3
  73. package/dist/runtimes/node/utils/zip.js +9 -28
  74. package/dist/runtimes/runtime.d.ts +8 -9
  75. package/dist/runtimes/rust/builder.d.ts +1 -2
  76. package/dist/runtimes/rust/builder.js +4 -4
  77. package/dist/runtimes/rust/cargo_manifest.d.ts +1 -2
  78. package/dist/runtimes/rust/constants.d.ts +2 -3
  79. package/dist/runtimes/rust/constants.js +2 -4
  80. package/dist/utils/archive_size.d.ts +1 -2
  81. package/dist/utils/format_result.d.ts +2 -4
  82. package/dist/utils/fs.d.ts +10 -12
  83. package/dist/utils/fs.js +5 -8
  84. package/dist/utils/non_nullable.d.ts +1 -2
  85. package/dist/utils/remove_undefined.d.ts +1 -2
  86. package/dist/utils/shell.d.ts +21 -1
  87. package/dist/utils/shell.js +2 -2
  88. package/dist/zip.d.ts +3 -3
  89. package/dist/zip.js +1 -1
  90. package/dist/zip_binary.d.ts +1 -2
  91. package/package.json +5 -5
package/README.md CHANGED
@@ -32,15 +32,11 @@ npm install @netlify/zip-it-and-ship-it
32
32
  - _Return value_: `Promise<object[]>`
33
33
 
34
34
  ```js
35
- const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
35
+ import { zipFunctions } from '@netlify/zip-it-and-ship-it'
36
36
 
37
- const zipNetlifyFunctions = async function () {
38
- const archives = await zipFunctions('functions', 'functions-dist', {
39
- archiveFormat: 'zip',
40
- })
41
-
42
- return archives
43
- }
37
+ const archives = await zipFunctions('functions', 'functions-dist', {
38
+ archiveFormat: 'zip',
39
+ })
44
40
  ```
45
41
 
46
42
  Creates Zip `archives` from Node.js, Go, and Rust programs. Those `archives` are ready to be uploaded to AWS Lambda.
@@ -258,13 +254,9 @@ Additionally, the following properties also exist for Node.js functions:
258
254
  - _Return value_: `object | undefined`
259
255
 
260
256
  ```js
261
- const { zipFunction } = require('@netlify/zip-it-and-ship-it')
262
-
263
- const zipNetlifyFunctions = async function () {
264
- const archive = await zipFunctions('functions/function.js', 'functions-dist')
257
+ import { zipFunction } from '@netlify/zip-it-and-ship-it'
265
258
 
266
- return archive
267
- }
259
+ const archive = await zipFunctions('functions/function.js', 'functions-dist')
268
260
  ```
269
261
 
270
262
  This is like [`zipFunctions()`](#zipfunctionssrcfolder-destfolder-options) except it bundles a single Function.
@@ -276,13 +268,9 @@ The return value is `undefined` if the function is invalid.
276
268
  Returns the list of functions to bundle.
277
269
 
278
270
  ```js
279
- const { listFunctions } = require('@netlify/zip-it-and-ship-it')
280
-
281
- const listNetlifyFunctions = async function () {
282
- const functions = await listFunctions('functions/function.js')
271
+ import { listFunctions } from '@netlify/zip-it-and-ship-it'
283
272
 
284
- return functions
285
- }
273
+ const functions = await listFunctions('functions/function.js')
286
274
  ```
287
275
 
288
276
  ### `srcFolders`
@@ -326,12 +314,9 @@ Like [`listFunctions()`](#listfunctionssrcfolder), except it returns not only th
326
314
  their required files. This is much slower.
327
315
 
328
316
  ```js
329
- const { listFunctionsFiles } = require('@netlify/zip-it-and-ship-it')
317
+ import { listFunctionsFiles } from '@netlify/zip-it-and-ship-it'
330
318
 
331
- const listNetlifyFunctionsFiles = async function () {
332
- const functions = await listFunctionsFiles('functions/function.js')
333
- return functions
334
- }
319
+ const functions = await listFunctionsFiles('functions/function.js')
335
320
  ```
336
321
 
337
322
  ### `srcFolders`
@@ -400,20 +385,16 @@ included in the bundle.
400
385
  You can enable esbuild by setting the [`config` option](#config) when calling `zipFunction` or `zipFunctions`:
401
386
 
402
387
  ```js
403
- const { zipFunctions } = require('@netlify/zip-it-and-ship-it')
404
-
405
- const zipNetlifyFunctions = async function () {
406
- const archives = await zipFunctions('functions', 'functions-dist', {
407
- config: {
408
- // Applying these settings to all functions.
409
- '*': {
410
- nodeBundler: 'esbuild',
411
- },
412
- },
413
- })
388
+ import { zipFunctions } from '@netlify/zip-it-and-ship-it'
414
389
 
415
- return archives
416
- }
390
+ const archives = await zipFunctions('functions', 'functions-dist', {
391
+ config: {
392
+ // Applying these settings to all functions.
393
+ '*': {
394
+ nodeBundler: 'esbuild',
395
+ },
396
+ },
397
+ })
417
398
  ```
418
399
 
419
400
  # Feature flags
package/dist/archive.d.ts CHANGED
@@ -2,14 +2,12 @@ import { Buffer } from 'buffer';
2
2
  import { Stats } from 'fs';
3
3
  import { Writable } from 'stream';
4
4
  import { Archiver } from 'archiver';
5
- declare type ArchiveFormat = 'none' | 'zip';
6
- declare const startZip: (destPath: string) => {
5
+ export { Archiver as ZipArchive } from 'archiver';
6
+ export declare type ArchiveFormat = 'none' | 'zip';
7
+ export declare const startZip: (destPath: string) => {
7
8
  archive: Archiver;
8
9
  output: Writable;
9
10
  };
10
- declare const addZipFile: (archive: Archiver, file: string, name: string, stat: Stats) => void;
11
- declare const addZipContent: (archive: Archiver, content: Buffer | string, name: string) => void;
12
- declare const endZip: (archive: Archiver, output: Writable) => Promise<void>;
13
- export { startZip, addZipFile, addZipContent, endZip };
14
- export type { ArchiveFormat };
15
- export { Archiver as ZipArchive } from 'archiver';
11
+ export declare const addZipFile: (archive: Archiver, file: string, name: string, stat: Stats) => void;
12
+ export declare const addZipContent: (archive: Archiver, content: Buffer | string, name: string) => void;
13
+ export declare const endZip: (archive: Archiver, output: Writable) => Promise<void>;
package/dist/bin.js CHANGED
@@ -6,6 +6,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  const process_1 = require("process");
8
8
  const yargs_1 = __importDefault(require("yargs"));
9
+ const helpers_1 = require("yargs/helpers");
9
10
  const main_1 = require("./main");
10
11
  // CLI entry point
11
12
  const runCli = async function () {
@@ -23,7 +24,7 @@ const runCli = async function () {
23
24
  }
24
25
  };
25
26
  const parseArgs = function () {
26
- return yargs_1.default
27
+ return (0, yargs_1.default)((0, helpers_1.hideBin)(process_1.argv))
27
28
  .command('* <srcFolder> <destFolder>', 'Create ZIP archives from a directory')
28
29
  .options(OPTIONS)
29
30
  .usage(USAGE)
package/dist/config.d.ts CHANGED
@@ -1,23 +1,23 @@
1
1
  import { FunctionSource } from './function';
2
- import type { NodeBundlerName, NodeVersion } from './runtimes/node';
3
- interface FunctionConfig {
2
+ import type { NodeVersionString } from './runtimes/node';
3
+ import type { NodeBundlerName } from './runtimes/node/bundlers';
4
+ export interface FunctionConfig {
4
5
  externalNodeModules?: string[];
5
6
  includedFiles?: string[];
6
7
  includedFilesBasePath?: string;
7
8
  ignoredNodeModules?: string[];
8
9
  nodeBundler?: NodeBundlerName;
9
10
  nodeSourcemap?: boolean;
10
- nodeVersion?: NodeVersion;
11
+ nodeVersion?: NodeVersionString;
11
12
  processDynamicNodeImports?: boolean;
12
13
  rustTargetDirectory?: string;
13
14
  schedule?: string;
14
15
  zipGo?: boolean;
15
16
  }
16
17
  declare type GlobPattern = string;
17
- declare type Config = Record<GlobPattern, FunctionConfig>;
18
- declare const getConfigForFunction: ({ config, func, }: {
18
+ export declare type Config = Record<GlobPattern, FunctionConfig>;
19
+ export declare const getConfigForFunction: ({ config, func, }: {
19
20
  config?: Config | undefined;
20
21
  func: Omit<FunctionSource, 'config'>;
21
22
  }) => FunctionConfig;
22
- export { getConfigForFunction };
23
- export type { Config, FunctionConfig };
23
+ export {};
@@ -1,6 +1,4 @@
1
- declare const FLAGS: Record<string, boolean>;
2
- declare type FeatureFlag = keyof typeof FLAGS;
3
- declare type FeatureFlags = Record<FeatureFlag, boolean>;
4
- declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => {};
5
- export { FLAGS as defaultFlags, getFlags };
6
- export type { FeatureFlag, FeatureFlags };
1
+ export declare const defaultFlags: Record<string, boolean>;
2
+ export declare type FeatureFlag = keyof typeof defaultFlags;
3
+ export declare type FeatureFlags = Record<FeatureFlag, boolean>;
4
+ export declare const getFlags: (input?: Record<string, boolean>, flags?: Record<string, boolean>) => {};
@@ -2,16 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getFlags = exports.defaultFlags = void 0;
4
4
  const process_1 = require("process");
5
- const FLAGS = {
5
+ exports.defaultFlags = {
6
6
  buildGoSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_GO_SOURCE),
7
7
  buildRustSource: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE),
8
8
  defaultEsModulesToEsbuild: Boolean(process_1.env.NETLIFY_EXPERIMENTAL_DEFAULT_ES_MODULES_TO_ESBUILD),
9
9
  parseWithEsbuild: false,
10
10
  traceWithNft: false,
11
+ zisi_pure_esm: false,
11
12
  };
12
- exports.defaultFlags = FLAGS;
13
13
  // List of supported flags and their default value.
14
- const getFlags = (input = {}, flags = FLAGS) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
14
+ const getFlags = (input = {}, flags = exports.defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
15
15
  ...result,
16
16
  [key]: input[key] === undefined ? defaultValue : input[key],
17
17
  }), {});
@@ -2,13 +2,13 @@
2
2
  import { Stats } from 'fs';
3
3
  import type { FunctionConfig } from './config';
4
4
  import type { Runtime, ZipFunctionResult } from './runtimes/runtime';
5
- declare type FunctionArchive = ZipFunctionResult & {
5
+ export declare type FunctionArchive = ZipFunctionResult & {
6
6
  mainFile: string;
7
7
  name: string;
8
8
  runtime: Runtime;
9
9
  size?: number;
10
10
  };
11
- interface SourceFile {
11
+ export interface SourceFile {
12
12
  extension: string;
13
13
  filename: string;
14
14
  mainFile: string;
@@ -17,8 +17,7 @@ interface SourceFile {
17
17
  srcPath: string;
18
18
  stat: Stats;
19
19
  }
20
- declare type FunctionSource = SourceFile & {
20
+ export declare type FunctionSource = SourceFile & {
21
21
  config: FunctionConfig;
22
22
  runtime: Runtime;
23
23
  };
24
- export { FunctionArchive, FunctionSource, SourceFile };
package/dist/main.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { Config } from './config';
2
2
  import { FeatureFlags } from './feature_flags';
3
3
  import { RuntimeName } from './runtimes/runtime';
4
+ export { zipFunction, zipFunctions } from './zip';
4
5
  interface ListedFunction {
5
6
  name: string;
6
7
  mainFile: string;
@@ -17,16 +18,14 @@ interface ListFunctionsOptions {
17
18
  featureFlags?: FeatureFlags;
18
19
  parseISC?: boolean;
19
20
  }
20
- declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
21
+ export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
21
22
  featureFlags?: FeatureFlags | undefined;
22
23
  config?: Config | undefined;
23
24
  parseISC?: boolean | undefined;
24
25
  }) => Promise<ListedFunction[]>;
25
- declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
26
+ export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
26
27
  featureFlags?: FeatureFlags | undefined;
27
28
  config?: Config | undefined;
28
29
  parseISC?: boolean | undefined;
29
30
  }) => Promise<ListedFunction | undefined>;
30
- declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
31
- export { listFunctions, listFunction, listFunctionsFiles };
32
- export { zipFunction, zipFunctions } from './zip';
31
+ export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
package/dist/main.js CHANGED
@@ -1,11 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zipFunctions = exports.zipFunction = exports.listFunctionsFiles = exports.listFunction = exports.listFunctions = void 0;
3
+ exports.listFunctionsFiles = exports.listFunction = exports.listFunctions = exports.zipFunctions = exports.zipFunction = void 0;
4
4
  const path_1 = require("path");
5
5
  const feature_flags_1 = require("./feature_flags");
6
6
  const runtimes_1 = require("./runtimes");
7
7
  const in_source_config_1 = require("./runtimes/node/in_source_config");
8
8
  const fs_1 = require("./utils/fs");
9
+ var zip_1 = require("./zip");
10
+ Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return zip_1.zipFunction; } });
11
+ Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return zip_1.zipFunctions; } });
9
12
  const augmentWithISC = async (func) => {
10
13
  // ISC is currently only supported in JavaScript and TypeScript functions.
11
14
  if (func.runtime.name !== 'js') {
@@ -68,7 +71,4 @@ const getSrcFiles = async function ({ extension, runtime, srcPath, ...args }) {
68
71
  ...args,
69
72
  });
70
73
  };
71
- var zip_1 = require("./zip");
72
- Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return zip_1.zipFunction; } });
73
- Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return zip_1.zipFunctions; } });
74
74
  //# sourceMappingURL=main.js.map
@@ -6,7 +6,7 @@ interface ManifestFunction {
6
6
  runtime: string;
7
7
  schedule?: string;
8
8
  }
9
- interface Manifest {
9
+ export interface Manifest {
10
10
  functions: ManifestFunction[];
11
11
  system: {
12
12
  arch: string;
@@ -15,9 +15,8 @@ interface Manifest {
15
15
  timestamp: number;
16
16
  version: number;
17
17
  }
18
- declare const createManifest: ({ functions, path }: {
18
+ export declare const createManifest: ({ functions, path }: {
19
19
  functions: FunctionResult[];
20
20
  path: string;
21
21
  }) => Promise<void>;
22
- export { createManifest };
23
- export type { Manifest };
22
+ export {};
@@ -1,7 +1,6 @@
1
1
  import { FsCache } from '../utils/fs';
2
2
  import type { RuntimeName } from './runtime';
3
- declare const detectBinaryRuntime: ({ fsCache, path, }: {
3
+ export declare const detectBinaryRuntime: ({ fsCache, path, }: {
4
4
  fsCache: FsCache;
5
5
  path: string;
6
6
  }) => Promise<RuntimeName | undefined>;
7
- export { detectBinaryRuntime };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- declare const build: ({ destPath, mainFile, srcDir }: {
2
+ export declare const build: ({ destPath, mainFile, srcDir }: {
3
3
  destPath: string;
4
4
  mainFile: string;
5
5
  srcDir: string;
@@ -10,4 +10,3 @@ declare const build: ({ destPath, mainFile, srcDir }: {
10
10
  srcPath: string;
11
11
  stat: import("fs").Stats;
12
12
  }>;
13
- export { build };
@@ -7,7 +7,7 @@ const shell_1 = require("../../utils/shell");
7
7
  const build = async ({ destPath, mainFile, srcDir }) => {
8
8
  const functionName = (0, path_1.basename)(srcDir);
9
9
  try {
10
- await (0, shell_1.runCommand)('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
10
+ await shell_1.shellUtils.runCommand('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
11
11
  cwd: srcDir,
12
12
  env: {
13
13
  CGO_ENABLED: '0',
@@ -5,7 +5,7 @@ declare type FunctionMap = Map<string, FunctionSource>;
5
5
  /**
6
6
  * Gets a list of functions found in a list of paths.
7
7
  */
8
- declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, featureFlags, }?: {
8
+ export declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, featureFlags, }?: {
9
9
  config?: Config | undefined;
10
10
  dedupe?: boolean | undefined;
11
11
  featureFlags?: FeatureFlags | undefined;
@@ -13,8 +13,8 @@ declare const getFunctionsFromPaths: (paths: string[], { config, dedupe, feature
13
13
  /**
14
14
  * Gets a list of functions found in a list of paths.
15
15
  */
16
- declare const getFunctionFromPath: (path: string, { config, featureFlags }?: {
16
+ export declare const getFunctionFromPath: (path: string, { config, featureFlags }?: {
17
17
  config?: Config | undefined;
18
18
  featureFlags?: FeatureFlags | undefined;
19
19
  }) => Promise<FunctionSource | undefined>;
20
- export { getFunctionsFromPaths, getFunctionFromPath };
20
+ export {};
@@ -1,6 +1,6 @@
1
1
  import type { FunctionConfig } from '../../../../config';
2
- declare const ESBUILD_LOG_LIMIT = 10;
3
- declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, ignoredModules, name, srcDir, srcFile, }: {
2
+ export declare const ESBUILD_LOG_LIMIT = 10;
3
+ export declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, ignoredModules, name, srcDir, srcFile, }: {
4
4
  additionalModulePaths?: string[] | undefined;
5
5
  basePath?: string | undefined;
6
6
  config: FunctionConfig;
@@ -18,4 +18,3 @@ declare const bundleJsFile: ({ additionalModulePaths, basePath, config, external
18
18
  nodeModulesWithDynamicImports: string[];
19
19
  warnings: import("@netlify/esbuild").Message[];
20
20
  }>;
21
- export { bundleJsFile, ESBUILD_LOG_LIMIT };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ESBUILD_LOG_LIMIT = exports.bundleJsFile = void 0;
3
+ exports.bundleJsFile = exports.ESBUILD_LOG_LIMIT = void 0;
4
4
  const path_1 = require("path");
5
5
  const esbuild_1 = require("@netlify/esbuild");
6
6
  const tmp_promise_1 = require("tmp-promise");
@@ -12,8 +12,7 @@ const plugin_node_builtin_1 = require("./plugin_node_builtin");
12
12
  // Maximum number of log messages that an esbuild instance will produce. This
13
13
  // limit is important to avoid out-of-memory errors due to too much data being
14
14
  // sent in the Go<>Node IPC channel.
15
- const ESBUILD_LOG_LIMIT = 10;
16
- exports.ESBUILD_LOG_LIMIT = ESBUILD_LOG_LIMIT;
15
+ exports.ESBUILD_LOG_LIMIT = 10;
17
16
  // When resolving imports with no extension (e.g. require('./foo')), these are
18
17
  // the extensions that esbuild will look for, in this order.
19
18
  const RESOLVE_EXTENSIONS = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.json'];
@@ -59,7 +58,7 @@ const bundleJsFile = async function ({ additionalModulePaths, basePath, config,
59
58
  entryPoints: [srcFile],
60
59
  external,
61
60
  logLevel: 'warning',
62
- logLimit: ESBUILD_LOG_LIMIT,
61
+ logLimit: exports.ESBUILD_LOG_LIMIT,
63
62
  metafile: true,
64
63
  nodePaths: additionalModulePaths,
65
64
  outdir: targetDirectory,
@@ -6,5 +6,5 @@ declare const versionMap: {
6
6
  };
7
7
  declare type VersionKeys = keyof typeof versionMap;
8
8
  declare type VersionValues = typeof versionMap[VersionKeys];
9
- declare const getBundlerTarget: (suppliedVersion?: string | undefined) => VersionValues;
10
- export { getBundlerTarget };
9
+ export declare const getBundlerTarget: (suppliedVersion?: string | undefined) => VersionValues;
10
+ export {};
@@ -78,6 +78,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
78
78
  bundlerWarnings,
79
79
  inputs,
80
80
  mainFile: normalizedMainFile,
81
+ moduleFormat: 'cjs',
81
82
  nativeNodeModules,
82
83
  nodeModulesWithDynamicImports,
83
84
  srcFiles: [...supportingSrcFiles, ...bundlePaths.keys()],
@@ -1,9 +1,8 @@
1
1
  import type { Plugin } from '@netlify/esbuild';
2
- declare const getDynamicImportsPlugin: ({ basePath, includedPaths, moduleNames, processImports, srcDir, }: {
2
+ export declare const getDynamicImportsPlugin: ({ basePath, includedPaths, moduleNames, processImports, srcDir, }: {
3
3
  basePath?: string | undefined;
4
4
  includedPaths: Set<string>;
5
5
  moduleNames: Set<string>;
6
6
  processImports: boolean;
7
7
  srcDir: string;
8
8
  }) => Plugin;
9
- export { getDynamicImportsPlugin };
@@ -1,4 +1,3 @@
1
1
  import type { Plugin } from '@netlify/esbuild';
2
2
  import type { NativeNodeModules } from '..';
3
- declare const getNativeModulesPlugin: (externalizedModules: NativeNodeModules) => Plugin;
4
- export { getNativeModulesPlugin };
3
+ export declare const getNativeModulesPlugin: (externalizedModules: NativeNodeModules) => Plugin;
@@ -1,3 +1,2 @@
1
1
  import type { Plugin } from '@netlify/esbuild';
2
- declare const getNodeBuiltinPlugin: () => Plugin;
3
- export { getNodeBuiltinPlugin };
2
+ export declare const getNodeBuiltinPlugin: () => Plugin;
@@ -1,7 +1,6 @@
1
- declare const getExternalAndIgnoredModulesFromSpecialCases: ({ srcDir }: {
1
+ export declare const getExternalAndIgnoredModulesFromSpecialCases: ({ srcDir }: {
2
2
  srcDir: string;
3
3
  }) => Promise<{
4
4
  externalModules: string[];
5
5
  ignoredModules: string[];
6
6
  }>;
7
- export { getExternalAndIgnoredModulesFromSpecialCases };
@@ -4,15 +4,6 @@ exports.getExternalAndIgnoredModulesFromSpecialCases = void 0;
4
4
  const package_json_1 = require("../../utils/package_json");
5
5
  const EXTERNAL_MODULES = ['@prisma/client'];
6
6
  const IGNORED_MODULES = ['aws-sdk'];
7
- const getPackageJsonIfAvailable = async (srcDir) => {
8
- try {
9
- const packageJson = await (0, package_json_1.getPackageJson)(srcDir);
10
- return packageJson;
11
- }
12
- catch {
13
- return {};
14
- }
15
- };
16
7
  const getModulesForNextJs = ({ dependencies, devDependencies }) => {
17
8
  const allDependencies = { ...dependencies, ...devDependencies };
18
9
  const externalModules = allDependencies.next ? ['critters', 'nanoid'] : [];
@@ -23,7 +14,7 @@ const getModulesForNextJs = ({ dependencies, devDependencies }) => {
23
14
  };
24
15
  };
25
16
  const getExternalAndIgnoredModulesFromSpecialCases = async ({ srcDir }) => {
26
- const { dependencies = {}, devDependencies = {} } = await getPackageJsonIfAvailable(srcDir);
17
+ const { dependencies = {}, devDependencies = {} } = await (0, package_json_1.getPackageJsonIfAvailable)(srcDir);
27
18
  const { externalModules: nextJsExternalModules, ignoredModules: nextJsIgnoredModules } = getModulesForNextJs({
28
19
  dependencies,
29
20
  devDependencies,
@@ -1,3 +1,2 @@
1
1
  import type { GetSrcFilesFunction } from '..';
2
- declare const getSrcFiles: GetSrcFilesFunction;
3
- export { getSrcFiles };
2
+ export declare const getSrcFiles: GetSrcFilesFunction;
@@ -1,12 +1,13 @@
1
1
  import type { Message } from '@netlify/esbuild';
2
- import type { NodeBundlerName } from '..';
3
2
  import { FunctionConfig } from '../../../config';
4
3
  import { FeatureFlag, FeatureFlags } from '../../../feature_flags';
5
4
  import { FunctionSource } from '../../../function';
5
+ import { ModuleFormat } from '../utils/module_format';
6
+ export declare type NodeBundlerName = 'esbuild' | 'esbuild_zisi' | 'nft' | 'zisi';
6
7
  declare type BundlerWarning = Message;
7
8
  declare type CleanupFunction = () => Promise<void>;
8
- declare type NativeNodeModules = Record<string, Record<string, string | undefined>>;
9
- declare type BundleFunction = (args: {
9
+ export declare type NativeNodeModules = Record<string, Record<string, string | undefined>>;
10
+ export declare type BundleFunction = (args: {
10
11
  basePath?: string;
11
12
  config: FunctionConfig;
12
13
  featureFlags: Record<FeatureFlag, boolean>;
@@ -20,11 +21,12 @@ declare type BundleFunction = (args: {
20
21
  cleanupFunction?: CleanupFunction;
21
22
  inputs: string[];
22
23
  mainFile: string;
24
+ moduleFormat: ModuleFormat;
23
25
  nativeNodeModules?: NativeNodeModules;
24
26
  nodeModulesWithDynamicImports?: string[];
25
27
  srcFiles: string[];
26
28
  }>;
27
- declare type GetSrcFilesFunction = (args: {
29
+ export declare type GetSrcFilesFunction = (args: {
28
30
  basePath?: string;
29
31
  config: FunctionConfig;
30
32
  featureFlags: FeatureFlags;
@@ -35,6 +37,10 @@ interface NodeBundler {
35
37
  bundle: BundleFunction;
36
38
  getSrcFiles: GetSrcFilesFunction;
37
39
  }
38
- declare const getBundler: (name: NodeBundlerName) => NodeBundler;
39
- export { getBundler };
40
- export type { BundleFunction, GetSrcFilesFunction, NativeNodeModules };
40
+ export declare const getBundler: (name: NodeBundlerName) => NodeBundler;
41
+ export declare const getDefaultBundler: ({ extension, mainFile, featureFlags, }: {
42
+ extension: string;
43
+ mainFile: string;
44
+ featureFlags: FeatureFlags;
45
+ }) => Promise<NodeBundlerName>;
46
+ export {};
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBundler = void 0;
6
+ exports.getDefaultBundler = exports.getBundler = void 0;
7
+ const detect_es_module_1 = require("../utils/detect_es_module");
7
8
  const esbuild_1 = __importDefault(require("./esbuild"));
8
9
  const nft_1 = __importDefault(require("./nft"));
9
10
  const zisi_1 = __importDefault(require("./zisi"));
@@ -21,4 +22,23 @@ const getBundler = (name) => {
21
22
  }
22
23
  };
23
24
  exports.getBundler = getBundler;
25
+ // We use ZISI as the default bundler, except for certain extensions, for which
26
+ // esbuild is the only option.
27
+ const getDefaultBundler = async ({ extension, mainFile, featureFlags, }) => {
28
+ const { defaultEsModulesToEsbuild, traceWithNft } = featureFlags;
29
+ if (['.mjs', '.ts'].includes(extension)) {
30
+ return 'esbuild';
31
+ }
32
+ if (traceWithNft) {
33
+ return 'nft';
34
+ }
35
+ if (defaultEsModulesToEsbuild) {
36
+ const isEsModule = await (0, detect_es_module_1.detectEsModule)({ mainFile });
37
+ if (isEsModule) {
38
+ return 'esbuild';
39
+ }
40
+ }
41
+ return 'zisi';
42
+ };
43
+ exports.getDefaultBundler = getDefaultBundler;
24
44
  //# sourceMappingURL=index.js.map
@@ -1,11 +1,17 @@
1
1
  import { NodeFileTraceReasons } from '@vercel/nft';
2
2
  import type { FunctionConfig } from '../../../../config';
3
+ import { FeatureFlags } from '../../../../feature_flags';
3
4
  import { FsCache } from '../../../../utils/fs';
4
- declare const transpileESM: ({ basePath, config, esmPaths, fsCache, reasons, }: {
5
+ import { ModuleFormat } from '../../utils/module_format';
6
+ export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, }: {
5
7
  basePath: string | undefined;
6
8
  config: FunctionConfig;
7
9
  esmPaths: Set<string>;
10
+ featureFlags: FeatureFlags;
8
11
  fsCache: FsCache;
12
+ mainFile: string;
9
13
  reasons: NodeFileTraceReasons;
10
- }) => Promise<Map<string, string>>;
11
- export { transpileESM };
14
+ }) => Promise<{
15
+ rewrites?: Map<string, string> | undefined;
16
+ moduleFormat: ModuleFormat;
17
+ }>;