@netlify/build 27.20.4 → 27.20.6

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 (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +14 -7
@@ -1,60 +1,50 @@
1
- import { promises as fs } from 'fs'
2
- import { dirname, join, resolve } from 'path'
3
- import { pathToFileURL } from 'url'
4
-
1
+ import { promises as fs } from 'fs';
2
+ import { dirname, join, resolve } from 'path';
3
+ import { pathToFileURL } from 'url';
5
4
  const parseManifest = async (internalSourceDirectory, systemLog) => {
6
- const manifestPath = join(internalSourceDirectory, 'manifest.json')
7
-
8
- try {
9
- const data = await fs.readFile(manifestPath)
10
- const manifest = JSON.parse(data)
11
-
12
- if (manifest.version !== 1) {
13
- throw new Error('Unsupported manifest version')
5
+ const manifestPath = join(internalSourceDirectory, 'manifest.json');
6
+ try {
7
+ const data = await fs.readFile(manifestPath);
8
+ const manifest = JSON.parse(data);
9
+ if (manifest.version !== 1) {
10
+ throw new Error('Unsupported manifest version');
11
+ }
12
+ const result = {
13
+ declarations: manifest.functions,
14
+ };
15
+ if (manifest.import_map) {
16
+ const importMapPath = resolve(dirname(manifestPath), manifest.import_map);
17
+ const importMap = await readImportMap(importMapPath);
18
+ return {
19
+ ...result,
20
+ importMap: {
21
+ baseURL: pathToFileURL(importMapPath),
22
+ ...importMap,
23
+ },
24
+ };
25
+ }
26
+ return result;
14
27
  }
15
-
16
- const result = {
17
- declarations: manifest.functions,
28
+ catch (error) {
29
+ if (error.code !== 'ENOENT') {
30
+ systemLog('Error while parsing internal edge functions manifest:', error);
31
+ }
18
32
  }
19
-
20
- if (manifest.import_map) {
21
- const importMapPath = resolve(dirname(manifestPath), manifest.import_map)
22
- const importMap = await readImportMap(importMapPath)
23
-
24
- return {
25
- ...result,
26
- importMap: {
27
- baseURL: pathToFileURL(importMapPath),
28
- ...importMap,
29
- },
30
- }
33
+ return {
34
+ declarations: [],
35
+ };
36
+ };
37
+ const readImportMap = async (path) => {
38
+ try {
39
+ const data = await fs.readFile(path);
40
+ const importMap = JSON.parse(data);
41
+ return importMap;
31
42
  }
32
-
33
- return result
34
- } catch (error) {
35
- if (error.code !== 'ENOENT') {
36
- systemLog('Error while parsing internal edge functions manifest:', error)
43
+ catch {
44
+ // no-op
37
45
  }
38
- }
39
-
40
- return {
41
- declarations: [],
42
- }
43
- }
44
-
45
- const readImportMap = async (path) => {
46
- try {
47
- const data = await fs.readFile(path)
48
- const importMap = JSON.parse(data)
49
-
50
- return importMap
51
- } catch {
52
- // no-op
53
- }
54
-
55
- return {
56
- imports: {},
57
- }
58
- }
59
-
60
- export { parseManifest }
46
+ return {
47
+ imports: {},
48
+ };
49
+ };
50
+ export { parseManifest };
@@ -1,90 +1,75 @@
1
- import { promises as fs } from 'fs'
2
- import { join, resolve } from 'path'
3
-
4
- import Ajv from 'ajv'
5
- import ajvErrors from 'ajv-errors'
6
-
7
- import { addErrorInfo } from '../../../error/info.js'
8
-
9
- const ajv = new Ajv({ allErrors: true })
10
- ajvErrors(ajv)
11
-
1
+ import { promises as fs } from 'fs';
2
+ import { join, resolve } from 'path';
3
+ import Ajv from 'ajv';
4
+ import ajvErrors from 'ajv-errors';
5
+ import { addErrorInfo } from '../../../error/info.js';
6
+ const ajv = new Ajv({ allErrors: true });
7
+ ajvErrors(ajv);
12
8
  // regex pattern for manifest route pattern
13
9
  // checks if the pattern string starts with ^ and ends with $
14
10
  // we define this format in edge-bundler:
15
11
  // https://github.com/netlify/edge-bundler/blob/main/src/manifest.ts#L66
16
- const normalizedPatternRegex = /^\^.*\$$/
12
+ const normalizedPatternRegex = /^\^.*\$$/;
17
13
  ajv.addFormat('regexPattern', {
18
- async: true,
19
- validate: (data) => normalizedPatternRegex.test(data),
20
- })
21
-
14
+ async: true,
15
+ validate: (data) => normalizedPatternRegex.test(data),
16
+ });
22
17
  const bundlesSchema = {
23
- $async: true,
24
- type: 'object',
25
- required: ['asset', 'format'],
26
- properties: {
27
- asset: { type: 'string' },
28
- format: { type: 'string' },
29
- },
30
- additionalProperties: false,
31
- }
32
-
18
+ $async: true,
19
+ type: 'object',
20
+ required: ['asset', 'format'],
21
+ properties: {
22
+ asset: { type: 'string' },
23
+ format: { type: 'string' },
24
+ },
25
+ additionalProperties: false,
26
+ };
33
27
  const routesSchema = {
34
- $async: true,
35
- type: 'object',
36
- required: ['function', 'pattern'],
37
- properties: {
38
- name: { type: 'string' },
39
- function: { type: 'string' },
40
- pattern: { type: 'string', format: 'regexPattern', errorMessage: `must match format ${normalizedPatternRegex}` },
41
- },
42
- additionalProperties: false,
43
- }
44
-
45
- const edgeManifestSchema = {
46
- $async: true,
47
- type: 'object',
48
- required: ['bundles', 'routes', 'bundler_version'],
49
- properties: {
50
- bundles: {
51
- type: 'array',
52
- items: bundlesSchema,
28
+ $async: true,
29
+ type: 'object',
30
+ required: ['function', 'pattern'],
31
+ properties: {
32
+ name: { type: 'string' },
33
+ function: { type: 'string' },
34
+ pattern: { type: 'string', format: 'regexPattern', errorMessage: `must match format ${normalizedPatternRegex}` },
53
35
  },
54
- routes: {
55
- type: 'array',
56
- items: routesSchema,
36
+ additionalProperties: false,
37
+ };
38
+ const edgeManifestSchema = {
39
+ $async: true,
40
+ type: 'object',
41
+ required: ['bundles', 'routes', 'bundler_version'],
42
+ properties: {
43
+ bundles: {
44
+ type: 'array',
45
+ items: bundlesSchema,
46
+ },
47
+ routes: {
48
+ type: 'array',
49
+ items: routesSchema,
50
+ },
51
+ bundler_version: { type: 'string' },
57
52
  },
58
- bundler_version: { type: 'string' },
59
- },
60
- additionalProperties: false,
61
- errorMessage: "Couldn't validate Edge Functions manifest.json",
62
- }
63
-
53
+ additionalProperties: false,
54
+ errorMessage: "Couldn't validate Edge Functions manifest.json",
55
+ };
64
56
  const validateManifest = async (manifestData) => {
65
- const validate = ajv.compile(edgeManifestSchema)
66
-
67
- await validate(manifestData)
68
- }
69
-
70
- export const validateEdgeFunctionsManifest = async function ({
71
- buildDir,
72
- constants: { EDGE_FUNCTIONS_DIST: distDirectory },
73
- }) {
74
- try {
75
- const edgeFunctionsDistPath = resolve(buildDir, distDirectory)
76
- const manifestPath = join(edgeFunctionsDistPath, 'manifest.json')
77
- const data = await fs.readFile(manifestPath)
78
- const manifestData = JSON.parse(data)
79
-
80
- await validateManifest(manifestData)
81
- } catch (error) {
82
- const isValidationErr = error instanceof Ajv.ValidationError
83
- const parsedErr = isValidationErr ? error.errors : error
84
-
85
- addErrorInfo(parsedErr, { type: 'coreStep' })
86
- throw new Error(isValidationErr ? JSON.stringify(parsedErr, null, 2) : parsedErr)
87
- }
88
-
89
- return {}
90
- }
57
+ const validate = ajv.compile(edgeManifestSchema);
58
+ await validate(manifestData);
59
+ };
60
+ export const validateEdgeFunctionsManifest = async function ({ buildDir, constants: { EDGE_FUNCTIONS_DIST: distDirectory }, }) {
61
+ try {
62
+ const edgeFunctionsDistPath = resolve(buildDir, distDirectory);
63
+ const manifestPath = join(edgeFunctionsDistPath, 'manifest.json');
64
+ const data = await fs.readFile(manifestPath);
65
+ const manifestData = JSON.parse(data);
66
+ await validateManifest(manifestData);
67
+ }
68
+ catch (error) {
69
+ const isValidationErr = error instanceof Ajv.ValidationError;
70
+ const parsedErr = isValidationErr ? error.errors : error;
71
+ addErrorInfo(parsedErr, { type: 'coreStep' });
72
+ throw new Error(isValidationErr ? JSON.stringify(parsedErr, null, 2) : parsedErr);
73
+ }
74
+ return {};
75
+ };
@@ -1,133 +1,99 @@
1
- import readdirp from 'readdirp'
2
-
3
- import { addErrorInfo } from '../../error/info.js'
4
-
5
- const MODULE_NOT_FOUND_CODE = 'MODULE_NOT_FOUND'
6
- const MODULE_NOT_FOUND_ESBUILD_REGEXP = /^Could not resolve ['"]([^'"]+)/
7
- const MODULE_NOT_FOUND_REGEXP = /Cannot find module ['"]([^'"]+)/
8
-
1
+ import readdirp from 'readdirp';
2
+ import { addErrorInfo } from '../../error/info.js';
3
+ const MODULE_NOT_FOUND_CODE = 'MODULE_NOT_FOUND';
4
+ const MODULE_NOT_FOUND_ESBUILD_REGEXP = /^Could not resolve ['"]([^'"]+)/;
5
+ const MODULE_NOT_FOUND_REGEXP = /Cannot find module ['"]([^'"]+)/;
9
6
  // Handle errors coming from zip-it-and-ship-it
10
7
  export const getZipError = async function (error, functionsSrc) {
11
- const moduleNotFoundError = await getModuleNotFoundError(error, functionsSrc)
12
-
13
- if (moduleNotFoundError) {
14
- return moduleNotFoundError
15
- }
16
-
17
- if (isPackageJsonError(error)) {
18
- return getPackageJsonError(error)
19
- }
20
-
21
- return error
22
- }
23
-
8
+ const moduleNotFoundError = await getModuleNotFoundError(error, functionsSrc);
9
+ if (moduleNotFoundError) {
10
+ return moduleNotFoundError;
11
+ }
12
+ if (isPackageJsonError(error)) {
13
+ return getPackageJsonError(error);
14
+ }
15
+ return error;
16
+ };
24
17
  const getModuleNotFoundError = async function (error, functionsSrc) {
25
- const errorFromZisi = await getModuleNotFoundErrorFromZISI(error, functionsSrc)
26
-
27
- if (errorFromZisi) {
28
- return errorFromZisi
29
- }
30
-
31
- const errorFromEsbuild = await getModuleNotFoundErrorFromEsbuild(error, functionsSrc)
32
-
33
- if (errorFromEsbuild) {
34
- return errorFromEsbuild
35
- }
36
- }
37
-
18
+ const errorFromZisi = await getModuleNotFoundErrorFromZISI(error, functionsSrc);
19
+ if (errorFromZisi) {
20
+ return errorFromZisi;
21
+ }
22
+ const errorFromEsbuild = await getModuleNotFoundErrorFromEsbuild(error, functionsSrc);
23
+ if (errorFromEsbuild) {
24
+ return errorFromEsbuild;
25
+ }
26
+ };
38
27
  const getModuleNotFoundErrorObject = async ({ error, functionsSrc, moduleNames }) => {
39
- const message = await getModuleNotFoundMessage(functionsSrc, moduleNames)
40
-
41
- error.message = `${message}\n\n${error.message}`
42
- addErrorInfo(error, { type: 'dependencies' })
43
-
44
- return error
45
- }
46
-
28
+ const message = await getModuleNotFoundMessage(functionsSrc, moduleNames);
29
+ error.message = `${message}\n\n${error.message}`;
30
+ addErrorInfo(error, { type: 'dependencies' });
31
+ return error;
32
+ };
47
33
  const getModuleNotFoundMessage = async function (functionsSrc, moduleNames) {
48
- if (moduleNames.length === 0 || !(await lacksNodeModules(functionsSrc))) {
49
- return MODULE_NOT_FOUND_MESSAGE
50
- }
51
-
52
- if (moduleNames.filter(Boolean).some(isLocalPath)) {
53
- return PATH_NOT_FOUND_MESSAGE
54
- }
55
-
56
- return getLocalInstallMessage(moduleNames)
57
- }
58
-
34
+ if (moduleNames.length === 0 || !(await lacksNodeModules(functionsSrc))) {
35
+ return MODULE_NOT_FOUND_MESSAGE;
36
+ }
37
+ if (moduleNames.filter(Boolean).some(isLocalPath)) {
38
+ return PATH_NOT_FOUND_MESSAGE;
39
+ }
40
+ return getLocalInstallMessage(moduleNames);
41
+ };
59
42
  const isLocalPath = function (moduleName) {
60
- return moduleName.startsWith('.') || moduleName.startsWith('/')
61
- }
62
-
43
+ return moduleName.startsWith('.') || moduleName.startsWith('/');
44
+ };
63
45
  const getModuleNotFoundErrorFromEsbuild = function (error, functionsSrc) {
64
- const { errors = [] } = error
65
- const modulesNotFound = errors.reduce((modules, errorObject) => {
66
- const match = errorObject.text.match(MODULE_NOT_FOUND_ESBUILD_REGEXP)
67
-
68
- if (!match) {
69
- return modules
46
+ const { errors = [] } = error;
47
+ const modulesNotFound = errors.reduce((modules, errorObject) => {
48
+ const match = errorObject.text.match(MODULE_NOT_FOUND_ESBUILD_REGEXP);
49
+ if (!match) {
50
+ return modules;
51
+ }
52
+ return [...modules, match[1]];
53
+ }, []);
54
+ if (modulesNotFound.length === 0) {
55
+ return;
70
56
  }
71
-
72
- return [...modules, match[1]]
73
- }, [])
74
-
75
- if (modulesNotFound.length === 0) {
76
- return
77
- }
78
-
79
- return getModuleNotFoundErrorObject({ error, functionsSrc, moduleNames: modulesNotFound })
80
- }
81
-
57
+ return getModuleNotFoundErrorObject({ error, functionsSrc, moduleNames: modulesNotFound });
58
+ };
82
59
  const getModuleNotFoundErrorFromZISI = function (error, functionsSrc) {
83
- if (!(error instanceof Error && error.code === MODULE_NOT_FOUND_CODE)) {
84
- return
85
- }
86
-
87
- const moduleName = getModuleNameFromZISIError(error)
88
-
89
- return getModuleNotFoundErrorObject({ error, functionsSrc, moduleNames: moduleName ? [moduleName] : [] })
90
- }
91
-
60
+ if (!(error instanceof Error && error.code === MODULE_NOT_FOUND_CODE)) {
61
+ return;
62
+ }
63
+ const moduleName = getModuleNameFromZISIError(error);
64
+ return getModuleNotFoundErrorObject({ error, functionsSrc, moduleNames: moduleName ? [moduleName] : [] });
65
+ };
92
66
  // This error message always include the same words
