@netlify/build 18.25.1 → 18.25.2
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
|
@@ -9,9 +9,9 @@ const { validatePlugin } = require('./validate')
|
|
|
9
9
|
// This also validates the plugin.
|
|
10
10
|
// Do it when parent requests it using the `load` event.
|
|
11
11
|
// Also figure out the list of plugin steps. This is also passed to the parent.
|
|
12
|
-
const load =
|
|
13
|
-
registerTypeScript(pluginPath)
|
|
14
|
-
const logic =
|
|
12
|
+
const load = function ({ pluginPath, inputs, packageJson }) {
|
|
13
|
+
const tsNodeService = registerTypeScript(pluginPath)
|
|
14
|
+
const logic = getLogic({ pluginPath, inputs, tsNodeService })
|
|
15
15
|
|
|
16
16
|
validatePlugin(logic)
|
|
17
17
|
|
|
@@ -4,18 +4,18 @@ const { addTsErrorInfo } = require('./typescript')
|
|
|
4
4
|
|
|
5
5
|
// Require the plugin file and fire its top-level function.
|
|
6
6
|
// The returned object is the `logic` which includes all event handlers.
|
|
7
|
-
const getLogic =
|
|
8
|
-
const logic =
|
|
7
|
+
const getLogic = function ({ pluginPath, inputs, tsNodeService }) {
|
|
8
|
+
const logic = requireLogic(pluginPath, tsNodeService)
|
|
9
9
|
const logicA = loadLogic({ logic, inputs })
|
|
10
10
|
return logicA
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
const requireLogic =
|
|
13
|
+
const requireLogic = function (pluginPath, tsNodeService) {
|
|
14
14
|
try {
|
|
15
15
|
// eslint-disable-next-line node/global-require, import/no-dynamic-require
|
|
16
16
|
return require(pluginPath)
|
|
17
17
|
} catch (error) {
|
|
18
|
-
|
|
18
|
+
addTsErrorInfo(error, tsNodeService)
|
|
19
19
|
error.message = `Could not import plugin:\n${error.message}`
|
|
20
20
|
throw error
|
|
21
21
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
const { extname } = require('path')
|
|
4
4
|
|
|
5
|
-
const execa = require('execa')
|
|
6
5
|
const { register } = require('ts-node')
|
|
7
6
|
|
|
8
7
|
const { addErrorInfo } = require('../../error/info')
|
|
@@ -16,39 +15,23 @@ const registerTypeScript = function (pluginPath) {
|
|
|
16
15
|
return
|
|
17
16
|
}
|
|
18
17
|
|
|
19
|
-
register()
|
|
18
|
+
return register()
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
// On TypeScript errors, adds information about the `ts-node` configuration,
|
|
23
22
|
// which includes the resolved `tsconfig.json`.
|
|
24
|
-
const addTsErrorInfo =
|
|
25
|
-
if (
|
|
23
|
+
const addTsErrorInfo = function (error, tsNodeService) {
|
|
24
|
+
if (tsNodeService === undefined) {
|
|
26
25
|
return
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
const {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
// `ts-node` binary.
|
|
37
|
-
localDir: __dirname,
|
|
38
|
-
preferLocal: true,
|
|
39
|
-
})
|
|
40
|
-
const tsConfig = safeJsonParse(stdout)
|
|
41
|
-
addErrorInfo(error, { tsConfig })
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// The output of `ts-node --show-config` should be JSON.
|
|
45
|
-
// This is just a failsafe.
|
|
46
|
-
const safeJsonParse = function (stdout) {
|
|
47
|
-
try {
|
|
48
|
-
return JSON.parse(stdout)
|
|
49
|
-
} catch (error) {
|
|
50
|
-
return { stdout, parsingError: error.message }
|
|
51
|
-
}
|
|
28
|
+
const {
|
|
29
|
+
config: {
|
|
30
|
+
raw: { compilerOptions },
|
|
31
|
+
},
|
|
32
|
+
options: tsNodeOptions,
|
|
33
|
+
} = tsNodeService
|
|
34
|
+
addErrorInfo(error, { tsConfig: { compilerOptions, tsNodeOptions } })
|
|
52
35
|
}
|
|
53
36
|
|
|
54
37
|
const isTypeScriptPlugin = function (pluginPath) {
|