@netlify/build 19.0.2 → 19.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "19.0.2",
3
+ "version": "19.0.6",
4
4
  "description": "Netlify build module",
5
5
  "main": "src/core/main.js",
6
6
  "types": "types/index.d.ts",
@@ -36,8 +36,8 @@
36
36
  "ci",
37
37
  "plugins",
38
38
  "continuous-integration",
39
- "continuous-delivery",
40
39
  "continuous-deployment",
40
+ "continuous-delivery",
41
41
  "continuous-testing",
42
42
  "netlify-plugin",
43
43
  "netlify"
@@ -58,14 +58,12 @@
58
58
  "@netlify/config": "^16.0.0",
59
59
  "@netlify/functions-utils": "^3.0.0",
60
60
  "@netlify/git-utils": "^3.0.0",
61
- "@netlify/plugin-edge-handlers": "^1.11.22",
61
+ "@netlify/plugin-edge-handlers": "^2.0.0",
62
62
  "@netlify/plugins-list": "^5.0.0",
63
63
  "@netlify/run-utils": "^3.0.0",
64
- "@netlify/zip-it-and-ship-it": "^4.30.0",
64
+ "@netlify/zip-it-and-ship-it": "^5.0.0",
65
65
  "@sindresorhus/slugify": "^1.1.0",
66
- "@ungap/from-entries": "^0.2.1",
67
66
  "ansi-escapes": "^4.3.2",
68
- "array-flat-polyfill": "^1.0.1",
69
67
  "chalk": "^4.1.2",
70
68
  "clean-stack": "^3.0.1",
71
69
  "execa": "^5.1.1",
package/src/core/bin.js CHANGED
@@ -6,8 +6,6 @@ const process = require('process')
6
6
  const filterObj = require('filter-obj')
7
7
  const yargs = require('yargs')
8
8
 
9
- require('../utils/polyfills')
10
-
11
9
  const { normalizeCliFeatureFlags } = require('./feature_flags')
12
10
  const { FLAGS } = require('./flags')
13
11
  const build = require('./main')
package/src/core/main.js CHANGED
@@ -1,8 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  /* eslint-disable max-lines, import/max-dependencies */
4
- require('../utils/polyfills')
5
-
6
4
  const { handleBuildError } = require('../error/handle')
7
5
  const { getErrorInfo } = require('../error/info')
8
6
  const { startErrorMonitor } = require('../error/monitor/start')
@@ -5,7 +5,8 @@ const safeJsonStringify = require('safe-json-stringify')
5
5
  const { CUSTOM_ERROR_KEY } = require('./info')
6
6
 
7
7
  // Retrieve error information from child process and re-build it in current