93
67
  const getModuleNameFromZISIError = function (error) {
94
- if (typeof error.message !== 'string') {
95
- return
96
- }
97
-
98
- const result = MODULE_NOT_FOUND_REGEXP.exec(error.message)
99
- if (result === null) {
100
- return
101
- }
102
-
103
- return result[1]
104
- }
105
-
68
+ if (typeof error.message !== 'string') {
69
+ return;
70
+ }
71
+ const result = MODULE_NOT_FOUND_REGEXP.exec(error.message);
72
+ if (result === null) {
73
+ return;
74
+ }
75
+ return result[1];
76
+ };
106
77
  // Netlify Functions has a `package.json` but no `node_modules`
107
78
  const lacksNodeModules = async function (functionsSrc) {
108
- return (
109
- functionsSrc !== undefined &&
110
- (await hasFunctionRootFile('package.json', functionsSrc)) &&
111
- !(await hasFunctionRootFile('node_modules', functionsSrc))
112
- )
113
- }
114
-
79
+ return (functionsSrc !== undefined &&
80
+ (await hasFunctionRootFile('package.json', functionsSrc)) &&
81
+ !(await hasFunctionRootFile('node_modules', functionsSrc)));
82
+ };
115
83
  // Functions can be either files or directories, so we need to check on two
