@netlify/zip-it-and-ship-it 5.13.1 → 5.13.4

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.
@@ -19,7 +19,7 @@ const build = async ({ destPath, mainFile, srcDir }) => {
19
19
  }
20
20
  catch (error) {
21
21
  console.error(`Could not compile Go function ${functionName}:\n`);
22
- throw new error_js_1.FunctionBundlingUserError(error, { functionName, runtime: 'go' });
22
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName, runtime: 'go' });
23
23
  }
24
24
  const stat = await fs_1.promises.lstat(destPath);
25
25
  return {
@@ -95,7 +95,7 @@ const bundleJsFile = async function ({ additionalModulePaths, basePath, config,
95
95
  };
96
96
  }
97
97
  catch (error) {
98
- throw new error_js_1.FunctionBundlingUserError(error, { functionName: name, runtime: 'js', bundler: 'esbuild' });
98
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName: name, runtime: 'js', bundler: 'esbuild' });
99
99
  }
100
100
  };
101
101
  exports.bundleJsFile = bundleJsFile;
@@ -1,5 +1,6 @@
1
1
  import { FeatureFlags } from '../../../../feature_flags';
2
2
  import { ModuleFormat } from '../../utils/module_format';
3
+ import { NodeVersionString } from '../../utils/node_version';
3
4
  declare const versionMap: {
4
5
  readonly '8.x': "node8";
5
6
  readonly '10.x': "node10";
@@ -7,9 +8,8 @@ declare const versionMap: {
7
8
  readonly '14.x': "node14";
8
9
  readonly '16.x': "node16";
9
10
  };
10
- declare type VersionKeys = keyof typeof versionMap;
11
- declare type VersionValues = typeof versionMap[VersionKeys];
12
- declare const getBundlerTarget: (suppliedVersion?: string) => VersionValues;
11
+ declare type VersionValues = typeof versionMap[keyof typeof versionMap];
12
+ declare const getBundlerTarget: (suppliedVersion?: NodeVersionString) => VersionValues;
13
13
  declare const getModuleFormat: (srcDir: string, featureFlags: FeatureFlags, configVersion?: string) => Promise<{
14
14
  includedFiles: string[];
15
15
  moduleFormat: ModuleFormat;
@@ -20,7 +20,6 @@ const getDynamicImportsPlugin = ({ basePath, includedPaths, moduleNames, process
20
20
  name: 'dynamic-imports',
21
21
  setup(build) {
22
22
  const cache = new Map();
23
- // eslint-disable-next-line complexity
24
23
  build.onDynamicImport({ filter: /.*/ }, async (args) => {
25
24
  const { expression, resolveDir } = args;
26
25
  // Don't attempt to parse the expression if the base path isn't defined,
@@ -22,7 +22,7 @@ const getNativeModulesPlugin = (externalizedModules) => ({
22
22
  name: 'external-native-modules',
23
23
  setup(build) {
24
24
  const cache = {};
25
- // eslint-disable-next-line complexity, max-statements
25
+ // eslint-disable-next-line max-statements
26
26
  build.onResolve({ filter: packageFilter }, async (args) => {
27
27
  const pkg = packageName.exec(args.path);
28
28
  if (!pkg)
@@ -22,7 +22,7 @@ const transpile = async (path, config, functionName) => {
22
22
  return transpiled.outputFiles[0].text;
23
23
  }
24
24
  catch (error) {
25
- throw new error_js_1.FunctionBundlingUserError(error, { functionName, runtime: 'js', bundler: 'nft' });
25
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName, runtime: 'js', bundler: 'nft' });
26
26
  }
27
27
  };
28
28
  exports.transpile = transpile;
@@ -74,7 +74,7 @@ const listImports = async ({ functionName, path, }) => {
74
74
  });
75
75
  }
76
76
  catch (error) {
77
- throw new error_js_1.FunctionBundlingUserError(error, { functionName, runtime: 'js', bundler: 'zisi' });
77
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName, runtime: 'js', bundler: 'zisi' });
78
78
  }
79
79
  finally {
80
80
  await (0, fs_js_1.safeUnlink)(targetPath);
@@ -8,7 +8,6 @@ const getBindingFromVariableDeclaration = function (node, bindings) {
8
8
  }
9
9
  });
10
10
  };
11
- // eslint-disable-next-line complexity
12
11
  const getBindingsFromNode = function (node, bindings) {
13
12
  var _a;
14
13
  if (node.type === 'VariableDeclaration') {
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isRequire = exports.isModuleExports = exports.isImport = void 0;
4
- // eslint-disable-next-line complexity
5
4
  const isDotExpression = (node, expression) => {
6
5
  if (node.type !== 'MemberExpression') {
7
6
  return false;
@@ -51,7 +51,6 @@ const getWildcardFromASTNode = (node) => {
51
51
  // Tries to parse an expression, returning an object with:
52
52
  // - `includedPathsGlob`: A glob with the files to be included in the bundle
53
53
  // - `type`: The expression type (e.g. "require", "import")
54
- // eslint-disable-next-line complexity
55
54
  const parseExpression = ({ basePath, expression: rawExpression, resolveDir, }) => {
56
55
  const { program } = (0, parser_1.parse)(rawExpression, {
57
56
  sourceType: 'module',
@@ -1,5 +1,6 @@
1
- declare type SupportedVersionNumbers = 8 | 10 | 12 | 14;
2
- export declare type NodeVersionString = `${SupportedVersionNumbers}.x` | `nodejs${SupportedVersionNumbers}.x`;
1
+ declare type SupportedVersionNumbers = 8 | 10 | 12 | 14 | 16;
2
+ export declare type ShortNodeVersionString = `${SupportedVersionNumbers}.x`;
3
+ export declare type NodeVersionString = ShortNodeVersionString | `nodejs${SupportedVersionNumbers}.x`;
3
4
  export interface NodeVersionSupport {
4
5
  esm: boolean;
5
6
  }
@@ -17,7 +17,7 @@ const build = async ({ config, name, srcDir }) => {
17
17
  await installToolchainOnce();
18
18
  }
19
19
  catch (error) {
20
- throw new error_js_1.FunctionBundlingUserError(error, { functionName, runtime: 'rs' });
20
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName, runtime: 'rs' });
21
21
  }
22
22
  const targetDirectory = await getTargetDirectory({ config, name });
23
23
  await cargoBuild({ functionName, srcDir, targetDirectory });
@@ -53,7 +53,7 @@ const cargoBuild = async ({ functionName, srcDir, targetDirectory, }) => {
53
53
  error.message =
54
54
  'There is no Rust toolchain installed. Visit https://ntl.fyi/missing-rust-toolchain for more information.';
55
55
  }
56
- throw new error_js_1.FunctionBundlingUserError(error, { functionName, runtime: 'rs' });
56
+ throw error_js_1.FunctionBundlingUserError.addCustomErrorInfo(error, { functionName, runtime: 'rs' });
57
57
  }
58
58
  };
59
59
  const checkRustToolchain = async () => {
@@ -9,8 +9,11 @@ interface CustomErrorInfo {
9
9
  type: 'functionsBundling';
10
10
  location: CustomErrorLocation;
11
11
  }
12
- export declare class FunctionBundlingUserError extends Error {
12
+ declare type UserError = Error & {
13
13
  customErrorInfo: CustomErrorInfo;
14
- constructor(messageOrError: string | Error, customErrorInfo: CustomErrorLocation);
14
+ };
15
+ export declare class FunctionBundlingUserError extends Error {
16
+ constructor(message: string, customErrorInfo: CustomErrorLocation);
17
+ static addCustomErrorInfo(error: Error, customErrorInfo: CustomErrorLocation): UserError;
15
18
  }
16
19
  export {};
@@ -2,18 +2,20 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunctionBundlingUserError = void 0;
4
4
  class FunctionBundlingUserError extends Error {
5
- constructor(messageOrError, customErrorInfo) {
6
- const isError = messageOrError instanceof Error;
7
- super(isError ? messageOrError.message : messageOrError);
5
+ constructor(message, customErrorInfo) {
6
+ super(message);
8
7
  Object.setPrototypeOf(this, new.target.prototype);
9
8
  this.name = 'FunctionBundlingUserError';
10
- if (isError) {
11
- this.stack = messageOrError.stack;
12
- }
13
- else {
14
- Error.captureStackTrace(this, FunctionBundlingUserError);
15
- }
16
- this.customErrorInfo = { type: 'functionsBundling', location: customErrorInfo };
9
+ Error.captureStackTrace(this, FunctionBundlingUserError);
10
+ FunctionBundlingUserError.addCustomErrorInfo(this, customErrorInfo);
11
+ }
12
+ static addCustomErrorInfo(error, customErrorInfo) {
13
+ const info = {
14
+ type: 'functionsBundling',
15
+ location: customErrorInfo,
16
+ };
17
+ error.customErrorInfo = info;
18
+ return error;
17
19
  }
18
20
  }
19
21
  exports.FunctionBundlingUserError = FunctionBundlingUserError;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "5.13.1",
3
+ "version": "5.13.4",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "bin": {
@@ -55,13 +55,13 @@
55
55
  "@babel/parser": "7.16.8",
56
56
  "@netlify/binary-info": "^1.0.0",
57
57
  "@netlify/esbuild": "0.14.25",
58
- "@vercel/nft": "^0.20.0",
58
+ "@vercel/nft": "^0.21.0",
59
59
  "archiver": "^5.3.0",
60
60
  "common-path-prefix": "^3.0.0",
61
61
  "cp-file": "^9.0.0",
62
62
  "del": "^6.0.0",
63
63
  "end-of-stream": "^1.4.4",
64
- "es-module-lexer": "^0.10.0",
64
+ "es-module-lexer": "^1.0.0",
65
65
  "execa": "^5.0.0",
66
66
  "filter-obj": "^2.0.1",
67
67
  "find-up": "^5.0.0",
@@ -86,7 +86,7 @@
86
86
  },
87
87
  "devDependencies": {
88
88
  "@babel/types": "^7.15.6",
89
- "@netlify/eslint-config-node": "^6.0.0",
89
+ "@netlify/eslint-config-node": "^7.0.0",
90
90
  "@types/archiver": "^5.1.1",
91
91
  "@types/end-of-stream": "^1.4.1",
92
92
  "@types/normalize-path": "^3.0.0",