@netlify/build 29.4.0 → 29.4.89-test

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.
@@ -6,9 +6,10 @@ import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle } fr
6
6
  import { getZipError } from './error.js';
7
7
  import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js';
8
8
  import { getZisiParameters } from './zisi.js';
9
- // Returns `true` if at least one of the functions has been configured to use
10
- // esbuild.
11
- const isUsingEsbuild = (functionsConfig = {}) => Object.values(functionsConfig).some((configObject) => configObject.node_bundler === 'esbuild');
9
+ // Get a list of all unique bundlers in this run
10
+ const getBundlers = (results = []) => Array.from(new Set(results
11
+ .map((bundle) => (bundle.runtime === "js" /* RuntimeType.JAVASCRIPT */ ? bundle.bundler : null))
12
+ .filter(Boolean)));
12
13
  const zipFunctionsAndLogResults = async ({ buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot, }) => {
13
14
  const zisiParameters = getZisiParameters({
14
15
  buildDir,
@@ -20,14 +21,14 @@ const zipFunctionsAndLogResults = async ({ buildDir, childEnv, featureFlags, fun
20
21
  isRunningLocally,
21
22
  repositoryRoot,
22
23
  });
23
- const bundler = isUsingEsbuild(functionsConfig) ? 'esbuild' : 'zisi';
24
24
  try {
25
25
  // Printing an empty line before bundling output.
26
26
  log(logs, '');
27
27
  const sourceDirectories = [internalFunctionsSrc, functionsSrc].filter(Boolean);
28
28
  const results = await zipItAndShipIt.zipFunctions(sourceDirectories, functionsDist, zisiParameters);
29
+ const bundlers = getBundlers(results);
29
30
  logBundleResults({ logs, results });
30
- return { bundler };
31
+ return { bundlers };
31
32
  }
32
33
  catch (error) {
33
34
  throw await getZipError(error, functionsSrc);
@@ -39,7 +40,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
39
40
  const functionsDist = resolve(buildDir, relativeFunctionsDist);
40
41
  const internalFunctionsSrc = resolve(buildDir, relativeInternalFunctionsSrc);
41
42
  const internalFunctionsSrcExists = await pathExists(internalFunctionsSrc);
42
- const functionsSrcExists = await validateFunctionsSrc({ functionsSrc, logs, relativeFunctionsSrc });
43
+ const functionsSrcExists = await validateFunctionsSrc({ functionsSrc, relativeFunctionsSrc });
43
44
  const [userFunctions = [], internalFunctions = []] = await getUserAndInternalFunctions({
44
45
  featureFlags,
45
46
  functionsSrc,
@@ -64,7 +65,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
64
65
  if (userFunctions.length === 0 && internalFunctions.length === 0) {
65
66
  return {};
66
67
  }
67
- const { bundler } = await zipFunctionsAndLogResults({
68
+ const { bundlers } = await zipFunctionsAndLogResults({
68
69
  buildDir,
69
70
  childEnv,
70
71
  featureFlags,
@@ -78,7 +79,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
78
79
  });
79
80
  return {
80
81
  tags: {
81
- bundler,
82
+ bundler: bundlers,
82
83
  },
83
84
  };
84
85
  };
@@ -1,31 +1,26 @@
1
1
  import { promisify } from 'util';
2
2
  import slugify from '@sindresorhus/slugify';
3
- import StatsdClient from 'statsd-client';
4
- // TODO: replace with `timers/promises` after dropping Node < 15.0.0
5
- const pSetTimeout = promisify(setTimeout);
6
- // See https://github.com/msiebuhr/node-statsd-client/blob/45a93ee4c94ca72f244a40b06cb542d4bd7c3766/lib/EphemeralSocket.js#L81
7
- const CLOSE_TIMEOUT = 11;
8
- // The socket creation is delayed until the first packet is sent. In our
9
- // case, this happens just before `client.close()` is called, which is too
10
- // late and make it not send anything. We need to manually create it using
11
- // the internal API.
3
+ import { StatsD } from 'hot-shots';
12
4
  export const startClient = async function (host, port) {
13
- const client = new StatsdClient({ host, port, socketTimeout: 0 });
14
- // @ts-expect-error using internals :D
15
- await promisify(client._socket._createSocket.bind(client._socket))();
16
- return client;
5
+ return new StatsD({ host, port, cacheDns: true });
17
6
  };
18
- // UDP packets are buffered and flushed at regular intervals by statsd-client.
19
- // Closing force flushing all of them.
20
7
  export const closeClient = async function (client) {
21
- client.close();
22
- // statsd-client does not provide a way of knowing when the socket is done
23
- // closing, so we need to use the following hack.
24
- await pSetTimeout(CLOSE_TIMEOUT);
25
- await pSetTimeout(CLOSE_TIMEOUT);
8
+ await promisify(client.close.bind(client))();
26
9
  };
27
10
  // Make sure the timer name does not include special characters.
28
11
  // For example, the `packageName` of local plugins includes dots.
29
12
  export const normalizeTagName = function (name) {
30
13
  return slugify(name, { separator: '_' });
31
14
  };
15
+ export const formatTags = function (tags) {
16
+ return Object.entries(tags)
17
+ .map(([key, value]) => {
18
+ if (Array.isArray(value)) {
19
+ return value.map((subValue) => `${key}:${subValue}`);
20
+ }
21
+ else {
22
+ return `${key}:${value}`;
23
+ }
24
+ })
25
+ .flat();
26
+ };
@@ -1,24 +1,27 @@
1
- import { closeClient, startClient } from '../report/statsd.js';
1
+ import { closeClient, formatTags, startClient } from '../report/statsd.js';
2
2
  import { addAggregatedTimers } from './aggregate.js';
3
3
  import { roundTimerToMillisecs } from './measure.js';
4
4
  // Record the duration of a build phase, for monitoring.
5
5
  // Sends to statsd daemon.
6
- export const reportTimers = async function ({ timers, statsdOpts: { host, port }, framework }) {
6
+ export const reportTimers = async function ({ timers, statsdOpts: { host, port }, framework, }) {
7
7
  if (host === undefined) {
8
8
  return;
9
9
  }
10
10
  const timersA = addAggregatedTimers(timers);
11
- await sendTimers({ timers: timersA, host, port, framework });
11
+ await sendTimers({ timers: timersA, statsdOpts: { host, port }, framework });
12
12
  };
13
- const sendTimers = async function ({ timers, host, port, framework }) {
13
+ const sendTimers = async function ({ timers, statsdOpts: { host, port }, framework, }) {
14
14
  const client = await startClient(host, port);
15
15
  timers.forEach((timer) => {
16
16
  sendTimer({ timer, client, framework });
17
17
  });
18
18
  await closeClient(client);
19
19
  };
20
- const sendTimer = function ({ timer: { metricName, stageTag, parentTag, durationNs, tags }, client, framework }) {
20
+ const sendTimer = function ({ timer: { metricName, stageTag, parentTag, durationNs, tags }, client, framework, }) {
21
21
  const durationMs = roundTimerToMillisecs(durationNs);
22
- const frameworkTag = framework === undefined ? {} : { framework };
23
- client.distribution(metricName, durationMs, { stage: stageTag, parent: parentTag, ...tags, ...frameworkTag });
22
+ const statsdTags = { stage: stageTag, parent: parentTag, ...tags };
23
+ if (framework != undefined) {
24
+ statsdTags.framework = framework;
25
+ }
26
+ client.distribution(metricName, durationMs, formatTags(statsdTags));
24
27
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.4.0",
3
+ "version": "29.4.89-test",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/core/main.js",
@@ -69,7 +69,7 @@
69
69
  "@netlify/edge-bundler": "8.0.0",
70
70
  "@netlify/functions-utils": "^5.1.1",
71
71
  "@netlify/git-utils": "^5.1.0",
72
- "@netlify/plugins-list": "^6.59.0",
72
+ "@netlify/plugins-list": "^6.61.0",
73
73
  "@netlify/run-utils": "^5.1.0",
74
74
  "@netlify/zip-it-and-ship-it": "^8.2.0",
75
75
  "@sindresorhus/slugify": "^2.0.0",
@@ -80,6 +80,7 @@
80
80
  "figures": "^4.0.0",
81
81
  "filter-obj": "^3.0.0",
82
82
  "got": "^10.0.0",
83
+ "hot-shots": "9.3.0",
83
84
  "indent-string": "^5.0.0",
84
85
  "is-plain-obj": "^4.0.0",
85
86
  "js-yaml": "^4.0.0",
@@ -105,7 +106,6 @@
105
106
  "rfdc": "^1.3.0",
106
107
  "safe-json-stringify": "^1.2.0",
107
108
  "semver": "^7.0.0",
108
- "statsd-client": "0.4.7",
109
109
  "string-width": "^5.0.0",
110
110
  "strip-ansi": "^7.0.0",
111
111
  "supports-color": "^9.0.0",
@@ -120,7 +120,6 @@
120
120
  "devDependencies": {
121
121
  "@netlify/nock-udp": "^3.1.0",
122
122
  "@types/node": "^14.18.31",
123
- "@types/statsd-client": "^0.4.3",
124
123
  "atob": "^2.1.2",
125
124
  "ava": "^4.0.0",
126
125
  "c8": "^7.12.0",
@@ -148,6 +147,5 @@
148
147
  "compilerOptions": {
149
148
  "module": "commonjs"
150
149
  }
151
- },
152
- "gitHead": "87d6d9344ac37b4c40b70c582958347c0f7fd8eb"
150
+ }
153
151
  }