116
84
  // depth levels
117
85
  const hasFunctionRootFile = async function (filename, functionsSrc) {
118
- const files = await readdirp.promise(functionsSrc, { depth: 1, fileFilter: filename })
119
- return files.length !== 0
120
- }
121
-
86
+ const files = await readdirp.promise(functionsSrc, { depth: 1, fileFilter: filename });
87
+ return files.length !== 0;
88
+ };
122
89
  const MODULE_NOT_FOUND_MESSAGE = `A Netlify Function failed to require one of its dependencies.
123
- Please make sure it is present in the site's top-level "package.json".`
90
+ Please make sure it is present in the site's top-level "package.json".`;
124
91
  const PATH_NOT_FOUND_MESSAGE = `A Netlify Function failed to require a local file.
125
- Please make sure the file exists and its path is correctly spelled.`
126
-
92
+ Please make sure the file exists and its path is correctly spelled.`;
127
93
  // A common mistake is to assume Netlify Functions dependencies are
128
94
  // automatically installed. This checks for this pattern.
129
95
  const getLocalInstallMessage = function (modules) {
130
- const genericMessage = `
96
+ const genericMessage = `
131
97
 
132
98
  By default, dependencies inside a Netlify Function's "package.json" are not automatically installed.
133
99
  There are several ways to fix this problem:
@@ -137,27 +103,21 @@ There are several ways to fix this problem:
137
103
 
138
104
  [[plugins]]
139
105
  package = "@netlify/plugin-functions-install-core"
140
- `
141
-
142
- if (modules.length === 1) {
143
- return `A Netlify Function is using "${modules[0]}" but that dependency has not been installed yet.${genericMessage}`
144
- }
145
-
146
- const moduleNames = modules.map((name) => `"${name}"`).join(', ')
147
-
148
- return `A Netlify Function is using dependencies that have not been installed yet: ${moduleNames}${genericMessage}`
149
- }
150
-
106
+ `;
107
+ if (modules.length === 1) {
108
+ return `A Netlify Function is using "${modules[0]}" but that dependency has not been installed yet.${genericMessage}`;
109
+ }
110
+ const moduleNames = modules.map((name) => `"${name}"`).join(', ');
111
+ return `A Netlify Function is using dependencies that have not been installed yet: ${moduleNames}${genericMessage}`;
112
+ };
151
113
  // We need to load the site's `package.json` when bundling Functions. This is
152
114
  // because `optionalDependencies` can make `import()` fail, but we don't want
153
115
  // to error then. However, if the `package.json` is invalid, we fail the build.
154
116
  const isPackageJsonError = function (error) {
155
- return PACKAGE_JSON_ORIGINAL_MESSAGES.some((msg) => error.message.includes(msg))
156
- }
157
-
158
- const PACKAGE_JSON_ORIGINAL_MESSAGES = ['is invalid JSON', 'in JSON at position']
159
-
117
+ return PACKAGE_JSON_ORIGINAL_MESSAGES.some((msg) => error.message.includes(msg));
118
+ };
119
+ const PACKAGE_JSON_ORIGINAL_MESSAGES = ['is invalid JSON', 'in JSON at position'];
160
120
  const getPackageJsonError = function (error) {
161
- addErrorInfo(error, { type: 'resolveConfig' })
162
- return error
163
- }
121
+ addErrorInfo(error, { type: 'resolveConfig' });
122
+ return error;
123
+ };
@@ -1,6 +1,6 @@
1
1
  export const getZisiFeatureFlags = (featureFlags) => ({
2
- ...featureFlags,
3
- defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
4
- parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
5
- traceWithNft: featureFlags.buildbot_zisi_trace_nft,
6
- })
2
+ ...featureFlags,
3
+ defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
4
+ parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
5
+ traceWithNft: featureFlags.buildbot_zisi_trace_nft,
6
+ });