@netlify/build 29.43.0 → 29.44.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/lib/core/build.js CHANGED
@@ -382,6 +382,8 @@ const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig
382
382
  debug,
383
383
  verbose,
384
384
  netlifyConfig,
385
+ featureFlags,
386
+ systemLog,
385
387
  });
386
388
  const { steps, events } = timeline === 'dev' ? getDevSteps(devCommand, pluginsSteps, eventHandlers) : getSteps(pluginsSteps, eventHandlers);
387
389
  if (dry) {
@@ -17,4 +17,5 @@ export const DEFAULT_FEATURE_FLAGS = {
17
17
  edge_functions_system_logger: false,
18
18
  netlify_build_reduced_output: false,
19
19
  netlify_build_updated_plugin_compatibility: false,
20
+ netlify_build_plugin_system_log: false,
20
21
  };
@@ -1,4 +1,4 @@
1
- export function loadPlugins({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose, netlifyConfig, }: {
1
+ export function loadPlugins({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose, netlifyConfig, featureFlags, systemLog, }: {
2
2
  pluginsOptions: any;
3
3
  childProcesses: any;
4
4
  packageJson: any;
@@ -7,4 +7,6 @@ export function loadPlugins({ pluginsOptions, childProcesses, packageJson, timer
7
7
  debug: any;
8
8
  verbose: any;
9
9
  netlifyConfig: any;
10
+ featureFlags: any;
11
+ systemLog: any;
10
12
  }): Promise<any>;
@@ -1,16 +1,39 @@
1
+ import { promisify } from 'util';
1
2
  import { addErrorInfo } from '../error/info.js';
2
3
  import { addPluginLoadErrorStatus } from '../status/load_error.js';
3
4
  import { measureDuration } from '../time/main.js';
4
5
  import { callChild } from './ipc.js';
6
+ const pSetTimeout = promisify(setTimeout);
5
7
  // Retrieve all plugins steps
6
8
  // Can use either a module name or a file path to the plugin.
7
- export const loadPlugins = async function ({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose, netlifyConfig, }) {
9
+ export const loadPlugins = async function ({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose, netlifyConfig, featureFlags, systemLog, }) {
8
10
  return pluginsOptions.length === 0
9
11
  ? { pluginsSteps: [], timers }
10
- : await loadAllPlugins({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose, netlifyConfig });
12
+ : await loadAllPlugins({
13
+ pluginsOptions,
14
+ childProcesses,
15
+ packageJson,
16
+ timers,
17
+ logs,
18
+ debug,
19
+ verbose,
20
+ netlifyConfig,
21
+ featureFlags,
22
+ systemLog,
23
+ });
11
24
  };
12
- const tLoadAllPlugins = async function ({ pluginsOptions, childProcesses, packageJson, logs, debug, verbose, netlifyConfig, }) {
13
- const pluginsSteps = await Promise.all(pluginsOptions.map((pluginOptions, index) => loadPlugin(pluginOptions, { childProcesses, index, packageJson, logs, debug, verbose, netlifyConfig })));
25
+ const tLoadAllPlugins = async function ({ pluginsOptions, childProcesses, packageJson, logs, debug, verbose, netlifyConfig, featureFlags, systemLog, }) {
26
+ const pluginsSteps = await Promise.all(pluginsOptions.map((pluginOptions, index) => loadPlugin(pluginOptions, {
27
+ childProcesses,
28
+ index,
29
+ packageJson,
30
+ logs,
31
+ debug,
32
+ verbose,
33
+ netlifyConfig,
34
+ featureFlags,
35
+ systemLog,
36
+ })));
14
37
  const pluginsStepsA = pluginsSteps.flat();
15
38
  return { pluginsSteps: pluginsStepsA };
16
39
  };
@@ -18,9 +41,19 @@ const tLoadAllPlugins = async function ({ pluginsOptions, childProcesses, packag
18
41
  const loadAllPlugins = measureDuration(tLoadAllPlugins, 'load_plugins');
19
42
  // Retrieve plugin steps for one plugin.
20
43
  // Do it by executing the plugin `load` event handler.
21
- const loadPlugin = async function ({ packageName, pluginPackageJson, pluginPackageJson: { version } = {}, pluginPath, inputs, loadedFrom, origin }, { childProcesses, index, packageJson, logs, debug, verbose, netlifyConfig }) {
44
+ const loadPlugin = async function ({ packageName, pluginPackageJson, pluginPackageJson: { version } = {}, pluginPath, inputs, loadedFrom, origin }, { childProcesses, index, packageJson, logs, debug, verbose, netlifyConfig, featureFlags, systemLog }) {
22
45
  const { childProcess } = childProcesses[index];
23
46
  const loadEvent = 'load';
47
+ // A buffer for any data piped into the child process' stderr. We'll pipe
48
+ // this to system logs if we fail to load the plugin.
49
+ const bufferedStdErr = [];
50
+ let bufferedStdListener;
51
+ if (featureFlags.netlify_build_plugin_system_log && childProcess.stderr) {
52
+ bufferedStdListener = (data) => {
53
+ bufferedStdErr.push(data.toString().trimEnd());
54
+ };
55
+ childProcess.stderr.on('data', bufferedStdListener);
56
+ }
24
57
  try {
25
58
  const { events } = await callChild({
26
59
  childProcess,
@@ -40,6 +73,13 @@ const loadPlugin = async function ({ packageName, pluginPackageJson, pluginPacka
40
73
  return pluginSteps;
41
74
  }
42
75
  catch (error) {
76
+ if (featureFlags.netlify_build_plugin_system_log) {
77
+ // Wait for stderr to be flushed.
78
+ await pSetTimeout(0);
79
+ bufferedStdErr.forEach((line) => {
80
+ systemLog(line);
81
+ });
82
+ }
43
83
  addErrorInfo(error, {
44
84
  plugin: { packageName, pluginPackageJson },
45
85
  location: { event: loadEvent, packageName, loadedFrom, origin },
@@ -47,4 +87,9 @@ const loadPlugin = async function ({ packageName, pluginPackageJson, pluginPacka
47
87
  addPluginLoadErrorStatus({ error, packageName, version, debug });
48
88
  throw error;
49
89
  }
90
+ finally {
91
+ if (bufferedStdListener) {
92
+ childProcess.stderr.removeListener('data', bufferedStdListener);
93
+ }
94
+ }
50
95
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.43.0",
3
+ "version": "29.44.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -165,5 +165,5 @@
165
165
  "engines": {
166
166
  "node": "^14.16.0 || >=16.0.0"
167
167
  },
168
- "gitHead": "5c7e4326ca1e4f0134506295281f76ed842d31f5"
168
+ "gitHead": "bd868b81a1ead42e337bea8bebfee0d51307e078"
169
169
  }