@netlify/zip-it-and-ship-it 5.9.1 → 5.9.2

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.
@@ -3,7 +3,7 @@ import type { FunctionConfig } from '../../../../config.js';
3
3
  import { FeatureFlags } from '../../../../feature_flags.js';
4
4
  import { FsCache } from '../../../../utils/fs.js';
5
5
  import { ModuleFormat } from '../../utils/module_format.js';
6
- export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, }: {
6
+ export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, name, }: {
7
7
  basePath: string | undefined;
8
8
  config: FunctionConfig;
9
9
  esmPaths: Set<string>;
@@ -11,6 +11,7 @@ export declare const processESM: ({ basePath, config, esmPaths, featureFlags, fs
11
11
  fsCache: FsCache;
12
12
  mainFile: string;
13
13
  reasons: NodeFileTraceReasons;
14
+ name: string;
14
15
  }) => Promise<{
15
16
  rewrites?: Map<string, string> | undefined;
16
17
  moduleFormat: ModuleFormat;
@@ -28,7 +28,7 @@ const patchESMPackage = async (path, fsCache) => {
28
28
  };
29
29
  return JSON.stringify(patchedPackageJson);
30
30
  };
31
- const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, }) => {
31
+ const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, mainFile, reasons, name, }) => {
32
32
  const entrypointIsESM = isEntrypointESM({ basePath, esmPaths, mainFile });
33
33
  if (!entrypointIsESM) {
34
34
  return {
@@ -42,7 +42,7 @@ const processESM = async ({ basePath, config, esmPaths, featureFlags, fsCache, m
42
42
  moduleFormat: 'esm',
43
43
  };
44
44
  }
45
- const rewrites = await transpileESM({ basePath, config, esmPaths, fsCache, reasons });
45
+ const rewrites = await transpileESM({ basePath, config, esmPaths, fsCache, reasons, name });
46
46
  return {
47
47
  moduleFormat: 'cjs',
48
48
  rewrites,
@@ -75,7 +75,7 @@ const shouldTranspile = (path, cache, esmPaths, reasons) => {
75
75
  cache.set(path, shouldTranspilePath);
76
76
  return shouldTranspilePath;
77
77
  };
78
- const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, }) => {
78
+ const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, name, }) => {
79
79
  const cache = new Map();
80
80
  const pathsToTranspile = [...esmPaths].filter((path) => shouldTranspile(path, cache, esmPaths, reasons));
81
81
  const pathsToTranspileSet = new Set(pathsToTranspile);
@@ -91,7 +91,7 @@ const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, }) =
91
91
  const rewrites = await getPatchedESMPackages(packageJsonPaths, fsCache);
92
92
  await Promise.all(pathsToTranspile.map(async (path) => {
93
93
  const absolutePath = resolvePath(path, basePath);
94
- const transpiled = await (0, transpile_js_1.transpile)(absolutePath, config);
94
+ const transpiled = await (0, transpile_js_1.transpile)(absolutePath, config, name);
95
95
  rewrites.set(absolutePath, transpiled);
96
96
  }));
97
97
  return rewrites;
@@ -15,7 +15,7 @@ const es_modules_js_1 = require("./es_modules.js");
15
15
  // Paths that will be excluded from the tracing process.
16
16
  const ignore = ['node_modules/aws-sdk/**'];
17
17
  const appearsToBeModuleName = (name) => !name.startsWith('.');