8
- // process. We need this since errors are not JSON-serializable.
8
+ // process. We need this since errors static properties are not kept by
9
+ // `v8.serialize()`.
9
10
  const jsonToError = function ({ name, message, stack, ...errorProps }) {
10
11
  // eslint-disable-next-line unicorn/error-message
11
12
  const error = new Error('')
@@ -35,8 +36,6 @@ const assignErrorProp = function (error, name, value) {
35
36
  }
36
37
 
37
38
  // Inverse of `jsonToError()`.
38
- // IPC uses JSON for the payload. We ensure there are not circular references
39
- // as those would make the message sending fail.
40
39
  const errorToJson = function ({ name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps }) {
41
40
  return {
42
41
  ...safeJsonStringify.ensureProperties(errorProps),
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ const filterObj = require('filter-obj')
4
+
3
5
  const { getLogic } = require('./logic')
4
6
  const { registerTypeScript } = require('./typescript')
5
7
  const { validatePlugin } = require('./validate')
@@ -15,21 +17,16 @@ const load = function ({ pluginPath, inputs, packageJson }) {
15
17
 
16
18
  validatePlugin(logic)
17
19
 
18
- const pluginSteps = getPluginSteps(logic)
20
+ const methods = filterObj(logic, isEventHandler)
21
+ const events = Object.keys(methods)
19
22
 
20
23
  // Context passed to every event handler
21
- const context = { pluginSteps, inputs, packageJson }
22
-
23
- return { pluginSteps, context }
24
- }
24
+ const context = { methods, inputs, packageJson }
25
25
 
26
- const getPluginSteps = function (logic) {
27
- return Object.entries(logic)
28
- .filter(isEventHandler)
29
- .map(([event, method]) => ({ event, method }))
26
+ return { events, context }
30
27
  }
31
28
 
32
- const isEventHandler = function ([, value]) {
29
+ const isEventHandler = function (event, value) {
33
30
  return typeof value === 'function'
34
31
  }
35
32
 
@@ -1,7 +1,5 @@
1
1
  'use strict'
2
2
 
3
- require('../../utils/polyfills')
4
-
5
3
  const { setInspectColors } = require('../../log/colors')
6
4
  const { sendEventToParent, getEventsFromParent } = require('../ipc')
7
5
 
@@ -6,11 +6,8 @@ const { cloneNetlifyConfig, getConfigMutations } = require('./diff')
6
6
  const { getUtils } = require('./utils')
7
7
 
8
8
  // Run a specific plugin event handler
9
- const run = async function (
10
- { event, error, constants, envChanges, netlifyConfig },
11
- { pluginSteps, inputs, packageJson },
12
- ) {
13
- const { method } = pluginSteps.find((pluginStep) => pluginStep.event === event)
9
+ const run = async function ({ event, error, constants, envChanges, netlifyConfig }, { methods, inputs, packageJson }) {
10
+ const method = methods[event]
14
11
  const runState = {}
15
12
  const utils = getUtils({ event, constants, runState })
16
13
  const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig)
@@ -113,10 +113,9 @@ const sendEventToParent = async function (callId, payload) {
113
113
  await promisify(process.send.bind(process))([callId, payload])
114
114
  }
115
115
 
116
- // Errors are not serializable through `child_process` `ipc` so we need to
117
- // convert from/to plain objects.
118
- // TODO: use `child_process.spawn()` `serialization: 'advanced'` option after
119
- // dropping support for Node.js <=12.6.0
116
+ // Error static properties are not serializable through `child_process`
117
+ // (which uses `v8.serialize()` under the hood) so we need to convert from/to
118
+ // plain objects.
120
119
  const serializePayload = function ({ error = {}, error: { name } = {}, ...payload }) {
121
120
  if (name === undefined) {
122
121
  return payload
@@ -1,8 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  const { pluginsList: oldPluginsList, pluginsUrl } = require('@netlify/plugins-list')
4
- // TODO: replace with `Object.fromEntries()` after dropping Node <12.0.0
5
- const fromEntries = require('@ungap/from-entries')
6
4
  const got = require('got')
7
5
  const isPlainObj = require('is-plain-obj')
8
6
 
@@ -60,7 +58,7 @@ const isValidPluginsList = function (pluginsList) {
60
58
  }
61
59
 
62
60
  const normalizePluginsList = function (pluginsList) {
63
- return fromEntries(pluginsList.map(normalizePluginItem))
61
+ return Object.fromEntries(pluginsList.map(normalizePluginItem))
64
62
  }
65
63
 
66
64
  // `version` in `plugins.json` is the latest version.
@@ -37,8 +37,8 @@ const loadPlugin = async function (
37
37
  const loadEvent = 'load'
38
38
 
39
39
  try {
40
- const { pluginSteps } = await callChild(childProcess, 'load', { pluginPath, inputs, packageJson })
41
- const pluginStepsA = pluginSteps.map(({ event }) => ({
40
+ const { events } = await callChild(childProcess, 'load', { pluginPath, inputs, packageJson })
41
+ const pluginSteps = events.map((event) => ({
42
42
  event,
43
43
  packageName,
44
44
  loadedFrom,
@@ -46,7 +46,7 @@ const loadPlugin = async function (
46
46
  pluginPackageJson,
47
47
  childProcess,
48
48
  }))
49
- return pluginStepsA
49
+ return pluginSteps
50
50
  } catch (error) {
51
51
  addErrorInfo(error, {
52
52
  plugin: { packageName, pluginPackageJson },
@@ -39,6 +39,7 @@ const startPlugin = async function ({ pluginDir, nodePath, buildDir, childEnv })
39
39
  execPath: nodePath,
40
40
  env: childEnv,
41
41
  extendEnv: false,
42
+ serialization: 'advanced',
42
43
  })
43
44
 
44
45
  try {
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- // Patches `Array.flat()` and `Array.flatMap()`
4
- // TODO: remove after dropping Node <12 support
5
- require('array-flat-polyfill')