@netlify/build 36.4.8 → 37.1.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/feature_flags.js +1 -0
- package/lib/core/normalize_flags.js +0 -3
- package/lib/plugins_core/functions/index.d.ts +3 -2
- package/lib/plugins_core/functions/index.js +23 -15
- package/lib/plugins_core/functions/server_entry.d.ts +7 -2
- package/lib/plugins_core/functions/server_entry.js +23 -14
- package/lib/plugins_core/functions/zisi.d.ts +5 -3
- package/lib/plugins_core/functions/zisi.js +9 -4
- package/package.json +9 -9
|
@@ -55,12 +55,9 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
|
|
|
55
55
|
testOpts: {},
|
|
56
56
|
featureFlags: DEFAULT_FEATURE_FLAGS,
|
|
57
57
|
statsd: { port: DEFAULT_STATSD_PORT },
|
|
58
|
-
// tracing.apiKey defaults to '-' else we'll get warning logs if not using
|
|
59
|
-
// honeycomb directly - https://github.com/honeycombio/honeycomb-opentelemetry-node/issues/201
|
|
60
58
|
tracing: {
|
|
61
59
|
enabled: false,
|
|
62
60
|
preloadingEnabled: false,
|
|
63
|
-
apiKey: '-',
|
|
64
61
|
// defaults to always sample
|
|
65
62
|
sampleRate: 1,
|
|
66
63
|
httpProtocol: DEFAULT_OTEL_ENDPOINT_PROTOCOL,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type BundleOptions, type BundleResult, type FunctionResult, zipFunctions } from '@netlify/zip-it-and-ship-it';
|
|
2
2
|
import type { CoreStepFunction } from '../types.js';
|
|
3
3
|
export declare const bundleFunctions: {
|
|
4
4
|
event: string;
|
|
@@ -18,5 +18,6 @@ export declare const bundleFunctions: {
|
|
|
18
18
|
}) => Promise<boolean>;
|
|
19
19
|
};
|
|
20
20
|
export declare const zipItAndShipIt: {
|
|
21
|
-
|
|
21
|
+
bundle(options: BundleOptions): Promise<BundleResult>;
|
|
22
|
+
zipFunctions(input: import("@netlify/zip-it-and-ship-it").MixedPaths, destFolder: string, args_2?: import("@netlify/zip-it-and-ship-it").ZipFunctionsOptions | undefined): Promise<FunctionResult[]>;
|
|
22
23
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
-
import { zipFunctions } from '@netlify/zip-it-and-ship-it';
|
|
2
|
+
import { bundle, zipFunctions, } from '@netlify/zip-it-and-ship-it';
|
|
3
3
|
import { pathExists } from '../../utils/path_exists.js';
|
|
4
4
|
import { addErrorInfo } from '../../error/info.js';
|
|
5
5
|
import { log } from '../../log/logger.js';
|
|
@@ -7,7 +7,7 @@ import { getGeneratedFunctions } from '../../steps/return_values.js';
|
|
|
7
7
|
import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle, trackBundleResults, } from '../../log/messages/core_steps.js';
|
|
8
8
|
import { FRAMEWORKS_API_FUNCTIONS_PATH } from '../../utils/frameworks_api.js';
|
|
9
9
|
import { getZipError } from './error.js';
|
|
10
|
-
import { getServerEntry } from './server_entry.js';
|
|
10
|
+
import { getServerEntry, useServer, writeServerShim } from './server_entry.js';
|
|
11
11
|
import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js';
|
|
12
12
|
import { getZisiParameters } from './zisi.js';
|
|
13
13
|
// see https://docs.netlify.com/functions/trigger-on-events/#available-triggers
|
|
@@ -42,7 +42,7 @@ const validateCustomRoutes = function (functions) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, generatedFunctions, frameworkFunctionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot, userNodeVersion, systemLog, }) => {
|
|
45
|
+
const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, generatedFunctions, frameworkFunctionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot, server, userNodeVersion, systemLog, }) => {
|
|
46
46
|
const zisiParameters = getZisiParameters({
|
|
47
47
|
branch,
|
|
48
48
|
buildDir,
|
|
@@ -52,14 +52,7 @@ const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFl
|
|
|
52
52
|
functionsDist,
|
|
53
53
|
internalFunctionsSrc,
|
|
54
54
|
isRunningLocally,
|
|
55
|
-
|
|
56
|
-
userNodeVersion,
|
|
57
|
-
systemLog,
|
|
58
|
-
});
|
|
59
|
-
try {
|
|
60
|
-
// Printing an empty line before bundling output.
|
|
61
|
-
log(logs, '');
|
|
62
|
-
const results = await zipItAndShipIt.zipFunctions({
|
|
55
|
+
paths: {
|
|
63
56
|
generated: {
|
|
64
57
|
directories: [internalFunctionsSrc, frameworkFunctionsSrc].filter(Boolean),
|
|
65
58
|
functions: generatedFunctions,
|
|
@@ -67,7 +60,16 @@ const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFl
|
|
|
67
60
|
user: {
|
|
68
61
|
directories: [functionsSrc].filter(Boolean),
|
|
69
62
|
},
|
|
70
|
-
},
|
|
63
|
+
},
|
|
64
|
+
repositoryRoot,
|
|
65
|
+
server,
|
|
66
|
+
userNodeVersion,
|
|
67
|
+
systemLog,
|
|
68
|
+
});
|
|
69
|
+
try {
|
|
70
|
+
// Printing an empty line before bundling output.
|
|
71
|
+
log(logs, '');
|
|
72
|
+
const { functions: results } = await zipItAndShipIt.bundle(zisiParameters);
|
|
71
73
|
validateCustomRoutes(results);
|
|
72
74
|
logBundleResults({ logs, results });
|
|
73
75
|
const summary = trackBundleResults({ results, systemLog });
|
|
@@ -106,6 +108,9 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
106
108
|
if (serverEntry) {
|
|
107
109
|
log(logs, `Netlify Server detected at ${serverEntry.relativeEntryPath}`);
|
|
108
110
|
}
|
|
111
|
+
const asFunction = featureFlags?.netlify_build_server_entry === true;
|
|
112
|
+
const standalone = featureFlags?.netlify_build_server_standalone === true;
|
|
113
|
+
const serverShimPath = serverEntry && asFunction ? await writeServerShim(serverEntry) : undefined;
|
|
109
114
|
logFunctionsToBundle({
|
|
110
115
|
logs,
|
|
111
116
|
userFunctions,
|
|
@@ -140,8 +145,9 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
140
145
|
systemLog,
|
|
141
146
|
generatedFunctions: [
|
|
142
147
|
...generatedFunctions.map((func) => func.path),
|
|
143
|
-
...(
|
|
148
|
+
...(serverShimPath === undefined ? [] : [serverShimPath]),
|
|
144
149
|
],
|
|
150
|
+
server: serverEntry && standalone ? { path: serverEntry.entryPath } : undefined,
|
|
145
151
|
});
|
|
146
152
|
const fallback = fallbackCount > 0 ? 'true' : 'false';
|
|
147
153
|
const warnings = warningsCount > 0 ? 'true' : 'false';
|
|
@@ -160,8 +166,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
160
166
|
// `condition` because the directories might be created by the build command
|
|
161
167
|
// or plugins.
|
|
162
168
|
const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC }, featureFlags, packagePath, returnValues, }) {
|
|
163
|
-
if (featureFlags
|
|
164
|
-
(await pathExists(resolve(buildDir, packagePath || '', 'netlify/server')))) {
|
|
169
|
+
if (useServer(featureFlags) && (await pathExists(resolve(buildDir, packagePath || '', 'netlify/server')))) {
|
|
165
170
|
return true;
|
|
166
171
|
}
|
|
167
172
|
const hasFunctionsSrc = FUNCTIONS_SRC !== undefined && FUNCTIONS_SRC !== '';
|
|
@@ -210,6 +215,9 @@ export const bundleFunctions = {
|
|
|
210
215
|
// `zip-it-and-ship-it` methods. Therefore, we need to use an intermediary
|
|
211
216
|
// function and export them so tests can use it.
|
|
212
217
|
export const zipItAndShipIt = {
|
|
218
|
+
async bundle(options) {
|
|
219
|
+
return await bundle(options);
|
|
220
|
+
},
|
|
213
221
|
async zipFunctions(...args) {
|
|
214
222
|
return await zipFunctions(...args);
|
|
215
223
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type FeatureFlags } from '../../core/feature_flags.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const useServer: (featureFlags?: FeatureFlags) => boolean;
|
|
3
3
|
export interface ServerEntry {
|
|
4
4
|
entryPath: string;
|
|
5
|
-
|
|
5
|
+
packageRoot: string;
|
|
6
6
|
relativeEntryPath: string;
|
|
7
7
|
}
|
|
8
8
|
export declare const getServerEntry: ({ buildDir, packagePath, featureFlags, }: {
|
|
@@ -10,3 +10,8 @@ export declare const getServerEntry: ({ buildDir, packagePath, featureFlags, }:
|
|
|
10
10
|
packagePath?: string;
|
|
11
11
|
featureFlags?: FeatureFlags;
|
|
12
12
|
}) => Promise<ServerEntry | undefined>;
|
|
13
|
+
/**
|
|
14
|
+
* Writes the file a server is bundled from when it travels as a function, and
|
|
15
|
+
* returns its path.
|
|
16
|
+
*/
|
|
17
|
+
export declare const writeServerShim: ({ entryPath, packageRoot }: ServerEntry) => Promise<string>;
|
|
@@ -2,14 +2,12 @@ import { mkdir, readdir, writeFile } from 'fs/promises';
|
|
|
2
2
|
import { join, resolve } from 'path';
|
|
3
3
|
import { pathExists } from '../../utils/path_exists.js';
|
|
4
4
|
import { addErrorInfo } from '../../error/info.js';
|
|
5
|
-
export const SERVER_ENTRY_FUNCTION_NAME = '___netlify-server';
|
|
6
5
|
const SERVER_ENTRY_DIR = 'netlify/server';
|
|
7
6
|
const SERVER_ENTRY_BASENAMES = new Set(['index.js', 'index.mjs', 'index.ts', 'index.mts']);
|
|
8
|
-
const
|
|
9
|
-
// Finds the user's server entrypoint
|
|
10
|
-
// deployed as.
|
|
7
|
+
export const useServer = (featureFlags) => featureFlags?.netlify_build_server_entry === true || featureFlags?.netlify_build_server_standalone === true;
|
|
8
|
+
// Finds the user's server entrypoint.
|
|
11
9
|
export const getServerEntry = async ({ buildDir, packagePath, featureFlags, }) => {
|
|
12
|
-
if (!featureFlags
|
|
10
|
+
if (!useServer(featureFlags)) {
|
|
13
11
|
return undefined;
|
|
14
12
|
}
|
|
15
13
|
const packageRoot = resolve(buildDir, packagePath ?? '');
|
|
@@ -26,19 +24,19 @@ export const getServerEntry = async ({ buildDir, packagePath, featureFlags, }) =
|
|
|
26
24
|
addErrorInfo(error, { type: 'resolveConfig' });
|
|
27
25
|
throw error;
|
|
28
26
|
}
|
|
29
|
-
const entryPath = join(serverDir, candidates[0]);
|
|
30
|
-
const shimDir = join(packageRoot, SERVER_SHIM_DIR);
|
|
31
|
-
const shimPath = join(shimDir, `${SERVER_ENTRY_FUNCTION_NAME}.mjs`);
|
|
32
|
-
await mkdir(shimDir, { recursive: true });
|
|
33
|
-
await writeFile(shimPath, getShimContents(entryPath));
|
|
34
27
|
return {
|
|
35
|
-
entryPath,
|
|
36
|
-
|
|
28
|
+
entryPath: join(serverDir, candidates[0]),
|
|
29
|
+
packageRoot,
|
|
37
30
|
relativeEntryPath: `${SERVER_ENTRY_DIR}/${candidates[0]}`,
|
|
38
31
|
};
|
|
39
32
|
};
|
|
40
|
-
//
|
|
41
|
-
//
|
|
33
|
+
// Everything below carries a server through the functions plumbing, which is
|
|
34
|
+
// how it was deployed before it stood on its own. It goes away once no deploy
|
|
35
|
+
// is built with the function channel on.
|
|
36
|
+
const SERVER_FUNCTION_NAME = '___netlify-server';
|
|
37
|
+
const SERVER_SHIM_DIR = '.netlify/server-entry';
|
|
38
|
+
// Gives the server the deploy surface of a function without touching the user's
|
|
39
|
+
// code, so that it can be bundled and uploaded as one.
|
|
42
40
|
const getShimContents = (entryPath) => `import * as server from ${JSON.stringify(entryPath)}
|
|
43
41
|
|
|
44
42
|
export default server.default ?? server
|
|
@@ -51,3 +49,14 @@ export const config = {
|
|
|
51
49
|
preferStatic: true,
|
|
52
50
|
}
|
|
53
51
|
`;
|
|
52
|
+
/**
|
|
53
|
+
* Writes the file a server is bundled from when it travels as a function, and
|
|
54
|
+
* returns its path.
|
|
55
|
+
*/
|
|
56
|
+
export const writeServerShim = async ({ entryPath, packageRoot }) => {
|
|
57
|
+
const shimDir = join(packageRoot, SERVER_SHIM_DIR);
|
|
58
|
+
await mkdir(shimDir, { recursive: true });
|
|
59
|
+
const shimPath = join(shimDir, `${SERVER_FUNCTION_NAME}.mjs`);
|
|
60
|
+
await writeFile(shimPath, getShimContents(entryPath));
|
|
61
|
+
return shimPath;
|
|
62
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type FunctionConfig, type
|
|
1
|
+
import { type BundleOptions, type FunctionConfig, type MixedPaths, type ServerOptions } from '@netlify/zip-it-and-ship-it';
|
|
2
2
|
import type { FeatureFlags } from '../../core/feature_flags.js';
|
|
3
3
|
type GetZisiParametersType = {
|
|
4
4
|
branch?: string;
|
|
@@ -11,9 +11,11 @@ type GetZisiParametersType = {
|
|
|
11
11
|
isRunningLocally: boolean;
|
|
12
12
|
repositoryRoot: string;
|
|
13
13
|
userNodeVersion: string;
|
|
14
|
-
systemLog:
|
|
14
|
+
systemLog: BundleOptions['systemLog'];
|
|
15
|
+
paths: MixedPaths;
|
|
16
|
+
server?: ServerOptions;
|
|
15
17
|
};
|
|
16
|
-
export declare const getZisiParameters: ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, userNodeVersion, systemLog, }: GetZisiParametersType) =>
|
|
18
|
+
export declare const getZisiParameters: ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, paths, repositoryRoot, server, userNodeVersion, systemLog, }: GetZisiParametersType) => BundleOptions;
|
|
17
19
|
export declare const normalizeFunctionConfig: ({ buildDir, functionConfig, isRunningLocally, nodeVersion, }: {
|
|
18
20
|
buildDir: string;
|
|
19
21
|
functionConfig: Record<string, any>;
|
|
@@ -16,7 +16,7 @@ const getLambdaNodeVersion = (childEnv, userNodeVersion) => {
|
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
19
|
-
export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, userNodeVersion, systemLog, }) => {
|
|
19
|
+
export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, paths, repositoryRoot, server, userNodeVersion, systemLog, }) => {
|
|
20
20
|
const nodeVersion = getLambdaNodeVersion(childEnv, userNodeVersion);
|
|
21
21
|
const manifest = join(functionsDist, 'manifest.json');
|
|
22
22
|
const config = Object.fromEntries(Object.entries(functionsConfig).map(([expression, object]) => [
|
|
@@ -30,11 +30,16 @@ export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, fu
|
|
|
30
30
|
return {
|
|
31
31
|
basePath: buildDir,
|
|
32
32
|
branch,
|
|
33
|
-
|
|
34
|
-
manifest,
|
|
33
|
+
destFolder: functionsDist,
|
|
35
34
|
featureFlags: zisiFeatureFlags,
|
|
35
|
+
functions: {
|
|
36
|
+
config,
|
|
37
|
+
configFileDirectories,
|
|
38
|
+
paths,
|
|
39
|
+
},
|
|
40
|
+
manifest,
|
|
36
41
|
repositoryRoot,
|
|
37
|
-
|
|
42
|
+
server,
|
|
38
43
|
systemLog,
|
|
39
44
|
};
|
|
40
45
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "37.1.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -68,12 +68,12 @@
|
|
|
68
68
|
"@netlify/cache-utils": "^7.1.2",
|
|
69
69
|
"@netlify/config": "^25.2.5",
|
|
70
70
|
"@netlify/edge-bundler": "16.0.4",
|
|
71
|
-
"@netlify/functions-utils": "^7.1.
|
|
71
|
+
"@netlify/functions-utils": "^7.1.11",
|
|
72
72
|
"@netlify/git-utils": "^7.1.1",
|
|
73
|
-
"@netlify/opentelemetry-utils": "^
|
|
73
|
+
"@netlify/opentelemetry-utils": "^4.0.0",
|
|
74
74
|
"@netlify/plugins-list": "^6.81.6",
|
|
75
75
|
"@netlify/run-utils": "^7.1.0",
|
|
76
|
-
"@netlify/zip-it-and-ship-it": "
|
|
76
|
+
"@netlify/zip-it-and-ship-it": "16.1.0",
|
|
77
77
|
"@sindresorhus/slugify": "^2.0.0",
|
|
78
78
|
"ansis": "^4.1.0",
|
|
79
79
|
"execa": "^8.0.0",
|
|
@@ -108,8 +108,8 @@
|
|
|
108
108
|
},
|
|
109
109
|
"devDependencies": {
|
|
110
110
|
"@netlify/nock-udp": "^6.1.0",
|
|
111
|
-
"@opentelemetry/api": "~1.
|
|
112
|
-
"@opentelemetry/sdk-trace-base": "~
|
|
111
|
+
"@opentelemetry/api": "~1.9.0",
|
|
112
|
+
"@opentelemetry/sdk-trace-base": "~2.8.0",
|
|
113
113
|
"@types/node": "^22.12.0",
|
|
114
114
|
"@vitest/coverage-v8": "^3.2.6",
|
|
115
115
|
"atob": "^2.1.2",
|
|
@@ -126,8 +126,8 @@
|
|
|
126
126
|
"yarn": "^1.22.22"
|
|
127
127
|
},
|
|
128
128
|
"peerDependencies": {
|
|
129
|
-
"@netlify/opentelemetry-sdk-setup": "^
|
|
130
|
-
"@opentelemetry/api": "~1.
|
|
129
|
+
"@netlify/opentelemetry-sdk-setup": "^3.0.0 || ^4.0.0",
|
|
130
|
+
"@opentelemetry/api": "~1.9.0"
|
|
131
131
|
},
|
|
132
132
|
"peerDependenciesMeta": {
|
|
133
133
|
"@netlify/opentelemetry-sdk-setup": {
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"engines": {
|
|
138
138
|
"node": ">=22.12.0"
|
|
139
139
|
},
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "22902a5992a5909a97bb366c88c96f6d95c18b33"
|
|
141
141
|
}
|