@netlify/zip-it-and-ship-it 7.1.2 → 7.1.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.
@@ -17,6 +17,8 @@ exports.defaultFlags = {
17
17
  zisi_pure_esm_mjs: false,
18
18
  // Load configuration from per-function JSON files.
19
19
  project_deploy_configuration_api_use_per_function_configuration_files: false,
20
+ // Provide banner to esbuild which allows requires in ESM output
21
+ zisi_esbuild_require_banner: false,
20
22
  };
21
23
  // List of supported flags and their default value.
22
24
  const getFlags = (input = {}, flags = exports.defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
package/dist/main.d.ts CHANGED
@@ -21,14 +21,14 @@ interface ListFunctionsOptions {
21
21
  featureFlags?: FeatureFlags;
22
22
  parseISC?: boolean;
23
23
  }
24
- export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags, config, parseISC, }?: {
24
+ export declare const listFunctions: (relativeSrcFolders: string | string[], { featureFlags: inputFeatureFlags, config, parseISC, }?: {
25
25
  featureFlags?: FeatureFlags | undefined;
26
26
  config?: Config | undefined;
27
27
  parseISC?: boolean | undefined;
28
28
  }) => Promise<ListedFunction[]>;
29
- export declare const listFunction: (path: string, { featureFlags, config, parseISC, }?: {
29
+ export declare const listFunction: (path: string, { featureFlags: inputFeatureFlags, config, parseISC, }?: {
30
30
  featureFlags?: FeatureFlags | undefined;
31
31
  config?: Config | undefined;
32
32
  parseISC?: boolean | undefined;
33
33
  }) => Promise<ListedFunction | undefined>;
34
- export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
34
+ export declare const listFunctionsFiles: (relativeSrcFolders: string | string[], { basePath, config, featureFlags: inputFeatureFlags, parseISC }?: ListFunctionsOptions) => Promise<ListedFunctionFile[]>;
@@ -62,8 +62,19 @@ const bundleJsFile = async function ({ additionalModulePaths, basePath, config,
62
62
  const extension = (0, module_format_js_1.getFileExtensionForFormat)(moduleFormat, featureFlags);
63
63
  // When outputting an ESM file, configure esbuild to produce a `.mjs` file.
64
64
  const outExtension = moduleFormat === "esm" /* ModuleFormat.ESM */ ? { [".js" /* ModuleFileExtension.JS */]: ".mjs" /* ModuleFileExtension.MJS */ } : undefined;
65
+ // We add this banner so that calls to require() still work in ESM modules, especially when importing node built-ins
66
+ // We have to do this until this is fixed in esbuild: https://github.com/evanw/esbuild/pull/2067
67
+ const esmJSBanner = `
68
+ import {createRequire as ___nfyCreateRequire} from "module";
69
+ import {fileURLToPath as ___nfyFileURLToPath} from "url";
70
+ import {dirname as ___nfyPathDirname} from "path";
71
+ let __filename=___nfyFileURLToPath(import.meta.url);
72
+ let __dirname=___nfyPathDirname(___nfyFileURLToPath(import.meta.url));
73
+ let require=___nfyCreateRequire(import.meta.url);
74
+ `;
65
75
  try {
66
76
  const { metafile = { inputs: {}, outputs: {} }, warnings } = await (0, esbuild_1.build)({
77
+ banner: moduleFormat === "esm" /* ModuleFormat.ESM */ && featureFlags.zisi_esbuild_require_banner ? { js: esmJSBanner } : undefined,
67
78
  bundle: true,
68
79
  entryPoints: [srcFile],
69
80
  external,
@@ -1,4 +1,4 @@
1
- export declare const parseExpression: ({ basePath, expression, resolveDir, }: {
1
+ export declare const parseExpression: ({ basePath, expression: rawExpression, resolveDir, }: {
2
2
  basePath: string;
3
3
  expression: string;
4
4
  resolveDir: string;
package/dist/zip.d.ts CHANGED
@@ -14,9 +14,9 @@ declare type ZipFunctionsOptions = ZipFunctionOptions & {
14
14
  manifest?: string;
15
15
  parallelLimit?: number;
16
16
  };
17
- export declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, configFileDirectories, featureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<(Omit<import("./function.js").FunctionArchive, "runtime"> & {
17
+ export declare const zipFunctions: (relativeSrcFolders: string | string[], destFolder: string, { archiveFormat, basePath, config, configFileDirectories, featureFlags: inputFeatureFlags, manifest, parallelLimit, repositoryRoot, }?: ZipFunctionsOptions) => Promise<(Omit<import("./function.js").FunctionArchive, "runtime"> & {
18
18
  runtime: import("./main.js").RuntimeType;
19
19
  schedule?: string | undefined;
20
20
  })[]>;
21
- export declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config, featureFlags, repositoryRoot, }?: ZipFunctionOptions) => Promise<import("./utils/format_result.js").FunctionResult | undefined>;
21
+ export declare const zipFunction: (relativeSrcPath: string, destFolder: string, { archiveFormat, basePath, config: inputConfig, featureFlags: inputFeatureFlags, repositoryRoot, }?: ZipFunctionOptions) => Promise<import("./utils/format_result.js").FunctionResult | undefined>;
22
22
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "7.1.2",
3
+ "version": "7.1.3",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "bin": {