@netlify/build 27.9.0 → 27.11.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "27.9.0",
3
+ "version": "27.11.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./src/core/main.js",
@@ -56,7 +56,7 @@
56
56
  "license": "MIT",
57
57
  "dependencies": {
58
58
  "@bugsnag/js": "^7.0.0",
59
- "@netlify/edge-bundler": "^1.8.0",
59
+ "@netlify/edge-bundler": "^1.10.0",
60
60
  "@netlify/cache-utils": "^4.0.0",
61
61
  "@netlify/config": "^18.1.2",
62
62
  "@netlify/functions-utils": "^4.2.2",
@@ -18,4 +18,5 @@ export const DEFAULT_FEATURE_FLAGS = {
18
18
  buildbot_zisi_esbuild_parser: false,
19
19
  edge_functions_cache_cli: false,
20
20
  edge_functions_produce_eszip: false,
21
+ edge_functions_system_logger: false,
21
22
  }
package/src/log/logger.js CHANGED
@@ -113,11 +113,21 @@ export const logWarningSubHeader = function (logs, string, opts) {
113
113
  const reduceLogLines = function (lines) {
114
114
  return lines
115
115
  .map((input) => {
116
+ if (input instanceof Error) {
117
+ return `${input.message} ${input.stack}`
118
+ }
119
+
116
120
  if (typeof input === 'object') {
117
- return JSON.stringify(input)
121
+ try {
122
+ return JSON.stringify(input)
123
+ } catch {
124
+ // Value could not be serialized to JSON, so we return the string
125
+ // representation.
126
+ return String(input)
127
+ }
118
128
  }
119
129
 
120
- return input.toString()
130
+ return String(input)
121
131
  })
122
132
  .join(' ')
123
133
  }
@@ -125,18 +135,27 @@ const reduceLogLines = function (lines) {
125
135
  // Builds a function for logging data to the system logger (i.e. hidden from
126
136
  // the user-facing build logs)
127
137
  export const getSystemLogger = function (logs, debug, systemLogFile) {
128
- // If there's not a file descriptor (or it's set to 0, matching stdout), we
129
- // send debug lines to the normal logger. The same happens if the `debug`
130
- // flag is used, since that means we want to print logs to stdout.
131
- if (!systemLogFile || debug) {
138
+ // If the `debug` flag is used, we return a function that pipes system logs
139
+ // to the regular logger, as the intention is for them to end up in stdout.
140
+ if (debug) {
132
141
  return (...args) => log(logs, reduceLogLines(args))
133
142
  }
134
143
 
144
+ // If there's not a file descriptor configured for system logs and `debug`
145
+ // is not set, we return a no-op function that will swallow the errors.
146
+ if (!systemLogFile) {
147
+ return () => {
148
+ // no-op
149
+ }
150
+ }
151
+
152
+ // Return a function that writes to the file descriptor configured for system
153
+ // logs.
135
154
  const fileDescriptor = createWriteStream(null, { fd: systemLogFile })
136
155
 
137
156
  fileDescriptor.on('error', () => {
138
157
  logError(logs, 'Could not write to system log file')
139
158
  })
140
159
 
141
- return (...args) => fileDescriptor.write(reduceLogLines(args))
160
+ return (...args) => fileDescriptor.write(`${reduceLogLines(args)}\n`)
142
161
  }
@@ -14,7 +14,7 @@ import { validateEdgeFunctionsManifest } from './validate_manifest/validate_edge
14
14
  const DENO_CLI_CACHE_DIRECTORY = '.netlify/plugins/deno-cli'
15
15
  const IMPORT_MAP_FILENAME = 'edge-functions-import-map.json'
16
16
 
17
- // eslint-disable-next-line max-statements
17
+ // eslint-disable-next-line complexity, max-statements
18
18
  const coreStep = async function ({
19
19
  buildDir,
20
20
  constants: {
@@ -57,6 +57,7 @@ const coreStep = async function ({
57
57
  distImportMapPath,
58
58
  featureFlags,
59
59
  importMaps: [importMap].filter(Boolean),
60
+ systemLogger: featureFlags.edge_functions_system_logger ? systemLog : undefined,
60
61
  })
61
62
 
62
63
  systemLog('Edge Functions manifest:', manifest)