@netlify/zip-it-and-ship-it 12.0.2 → 12.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/dist/feature_flags.d.ts +2 -4
- package/dist/feature_flags.js +1 -3
- package/dist/main.d.ts +3 -0
- package/dist/main.js +2 -0
- package/dist/runtimes/node/utils/entry_file.d.ts +2 -4
- package/dist/runtimes/node/utils/entry_file.js +9 -13
- package/dist/runtimes/node/utils/zip.js +2 -5
- package/package.json +7 -7
package/dist/feature_flags.d.ts
CHANGED
|
@@ -5,10 +5,9 @@ export declare const defaultFlags: {
|
|
|
5
5
|
readonly zisi_pure_esm: false;
|
|
6
6
|
readonly zisi_pure_esm_mjs: false;
|
|
7
7
|
readonly zisi_output_cjs_extension: false;
|
|
8
|
-
readonly zisi_unique_entry_file: false;
|
|
9
8
|
readonly zisi_esbuild_fail_double_glob: false;
|
|
10
9
|
readonly zisi_add_instrumentation_loader: true;
|
|
11
|
-
readonly
|
|
10
|
+
readonly zisi_dynamic_import_function_handler_entry_point: false;
|
|
12
11
|
};
|
|
13
12
|
export type FeatureFlags = Partial<Record<keyof typeof defaultFlags, boolean>>;
|
|
14
13
|
export declare const getFlags: (input?: Record<string, boolean>, flags?: {
|
|
@@ -18,8 +17,7 @@ export declare const getFlags: (input?: Record<string, boolean>, flags?: {
|
|
|
18
17
|
readonly zisi_pure_esm: false;
|
|
19
18
|
readonly zisi_pure_esm_mjs: false;
|
|
20
19
|
readonly zisi_output_cjs_extension: false;
|
|
21
|
-
readonly zisi_unique_entry_file: false;
|
|
22
20
|
readonly zisi_esbuild_fail_double_glob: false;
|
|
23
21
|
readonly zisi_add_instrumentation_loader: true;
|
|
24
|
-
readonly
|
|
22
|
+
readonly zisi_dynamic_import_function_handler_entry_point: false;
|
|
25
23
|
}) => FeatureFlags;
|
package/dist/feature_flags.js
CHANGED
|
@@ -14,14 +14,12 @@ export const defaultFlags = {
|
|
|
14
14
|
zisi_pure_esm_mjs: false,
|
|
15
15
|
// Output CJS file extension.
|
|
16
16
|
zisi_output_cjs_extension: false,
|
|
17
|
-
// Create unique entry file instead of a file that is based on the function name.
|
|
18
|
-
zisi_unique_entry_file: false,
|
|
19
17
|
// If multiple glob stars are in includedFiles, fail the build instead of warning.
|
|
20
18
|
zisi_esbuild_fail_double_glob: false,
|
|
21
19
|
// Adds the `___netlify-telemetry.mjs` file to the function bundle.
|
|
22
20
|
zisi_add_instrumentation_loader: true,
|
|
23
21
|
// Dynamically import the function handler.
|
|
24
|
-
|
|
22
|
+
zisi_dynamic_import_function_handler_entry_point: false,
|
|
25
23
|
};
|
|
26
24
|
// List of supported flags and their default value.
|
|
27
25
|
export const getFlags = (input = {}, flags = defaultFlags) => Object.entries(flags).reduce((result, [key, defaultValue]) => ({
|
package/dist/main.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Config } from './config.js';
|
|
|
2
2
|
import { FeatureFlags } from './feature_flags.js';
|
|
3
3
|
import { ModuleFormat } from './runtimes/node/utils/module_format.js';
|
|
4
4
|
import { RuntimeName } from './runtimes/runtime.js';
|
|
5
|
+
import type { ExtendedRoute, Route } from './utils/routes.js';
|
|
5
6
|
export { Config, FunctionConfig } from './config.js';
|
|
6
7
|
export { zipFunction, zipFunctions, ZipFunctionOptions, ZipFunctionsOptions } from './zip.js';
|
|
7
8
|
export { ArchiveFormat, ARCHIVE_FORMAT } from './archive.js';
|
|
@@ -23,6 +24,8 @@ export interface ListedFunction {
|
|
|
23
24
|
generator?: string;
|
|
24
25
|
timeout?: number;
|
|
25
26
|
inputModuleFormat?: ModuleFormat;
|
|
27
|
+
excludedRoutes?: Route[];
|
|
28
|
+
routes?: ExtendedRoute[];
|
|
26
29
|
}
|
|
27
30
|
type ListedFunctionFile = ListedFunction & {
|
|
28
31
|
srcFile: string;
|
package/dist/main.js
CHANGED
|
@@ -61,10 +61,12 @@ const getListedFunction = function ({ config, extension, staticAnalysisResult, m
|
|
|
61
61
|
return {
|
|
62
62
|
displayName: config.name,
|
|
63
63
|
extension,
|
|
64
|
+
excludedRoutes: staticAnalysisResult?.excludedRoutes,
|
|
64
65
|
generator: config.generator,
|
|
65
66
|
timeout: config.timeout,
|
|
66
67
|
mainFile,
|
|
67
68
|
name,
|
|
69
|
+
routes: staticAnalysisResult?.routes,
|
|
68
70
|
runtime: runtime.name,
|
|
69
71
|
runtimeAPIVersion: staticAnalysisResult ? (staticAnalysisResult?.runtimeAPIVersion ?? 1) : undefined,
|
|
70
72
|
schedule: staticAnalysisResult?.config?.schedule ?? config.schedule,
|
|
@@ -15,16 +15,14 @@ export interface EntryFile {
|
|
|
15
15
|
* As DataDog has a special handling for the service name, we need to make sure it is kebab-case.
|
|
16
16
|
*/
|
|
17
17
|
export declare const kebabCase: (input: string) => string;
|
|
18
|
-
export declare const isNamedLikeEntryFile: (file: string, { basePath,
|
|
18
|
+
export declare const isNamedLikeEntryFile: (file: string, { basePath, filename, runtimeAPIVersion, }: {
|
|
19
19
|
basePath: string;
|
|
20
|
-
featureFlags: FeatureFlags;
|
|
21
20
|
filename: string;
|
|
22
21
|
runtimeAPIVersion: number;
|
|
23
22
|
}) => boolean;
|
|
24
|
-
export declare const conflictsWithEntryFile: (srcFiles: string[], { basePath, extension,
|
|
23
|
+
export declare const conflictsWithEntryFile: (srcFiles: string[], { basePath, extension, filename, mainFile, runtimeAPIVersion, }: {
|
|
25
24
|
basePath: string;
|
|
26
25
|
extension: string;
|
|
27
|
-
featureFlags: FeatureFlags;
|
|
28
26
|
filename: string;
|
|
29
27
|
mainFile: string;
|
|
30
28
|
runtimeAPIVersion: number;
|
|
@@ -26,7 +26,7 @@ export const kebabCase = (input) => input
|
|
|
26
26
|
const getEntryFileContents = (mainPath, moduleFormat, featureFlags, runtimeAPIVersion) => {
|
|
27
27
|
const importPath = `.${mainPath.startsWith('/') ? mainPath : `/${mainPath}`}`;
|
|
28
28
|
if (runtimeAPIVersion === 2) {
|
|
29
|
-
if (featureFlags.
|
|
29
|
+
if (featureFlags.zisi_dynamic_import_function_handler_entry_point) {
|
|
30
30
|
return [
|
|
31
31
|
`import * as bootstrap from './${BOOTSTRAP_FILE_NAME}'`,
|
|
32
32
|
`export const handler = bootstrap.getLambdaHandler('${importPath}')`,
|
|
@@ -40,10 +40,6 @@ const getEntryFileContents = (mainPath, moduleFormat, featureFlags, runtimeAPIVe
|
|
|
40
40
|
`export const handler = bootstrap.getLambdaHandler(funcModule)`,
|
|
41
41
|
].join(';');
|
|
42
42
|
}
|
|
43
|
-
if (featureFlags.zisi_unique_entry_file) {
|
|
44
|
-
// we use dynamic import because we do not know if the user code is cjs or esm
|
|
45
|
-
return [`const { handler } = await import('${importPath}')`, 'export { handler }'].join(';');
|
|
46
|
-
}
|
|
47
43
|
if (moduleFormat === MODULE_FORMAT.COMMONJS) {
|
|
48
44
|
return `module.exports = require('${importPath}')`;
|
|
49
45
|
}
|
|
@@ -56,13 +52,13 @@ const POSSIBLE_LAMBDA_ENTRY_EXTENSIONS = [
|
|
|
56
52
|
MODULE_FILE_EXTENSION.CJS,
|
|
57
53
|
];
|
|
58
54
|
// checks if the file is considered a entry-file in AWS Lambda
|
|
59
|
-
export const isNamedLikeEntryFile = (file, { basePath,
|
|
60
|
-
const entryFilename = getEntryFileName({ extension,
|
|
55
|
+
export const isNamedLikeEntryFile = (file, { basePath, filename, runtimeAPIVersion, }) => POSSIBLE_LAMBDA_ENTRY_EXTENSIONS.some((extension) => {
|
|
56
|
+
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion });
|
|
61
57
|
const entryFilePath = resolve(basePath, entryFilename);
|
|
62
58
|
return entryFilePath === file;
|
|
63
59
|
});
|
|
64
60
|
// Check if any src file (except the mainFile) is considered an entry file for AWS Lambda
|
|
65
|
-
export const conflictsWithEntryFile = (srcFiles, { basePath, extension,
|
|
61
|
+
export const conflictsWithEntryFile = (srcFiles, { basePath, extension, filename, mainFile, runtimeAPIVersion, }) => {
|
|
66
62
|
let hasConflict = false;
|
|
67
63
|
srcFiles.forEach((srcFile) => {
|
|
68
64
|
if (srcFile.includes(ENTRY_FILE_NAME)) {
|
|
@@ -73,11 +69,11 @@ export const conflictsWithEntryFile = (srcFiles, { basePath, extension, featureF
|
|
|
73
69
|
}
|
|
74
70
|
// If we're generating a unique entry file, we know we don't have a conflict
|
|
75
71
|
// at this point.
|
|
76
|
-
if (
|
|
72
|
+
if (runtimeAPIVersion === 2) {
|
|
77
73
|
return;
|
|
78
74
|
}
|
|
79
75
|
if (!hasConflict &&
|
|
80
|
-
isNamedLikeEntryFile(srcFile, { basePath,
|
|
76
|
+
isNamedLikeEntryFile(srcFile, { basePath, filename, runtimeAPIVersion }) &&
|
|
81
77
|
srcFile !== mainFile) {
|
|
82
78
|
hasConflict = true;
|
|
83
79
|
}
|
|
@@ -87,8 +83,8 @@ export const conflictsWithEntryFile = (srcFiles, { basePath, extension, featureF
|
|
|
87
83
|
// Returns the name for the AWS Lambda entry file
|
|
88
84
|
// We do set the handler in AWS Lambda to `<func-name>.handler` and because of
|
|
89
85
|
// this it considers `<func-name>.(c|m)?js` as possible entry-points
|
|
90
|
-
const getEntryFileName = ({ extension,
|
|
91
|
-
if (
|
|
86
|
+
const getEntryFileName = ({ extension, filename, runtimeAPIVersion, }) => {
|
|
87
|
+
if (runtimeAPIVersion === 2) {
|
|
92
88
|
return `${ENTRY_FILE_NAME}.mjs`;
|
|
93
89
|
}
|
|
94
90
|
return `${basename(filename, extname(filename))}${extension}`;
|
|
@@ -127,7 +123,7 @@ ${readFileSync(filePath, 'utf8')}
|
|
|
127
123
|
export const getEntryFile = ({ commonPrefix, featureFlags, filename, mainFile, moduleFormat, userNamespace, runtimeAPIVersion, }) => {
|
|
128
124
|
const mainPath = normalizeFilePath({ commonPrefix, path: mainFile, userNamespace });
|
|
129
125
|
const extension = getFileExtensionForFormat(moduleFormat, featureFlags, runtimeAPIVersion);
|
|
130
|
-
const entryFilename = getEntryFileName({ extension,
|
|
126
|
+
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion });
|
|
131
127
|
const contents = getEntryFileContents(mainPath, moduleFormat, featureFlags, runtimeAPIVersion);
|
|
132
128
|
return {
|
|
133
129
|
contents,
|
|
@@ -32,7 +32,6 @@ const createDirectory = async function ({ aliases = new Map(), basePath, cache,
|
|
|
32
32
|
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
|
|
33
33
|
basePath,
|
|
34
34
|
extension,
|
|
35
|
-
featureFlags,
|
|
36
35
|
filename,
|
|
37
36
|
mainFile,
|
|
38
37
|
runtimeAPIVersion,
|
|
@@ -109,17 +108,15 @@ const createZipArchive = async function ({ aliases = new Map(), basePath, branch
|
|
|
109
108
|
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
|
|
110
109
|
basePath,
|
|
111
110
|
extension,
|
|
112
|
-
featureFlags,
|
|
113
111
|
filename,
|
|
114
112
|
mainFile,
|
|
115
113
|
runtimeAPIVersion,
|
|
116
114
|
});
|
|
117
115
|
// We don't need an entry file if it would end up with the same path as the
|
|
118
116
|
// function's main file. Unless we have a file conflict and need to move everything into a subfolder
|
|
119
|
-
const needsEntryFile =
|
|
120
|
-
runtimeAPIVersion === 2 ||
|
|
117
|
+
const needsEntryFile = runtimeAPIVersion === 2 ||
|
|
121
118
|
hasEntryFileConflict ||
|
|
122
|
-
!isNamedLikeEntryFile(mainFile, { basePath,
|
|
119
|
+
!isNamedLikeEntryFile(mainFile, { basePath, filename, runtimeAPIVersion });
|
|
123
120
|
// If there is a naming conflict, we move all user files (everything other
|
|
124
121
|
// than the entry file) to its own sub-directory.
|
|
125
122
|
const userNamespace = hasEntryFileConflict ? DEFAULT_USER_SUBDIRECTORY : '';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/zip-it-and-ship-it",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Zip it and ship it",
|
|
5
5
|
"main": "./dist/main.js",
|
|
6
6
|
"type": "module",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@babel/types": "7.27.1",
|
|
46
46
|
"@netlify/binary-info": "^1.0.0",
|
|
47
47
|
"@netlify/serverless-functions-api": "^1.41.2",
|
|
48
|
-
"@vercel/nft": "0.
|
|
48
|
+
"@vercel/nft": "0.29.3",
|
|
49
49
|
"archiver": "^7.0.0",
|
|
50
50
|
"common-path-prefix": "^3.0.0",
|
|
51
51
|
"copy-file": "^11.0.0",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"esbuild": "0.25.4",
|
|
54
54
|
"execa": "^8.0.0",
|
|
55
55
|
"fast-glob": "^3.3.2",
|
|
56
|
-
"filter-obj": "^
|
|
56
|
+
"filter-obj": "^6.0.0",
|
|
57
57
|
"find-up": "^7.0.0",
|
|
58
58
|
"glob": "^8.0.3",
|
|
59
59
|
"is-builtin-module": "^3.1.0",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"normalize-path": "^3.0.0",
|
|
66
66
|
"p-map": "^7.0.0",
|
|
67
67
|
"path-exists": "^5.0.0",
|
|
68
|
-
"precinct": "^
|
|
68
|
+
"precinct": "^12.0.0",
|
|
69
69
|
"require-package-name": "^2.0.1",
|
|
70
70
|
"resolve": "^2.0.0-next.1",
|
|
71
71
|
"semver": "^7.3.8",
|
|
@@ -83,7 +83,7 @@
|
|
|
83
83
|
"@types/node": "20.12.11",
|
|
84
84
|
"@types/normalize-path": "3.0.2",
|
|
85
85
|
"@types/resolve": "1.20.6",
|
|
86
|
-
"@types/semver": "7.
|
|
86
|
+
"@types/semver": "7.7.0",
|
|
87
87
|
"@types/unixify": "1.0.2",
|
|
88
88
|
"@types/yargs": "17.0.33",
|
|
89
89
|
"@vitest/coverage-v8": "0.34.6",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"cpy": "11.1.0",
|
|
93
93
|
"decompress": "4.2.1",
|
|
94
94
|
"deepmerge": "^4.3.1",
|
|
95
|
-
"get-stream": "
|
|
95
|
+
"get-stream": "9.0.1",
|
|
96
96
|
"is-ci": "4.1.0",
|
|
97
97
|
"lambda-local": "2.2.0",
|
|
98
98
|
"source-map-support": "0.5.21",
|
|
@@ -102,5 +102,5 @@
|
|
|
102
102
|
"engines": {
|
|
103
103
|
"node": ">=18.14.0"
|
|
104
104
|
},
|
|
105
|
-
"gitHead": "
|
|
105
|
+
"gitHead": "8eb0a2d3736eb5b24304fac146ae57ca6ef48a79"
|
|
106
106
|
}
|