18
- const bundle = async ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, repositoryRoot = basePath, }) => {
18
+ const bundle = async ({ basePath, config, featureFlags, mainFile, name, pluginsModulesPath, repositoryRoot = basePath, }) => {
19
19
  const { includedFiles = [], includedFilesBasePath } = config;
20
20
  const { exclude: excludedPaths, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath || basePath);
21
21
  const { moduleFormat, paths: dependencyPaths, rewrites, } = await traceFilesAndTranspile({
@@ -24,6 +24,7 @@ const bundle = async ({ basePath, config, featureFlags, mainFile, pluginsModules
24
24
  featureFlags,
25
25
  mainFile,
26
26
  pluginsModulesPath,
27
+ name,
27
28
  });
28
29
  const filteredIncludedPaths = (0, included_files_js_1.filterExcludedPaths)([...dependencyPaths, ...includedFilePaths], excludedPaths);
29
30
  const dirnames = filteredIncludedPaths.map((filePath) => (0, path_1.normalize)((0, path_1.dirname)(filePath))).sort();
@@ -43,7 +44,7 @@ const ignoreFunction = (path) => {
43
44
  const shouldIgnore = ignore.some((expression) => (0, minimatch_1.default)(normalizedPath, expression));
44
45
  return shouldIgnore;
45
46
  };
46
- const traceFilesAndTranspile = async function ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, }) {
47
+ const traceFilesAndTranspile = async function ({ basePath, config, featureFlags, mainFile, pluginsModulesPath, name, }) {
47
48
  const fsCache = {};
48
49
  const { fileList: dependencyPaths, esmFileList, reasons, } = await (0, nft_1.nodeFileTrace)([mainFile], {
49
50
  base: basePath,
@@ -85,6 +86,7 @@ const traceFilesAndTranspile = async function ({ basePath, config, featureFlags,
85
86
  fsCache,
86
87
  mainFile,
87
88
  reasons,
89
+ name,
88
90
  });
89
91
  return {
90
92
  moduleFormat,
@@ -1,2 +1,2 @@
1
1
  import type { FunctionConfig } from '../../../../config.js';
2
- export declare const transpile: (path: string, config: FunctionConfig) => Promise<string>;
2
+ export declare const transpile: (path: string, config: FunctionConfig, functionName: string) => Promise<string>;
@@ -3,21 +3,32 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.transpile = void 0;
4
4
  const esbuild_1 = require("@netlify/esbuild");
5
5
  const bundler_target_js_1 = require("../esbuild/bundler_target.js");
6
- const transpile = async (path, config) => {
6
+ const transpile = async (path, config, functionName) => {
7
7
  // The version of ECMAScript to use as the build target. This will determine
8
8
  // whether certain features are transpiled down or left untransformed.
9
9
  const nodeTarget = (0, bundler_target_js_1.getBundlerTarget)(config.nodeVersion);
10
- const transpiled = await (0, esbuild_1.build)({
11
- bundle: false,
12
- entryPoints: [path],
13
- format: 'cjs',
14
- logLevel: 'error',
15
- platform: 'node',
16
- sourcemap: Boolean(config.nodeSourcemap),
17
- target: [nodeTarget],
18
- write: false,
19
- });
20
- return transpiled.outputFiles[0].text;
10
+ try {
11
+ const transpiled = await (0, esbuild_1.build)({
12
+ bundle: false,
13
+ entryPoints: [path],
14
+ format: 'cjs',
15
+ logLevel: 'error',
16
+ platform: 'node',
17
+ sourcemap: Boolean(config.nodeSourcemap),
18
+ target: [nodeTarget],
19
+ write: false,
20
+ });
21
+ return transpiled.outputFiles[0].text;
22
+ }
23
+ catch (error) {
24
+ const bundler = 'nft';
25
+ const runtime = 'js';
26
+ error.customErrorInfo = {
27
+ type: 'functionsBundling',
28
+ location: { bundler, functionName, runtime },
29
+ };
30
+ throw error;
31
+ }
21
32
  };
22
33
  exports.transpile = transpile;
23
34
  //# sourceMappingURL=transpile.js.map
@@ -1,27 +1,4 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
26
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
4
  };
@@ -29,10 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
6
  exports.getSrcFiles = void 0;
30
7
  /* eslint-disable max-lines */
31
8
  const path_1 = require("path");
32
- const process = __importStar(require("process"));
33
9
  const junk_1 = require("junk");
34
10
  const precinct_1 = __importDefault(require("precinct"));
35
- const semver_1 = __importDefault(require("semver"));
36
11
  const non_nullable_js_1 = require("../../../../utils/non_nullable.js");
37
12
  const included_files_js_1 = require("../../utils/included_files.js");
38
13
  const package_json_js_1 = require("../../utils/package_json.js");
@@ -84,34 +59,15 @@ const getDependencies = async function ({ featureFlags, functionName, mainFile,
84
59
  throw error;
85
60
  }
86
61
  };
87
- const paperwork = async (path) => {
88
- if (semver_1.default.lt(process.version, '18.0.0')) {
89
- return await precinct_1.default.paperwork(path, { includeCore: false });
90
- }
91
- // for Node v18, we're temporarily using our own mechanism to filter out core dependencies, until
92
- // https://github.com/dependents/node-precinct/pull/108 landed
93
- const modules = await precinct_1.default.paperwork(path, { includeCore: true });
94
- return modules.filter((moduleName) => {
95
- if (moduleName.startsWith('node:')) {
96
- return false;
97
- }
98
- // only require("node:test") refers to the
99
- // builtin, require("test") doesn't
100
- if (moduleName === 'test') {
101
- return true;
102
- }
103
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
104
- const isNativeModule = moduleName in process.binding('natives');
105
- return !isNativeModule;
106
- });
107
- };
108
62
  const getFileDependencies = async function ({ featureFlags, functionName, path, packageJson, pluginsModulesPath, state, treeShakeNext = false, }) {
109
63
  if (state.localFiles.has(path)) {
110
64
  return [];
111
65
  }
112
66
  state.localFiles.add(path);
113
67
  const basedir = (0, path_1.dirname)(path);
114
- const dependencies = featureFlags.parseWithEsbuild ? await (0, list_imports_js_1.listImports)({ functionName, path }) : await paperwork(path);
68
+ const dependencies = featureFlags.parseWithEsbuild
69
+ ? await (0, list_imports_js_1.listImports)({ functionName, path })
70
+ : await precinct_1.default.paperwork(path, { includeCore: false });
115
71
  const depsPaths = await Promise.all(dependencies.filter(non_nullable_js_1.nonNullable).map((dependency) => getImportDependencies({
116
72
  dependency,
117
73
  basedir,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/zip-it-and-ship-it",
3
- "version": "5.9.1",
3
+ "version": "5.9.2",
4
4
  "description": "Zip it and ship it",
5
5
  "main": "./dist/main.js",
6
6
  "bin": {
@@ -53,7 +53,7 @@
53
53
  },
54
54
  "dependencies": {
55
55
  "@babel/parser": "7.16.8",
56
- "@netlify/esbuild": "0.14.23",
56
+ "@netlify/esbuild": "0.14.25",
57
57
  "@vercel/nft": "^0.18.0",
58
58
  "archiver": "^5.3.0",
59
59
  "common-path-prefix": "^3.0.0",
@@ -74,7 +74,7 @@
74
74
  "p-map": "^4.0.0",
75
75
  "path-exists": "^4.0.0",
76
76
  "pkg-dir": "^5.0.0",
77
- "precinct": "^8.2.0",
77
+ "precinct": "^9.0.1",
78
78
  "read-package-json-fast": "^2.0.2",
79
79
  "require-package-name": "^2.0.1",
80
80
  "resolve": "^2.0.0-next.1",