@netlify/zip-it-and-ship-it 5.7.3 → 5.7.4
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/bin.js +2 -2
- package/dist/config.d.ts +3 -3
- package/dist/function.d.ts +2 -2
- package/dist/main.d.ts +4 -4
- package/dist/main.js +18 -18
- package/dist/manifest.d.ts +1 -1
- package/dist/runtimes/detect_runtime.d.ts +2 -2
- package/dist/runtimes/detect_runtime.js +2 -2
- package/dist/runtimes/go/builder.js +2 -2
- package/dist/runtimes/go/index.d.ts +1 -1
- package/dist/runtimes/go/index.js +13 -13
- package/dist/runtimes/index.d.ts +3 -3
- package/dist/runtimes/index.js +10 -10
- package/dist/runtimes/node/bundlers/esbuild/bundler.d.ts +1 -1
- package/dist/runtimes/node/bundlers/esbuild/bundler.js +11 -11
- package/dist/runtimes/node/bundlers/esbuild/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/esbuild/index.js +13 -13
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.d.ts +1 -1
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/special_cases.js +2 -2
- package/dist/runtimes/node/bundlers/esbuild/src_files.d.ts +1 -1
- package/dist/runtimes/node/bundlers/esbuild/src_files.js +10 -10
- package/dist/runtimes/node/bundlers/index.d.ts +4 -4
- package/dist/runtimes/node/bundlers/index.js +8 -8
- package/dist/runtimes/node/bundlers/nft/es_modules.d.ts +4 -4
- package/dist/runtimes/node/bundlers/nft/es_modules.js +8 -8
- package/dist/runtimes/node/bundlers/nft/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/nft/index.js +14 -14
- package/dist/runtimes/node/bundlers/nft/transpile.d.ts +1 -1
- package/dist/runtimes/node/bundlers/nft/transpile.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.d.ts +2 -2
- package/dist/runtimes/node/bundlers/zisi/index.js +5 -5
- package/dist/runtimes/node/bundlers/zisi/list_imports.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/nested.d.ts +1 -1
- package/dist/runtimes/node/bundlers/zisi/side_files.js +2 -2
- package/dist/runtimes/node/bundlers/zisi/src_files.d.ts +1 -1
- package/dist/runtimes/node/bundlers/zisi/src_files.js +19 -19
- package/dist/runtimes/node/bundlers/zisi/traverse.d.ts +2 -2
- package/dist/runtimes/node/bundlers/zisi/traverse.js +12 -12
- package/dist/runtimes/node/bundlers/zisi/tree_shake.js +2 -2
- package/dist/runtimes/node/finder.d.ts +1 -1
- package/dist/runtimes/node/finder.js +2 -2
- package/dist/runtimes/node/in_source_config/index.d.ts +1 -1
- package/dist/runtimes/node/in_source_config/index.js +10 -10
- package/dist/runtimes/node/in_source_config/properties/schedule.d.ts +1 -1
- package/dist/runtimes/node/index.d.ts +2 -2
- package/dist/runtimes/node/index.js +16 -16
- package/dist/runtimes/node/parser/exports.d.ts +1 -1
- package/dist/runtimes/node/parser/exports.js +2 -2
- package/dist/runtimes/node/parser/imports.js +6 -6
- package/dist/runtimes/node/parser/index.js +2 -2
- package/dist/runtimes/node/utils/detect_native_module.d.ts +1 -1
- package/dist/runtimes/node/utils/entry_file.d.ts +1 -1
- package/dist/runtimes/node/utils/entry_file.js +2 -2
- package/dist/runtimes/node/utils/zip.d.ts +1 -1
- package/dist/runtimes/node/utils/zip.js +14 -14
- package/dist/runtimes/runtime.d.ts +7 -7
- package/dist/runtimes/rust/builder.d.ts +1 -1
- package/dist/runtimes/rust/builder.js +8 -8
- package/dist/runtimes/rust/index.d.ts +1 -1
- package/dist/runtimes/rust/index.js +17 -17
- package/dist/utils/archive_size.d.ts +1 -1
- package/dist/utils/format_result.d.ts +2 -2
- package/dist/utils/format_result.js +2 -2
- package/dist/utils/fs.js +2 -2
- package/dist/zip.d.ts +6 -6
- package/dist/zip.js +18 -18
- package/dist/zip_binary.d.ts +1 -1
- package/dist/zip_binary.js +5 -5
- package/package.json +1 -1
package/dist/bin.js
CHANGED
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
7
7
|
const process_1 = require("process");
|
|
8
8
|
const yargs_1 = __importDefault(require("yargs"));
|
|
9
9
|
const helpers_1 = require("yargs/helpers");
|
|
10
|
-
const
|
|
10
|
+
const main_js_1 = require("./main.js");
|
|
11
11
|
// CLI entry point
|
|
12
12
|
const runCli = async function () {
|
|
13
13
|
// @ts-expect-error TODO: `destFolder` and `srcFolder` are not being passed
|
|
@@ -15,7 +15,7 @@ const runCli = async function () {
|
|
|
15
15
|
const { destFolder, srcFolder, ...options } = parseArgs();
|
|
16
16
|
try {
|
|
17
17
|
// @ts-expect-error TODO: `options` is not getting the right types.
|
|
18
|
-
const zipped = await (0,
|
|
18
|
+
const zipped = await (0, main_js_1.zipFunctions)(srcFolder, destFolder, options);
|
|
19
19
|
console.log(JSON.stringify(zipped, null, 2));
|
|
20
20
|
}
|
|
21
21
|
catch (error) {
|
package/dist/config.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FunctionSource } from './function';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
1
|
+
import { FunctionSource } from './function.js';
|
|
2
|
+
import type { NodeBundlerName } from './runtimes/node/bundlers/index.js';
|
|
3
|
+
import type { NodeVersionString } from './runtimes/node/index.js';
|
|
4
4
|
export interface FunctionConfig {
|
|
5
5
|
externalNodeModules?: string[];
|
|
6
6
|
includedFiles?: string[];
|
package/dist/function.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Stats } from 'fs';
|
|
3
|
-
import type { FunctionConfig } from './config';
|
|
4
|
-
import type { Runtime, ZipFunctionResult } from './runtimes/runtime';
|
|
3
|
+
import type { FunctionConfig } from './config.js';
|
|
4
|
+
import type { Runtime, ZipFunctionResult } from './runtimes/runtime.js';
|
|
5
5
|
export declare type FunctionArchive = ZipFunctionResult & {
|
|
6
6
|
mainFile: string;
|
|
7
7
|
name: string;
|
package/dist/main.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Config } from './config';
|
|
2
|
-
import { FeatureFlags } from './feature_flags';
|
|
3
|
-
import { RuntimeName } from './runtimes/runtime';
|
|
4
|
-
export { zipFunction, zipFunctions } from './zip';
|
|
1
|
+
import { Config } from './config.js';
|
|
2
|
+
import { FeatureFlags } from './feature_flags.js';
|
|
3
|
+
import { RuntimeName } from './runtimes/runtime.js';
|
|
4
|
+
export { zipFunction, zipFunctions } from './zip.js';
|
|
5
5
|
interface ListedFunction {
|
|
6
6
|
name: string;
|
|
7
7
|
mainFile: string;
|
package/dist/main.js
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listFunctionsFiles = exports.listFunction = exports.listFunctions = exports.zipFunctions = exports.zipFunction = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
var
|
|
10
|
-
Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return
|
|
11
|
-
Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return
|
|
5
|
+
const feature_flags_js_1 = require("./feature_flags.js");
|
|
6
|
+
const index_js_1 = require("./runtimes/index.js");
|
|
7
|
+
const index_js_2 = require("./runtimes/node/in_source_config/index.js");
|
|
8
|
+
const fs_js_1 = require("./utils/fs.js");
|
|
9
|
+
var zip_js_1 = require("./zip.js");
|
|
10
|
+
Object.defineProperty(exports, "zipFunction", { enumerable: true, get: function () { return zip_js_1.zipFunction; } });
|
|
11
|
+
Object.defineProperty(exports, "zipFunctions", { enumerable: true, get: function () { return zip_js_1.zipFunctions; } });
|
|
12
12
|
const augmentWithISC = async (func) => {
|
|
13
13
|
// ISC is currently only supported in JavaScript and TypeScript functions.
|
|
14
14
|
if (func.runtime.name !== 'js') {
|
|
15
15
|
return func;
|
|
16
16
|
}
|
|
17
|
-
const inSourceConfig = await (0,
|
|
17
|
+
const inSourceConfig = await (0, index_js_2.findISCDeclarationsInPath)(func.mainFile);
|
|
18
18
|
return { ...func, inSourceConfig };
|
|
19
19
|
};
|
|
20
20
|
// List all Netlify Functions main entry files for a specific directory
|
|
21
21
|
const listFunctions = async function (relativeSrcFolders, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
22
|
-
const featureFlags = (0,
|
|
23
|
-
const srcFolders = (0,
|
|
24
|
-
const paths = await (0,
|
|
25
|
-
const functionsMap = await (0,
|
|
22
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
23
|
+
const srcFolders = (0, fs_js_1.resolveFunctionsDirectories)(relativeSrcFolders);
|
|
24
|
+
const paths = await (0, fs_js_1.listFunctionsDirectories)(srcFolders);
|
|
25
|
+
const functionsMap = await (0, index_js_1.getFunctionsFromPaths)(paths, { featureFlags, config });
|
|
26
26
|
const functions = [...functionsMap.values()];
|
|
27
27
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
28
28
|
return augmentedFunctions.map(getListedFunction);
|
|
@@ -30,8 +30,8 @@ const listFunctions = async function (relativeSrcFolders, { featureFlags: inputF
|
|
|
30
30
|
exports.listFunctions = listFunctions;
|
|
31
31
|
// Finds a function at a specific path.
|
|
32
32
|
const listFunction = async function (path, { featureFlags: inputFeatureFlags, config, parseISC = false, } = {}) {
|
|
33
|
-
const featureFlags = (0,
|
|
34
|
-
const func = await (0,
|
|
33
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
34
|
+
const func = await (0, index_js_1.getFunctionFromPath)(path, { featureFlags, config });
|
|
35
35
|
if (!func) {
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
@@ -41,10 +41,10 @@ const listFunction = async function (path, { featureFlags: inputFeatureFlags, co
|
|
|
41
41
|
exports.listFunction = listFunction;
|
|
42
42
|
// List all Netlify Functions files for a specific directory
|
|
43
43
|
const listFunctionsFiles = async function (relativeSrcFolders, { basePath, config, featureFlags: inputFeatureFlags, parseISC = false } = {}) {
|
|
44
|
-
const featureFlags = (0,
|
|
45
|
-
const srcFolders = (0,
|
|
46
|
-
const paths = await (0,
|
|
47
|
-
const functionsMap = await (0,
|
|
44
|
+
const featureFlags = (0, feature_flags_js_1.getFlags)(inputFeatureFlags);
|
|
45
|
+
const srcFolders = (0, fs_js_1.resolveFunctionsDirectories)(relativeSrcFolders);
|
|
46
|
+
const paths = await (0, fs_js_1.listFunctionsDirectories)(srcFolders);
|
|
47
|
+
const functionsMap = await (0, index_js_1.getFunctionsFromPaths)(paths, { config, featureFlags });
|
|
48
48
|
const functions = [...functionsMap.values()];
|
|
49
49
|
const augmentedFunctions = parseISC ? await Promise.all(functions.map(augmentWithISC)) : functions;
|
|
50
50
|
const listedFunctionsFiles = await Promise.all(augmentedFunctions.map((func) => getListedFunctionFiles(func, { basePath, featureFlags })));
|
package/dist/manifest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FsCache } from '../utils/fs';
|
|
2
|
-
import type { RuntimeName } from './runtime';
|
|
1
|
+
import { FsCache } from '../utils/fs.js';
|
|
2
|
+
import type { RuntimeName } from './runtime.js';
|
|
3
3
|
export declare const detectBinaryRuntime: ({ fsCache, path, }: {
|
|
4
4
|
fsCache: FsCache;
|
|
5
5
|
path: string;
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.detectBinaryRuntime = void 0;
|
|
4
4
|
const elf_cam_1 = require("elf-cam");
|
|
5
|
-
const
|
|
5
|
+
const fs_js_1 = require("../utils/fs.js");
|
|
6
6
|
// Try to guess the runtime by inspecting the binary file.
|
|
7
7
|
const detectBinaryRuntime = async function ({ fsCache, path, }) {
|
|
8
8
|
try {
|
|
9
|
-
const buffer = await (0,
|
|
9
|
+
const buffer = await (0, fs_js_1.cachedReadFile)(fsCache, path);
|
|
10
10
|
// We're using the Type Assertion because the `cachedReadFile` abstraction
|
|
11
11
|
// loses part of the return type information. We can safely say it's a
|
|
12
12
|
// Buffer in this case because we're not specifying an encoding.
|
|
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.build = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
6
|
+
const shell_js_1 = require("../../utils/shell.js");
|
|
7
7
|
const build = async ({ destPath, mainFile, srcDir }) => {
|
|
8
8
|
const functionName = (0, path_1.basename)(srcDir);
|
|
9
9
|
try {
|
|
10
|
-
await
|
|
10
|
+
await shell_js_1.shellUtils.runCommand('go', ['build', '-o', destPath, '-ldflags', '-s -w'], {
|
|
11
11
|
cwd: srcDir,
|
|
12
12
|
env: {
|
|
13
13
|
CGO_ENABLED: '0',
|
|
@@ -5,20 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = require("path");
|
|
7
7
|
const cp_file_1 = __importDefault(require("cp-file"));
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const fs_js_1 = require("../../utils/fs.js");
|
|
9
|
+
const non_nullable_js_1 = require("../../utils/non_nullable.js");
|
|
10
|
+
const zip_binary_js_1 = require("../../zip_binary.js");
|
|
11
|
+
const detect_runtime_js_1 = require("../detect_runtime.js");
|
|
12
|
+
const builder_js_1 = require("./builder.js");
|
|
13
13
|
const detectGoFunction = async ({ fsCache, path }) => {
|
|
14
|
-
const stat = await (0,
|
|
14
|
+
const stat = await (0, fs_js_1.cachedLstat)(fsCache, path);
|
|
15
15
|
if (!stat.isDirectory()) {
|
|
16
16
|
return;
|
|
17
17
|
}
|
|
18
18
|
const directoryName = (0, path_1.basename)(path);
|
|
19
19
|
// @ts-expect-error TODO: The `makeCachedFunction` abstraction is causing the
|
|
20
20
|
// return value of `readdir` to be incorrectly typed.
|
|
21
|
-
const files = (await (0,
|
|
21
|
+
const files = (await (0, fs_js_1.cachedReaddir)(fsCache, path));
|
|
22
22
|
const mainFileName = [`${directoryName}.go`, 'main.go'].find((name) => files.includes(name));
|
|
23
23
|
if (mainFileName === undefined) {
|
|
24
24
|
return;
|
|
@@ -27,10 +27,10 @@ const detectGoFunction = async ({ fsCache, path }) => {
|
|
|
27
27
|
};
|
|
28
28
|
const findFunctionsInPaths = async function ({ featureFlags, fsCache, paths }) {
|
|
29
29
|
const functions = await Promise.all(paths.map((path) => findFunctionInPath({ featureFlags, fsCache, path })));
|
|
30
|
-
return functions.filter(
|
|
30
|
+
return functions.filter(non_nullable_js_1.nonNullable);
|
|
31
31
|
};
|
|
32
32
|
const findFunctionInPath = async function ({ featureFlags, fsCache, path }) {
|
|
33
|
-
const runtime = await (0,
|
|
33
|
+
const runtime = await (0, detect_runtime_js_1.detectBinaryRuntime)({ fsCache, path });
|
|
34
34
|
if (runtime === 'go') {
|
|
35
35
|
return processBinary({ fsCache, path });
|
|
36
36
|
}
|
|
@@ -43,7 +43,7 @@ const findFunctionInPath = async function ({ featureFlags, fsCache, path }) {
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const processBinary = async ({ fsCache, path }) => {
|
|
46
|
-
const stat = (await (0,
|
|
46
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
47
47
|
const extension = (0, path_1.extname)(path);
|
|
48
48
|
const filename = (0, path_1.basename)(path);
|
|
49
49
|
const name = (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
@@ -62,7 +62,7 @@ const processSource = async ({ fsCache, mainFile, path, }) => {
|
|
|
62
62
|
// the `FunctionSource` interface. We should revisit whether `stat` should be
|
|
63
63
|
// part of that interface in the first place, or whether we could compute it
|
|
64
64
|
// downstream when needed (maybe using the FS cache as an optimisation).
|
|
65
|
-
const stat = (await (0,
|
|
65
|
+
const stat = (await (0, fs_js_1.cachedLstat)(fsCache, path));
|
|
66
66
|
const filename = (0, path_1.basename)(path);
|
|
67
67
|
const extension = (0, path_1.extname)(mainFile);
|
|
68
68
|
const name = (0, path_1.basename)(path, (0, path_1.extname)(path));
|
|
@@ -86,7 +86,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
|
|
|
86
86
|
// If we're building a Go function from source, we call the build method and
|
|
87
87
|
// update `binary` to point to the newly-created binary.
|
|
88
88
|
if (isSource) {
|
|
89
|
-
const { stat: binaryStat } = await (0,
|
|
89
|
+
const { stat: binaryStat } = await (0, builder_js_1.build)({ destPath, mainFile, srcDir });
|
|
90
90
|
binary = {
|
|
91
91
|
path: destPath,
|
|
92
92
|
stat: binaryStat,
|
|
@@ -101,7 +101,7 @@ const zipFunction = async function ({ config, destFolder, filename, mainFile, sr
|
|
|
101
101
|
filename: (0, path_1.basename)(destPath),
|
|
102
102
|
runtime,
|
|
103
103
|
};
|
|
104
|
-
await (0,
|
|
104
|
+
await (0, zip_binary_js_1.zipBinary)({ ...zipOptions, srcPath: binary.path, stat: binary.stat });
|
|
105
105
|
return { config, path: zipPath };
|
|
106
106
|
}
|
|
107
107
|
// We don't need to zip the binary, so we can just copy it to the right path.
|
package/dist/runtimes/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Config } from '../config';
|
|
2
|
-
import { FeatureFlags } from '../feature_flags';
|
|
3
|
-
import { FunctionSource } from '../function';
|
|
1
|
+
import { Config } from '../config.js';
|
|
2
|
+
import { FeatureFlags } from '../feature_flags.js';
|
|
3
|
+
import { FunctionSource } from '../function.js';
|
|
4
4
|
declare type FunctionMap = Map<string, FunctionSource>;
|
|
5
5
|
/**
|
|
6
6
|
* Gets a list of functions found in a list of paths.
|
package/dist/runtimes/index.js
CHANGED
|
@@ -5,11 +5,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getFunctionFromPath = exports.getFunctionsFromPaths = void 0;
|
|
7
7
|
const path_1 = require("path");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
const
|
|
8
|
+
const config_js_1 = require("../config.js");
|
|
9
|
+
const feature_flags_js_1 = require("../feature_flags.js");
|
|
10
|
+
const index_js_1 = __importDefault(require("./go/index.js"));
|
|
11
|
+
const index_js_2 = __importDefault(require("./node/index.js"));
|
|
12
|
+
const index_js_3 = __importDefault(require("./rust/index.js"));
|
|
13
13
|
/**
|
|
14
14
|
* Finds functions for a list of paths using a specific runtime. The return
|
|
15
15
|
* value is an object containing an array of the functions found (`functions`)
|
|
@@ -43,11 +43,11 @@ const makeFsCache = () => ({});
|
|
|
43
43
|
// The order of this array determines the priority of the runtimes. If a path
|
|
44
44
|
// is used by the first time, it won't be made available to the subsequent
|
|
45
45
|
// runtimes.
|
|
46
|
-
const RUNTIMES = [
|
|
46
|
+
const RUNTIMES = [index_js_2.default, index_js_1.default, index_js_3.default];
|
|
47
47
|
/**
|
|
48
48
|
* Gets a list of functions found in a list of paths.
|
|
49
49
|
*/
|
|
50
|
-
const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFlags =
|
|
50
|
+
const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFlags = feature_flags_js_1.defaultFlags, } = {}) => {
|
|
51
51
|
const fsCache = makeFsCache();
|
|
52
52
|
// We cycle through the ordered array of runtimes, passing each one of them
|
|
53
53
|
// through `findFunctionsInRuntime`. For each iteration, we collect all the
|
|
@@ -69,7 +69,7 @@ const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFla
|
|
|
69
69
|
}, Promise.resolve({ functions: [], remainingPaths: paths }));
|
|
70
70
|
const functionsWithConfig = functions.map(([name, func]) => [
|
|
71
71
|
name,
|
|
72
|
-
{ ...func, config: (0,
|
|
72
|
+
{ ...func, config: (0, config_js_1.getConfigForFunction)({ config, func }) },
|
|
73
73
|
]);
|
|
74
74
|
return new Map(functionsWithConfig);
|
|
75
75
|
};
|
|
@@ -77,7 +77,7 @@ exports.getFunctionsFromPaths = getFunctionsFromPaths;
|
|
|
77
77
|
/**
|
|
78
78
|
* Gets a list of functions found in a list of paths.
|
|
79
79
|
*/
|
|
80
|
-
const getFunctionFromPath = async (path, { config, featureFlags =
|
|
80
|
+
const getFunctionFromPath = async (path, { config, featureFlags = feature_flags_js_1.defaultFlags } = {}) => {
|
|
81
81
|
const fsCache = makeFsCache();
|
|
82
82
|
for (const runtime of RUNTIMES) {
|
|
83
83
|
const func = await runtime.findFunctionInPath({ path, fsCache, featureFlags });
|
|
@@ -85,7 +85,7 @@ const getFunctionFromPath = async (path, { config, featureFlags = feature_flags_
|
|
|
85
85
|
return {
|
|
86
86
|
...func,
|
|
87
87
|
runtime,
|
|
88
|
-
config: (0,
|
|
88
|
+
config: (0, config_js_1.getConfigForFunction)({ config, func: { ...func, runtime } }),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FunctionConfig } from '../../../../config';
|
|
1
|
+
import type { FunctionConfig } from '../../../../config.js';
|
|
2
2
|
export declare const ESBUILD_LOG_LIMIT = 10;
|
|
3
3
|
export declare const bundleJsFile: ({ additionalModulePaths, basePath, config, externalModules, ignoredModules, name, srcDir, srcFile, }: {
|
|
4
4
|
additionalModulePaths?: string[] | undefined;
|
|
@@ -4,11 +4,11 @@ exports.bundleJsFile = exports.ESBUILD_LOG_LIMIT = void 0;
|
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const esbuild_1 = require("@netlify/esbuild");
|
|
6
6
|
const tmp_promise_1 = require("tmp-promise");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
7
|
+
const fs_js_1 = require("../../../../utils/fs.js");
|
|
8
|
+
const bundler_target_js_1 = require("./bundler_target.js");
|
|
9
|
+
const plugin_dynamic_imports_js_1 = require("./plugin_dynamic_imports.js");
|
|
10
|
+
const plugin_native_modules_js_1 = require("./plugin_native_modules.js");
|
|
11
|
+
const plugin_node_builtin_js_1 = require("./plugin_node_builtin.js");
|
|
12
12
|
// Maximum number of log messages that an esbuild instance will produce. This
|
|
13
13
|
// limit is important to avoid out-of-memory errors due to too much data being
|
|
14
14
|
// sent in the Go<>Node IPC channel.
|
|
@@ -35,9 +35,9 @@ const bundleJsFile = async function ({ additionalModulePaths, basePath, config,
|
|
|
35
35
|
const dynamicImportsIncludedPaths = new Set();
|
|
36
36
|
// The list of esbuild plugins to enable for this build.
|
|
37
37
|
const plugins = [
|
|
38
|
-
(0,
|
|
39
|
-
(0,
|
|
40
|
-
(0,
|
|
38
|
+
(0, plugin_node_builtin_js_1.getNodeBuiltinPlugin)(),
|
|
39
|
+
(0, plugin_native_modules_js_1.getNativeModulesPlugin)(nativeNodeModules),
|
|
40
|
+
(0, plugin_dynamic_imports_js_1.getDynamicImportsPlugin)({
|
|
41
41
|
basePath,
|
|
42
42
|
includedPaths: dynamicImportsIncludedPaths,
|
|
43
43
|
moduleNames: nodeModulesWithDynamicImports,
|
|
@@ -47,7 +47,7 @@ const bundleJsFile = async function ({ additionalModulePaths, basePath, config,
|
|
|
47
47
|
];
|
|
48
48
|
// The version of ECMAScript to use as the build target. This will determine
|
|
49
49
|
// whether certain features are transpiled down or left untransformed.
|
|
50
|
-
const nodeTarget = (0,
|
|
50
|
+
const nodeTarget = (0, bundler_target_js_1.getBundlerTarget)(config.nodeVersion);
|
|
51
51
|
// esbuild will format `sources` relative to the sourcemap file, which lives
|
|
52
52
|
// in `destFolder`. We use `sourceRoot` to establish that relation. They are
|
|
53
53
|
// URLs, not paths, so even on Windows they should use forward slashes.
|
|
@@ -116,7 +116,7 @@ const getBundlePaths = ({ destFolder, outputs, srcFile, }) => {
|
|
|
116
116
|
const absolutePath = (0, path_1.join)(destFolder, filename);
|
|
117
117
|
if (output.entryPoint && (0, path_1.basename)(output.entryPoint) === (0, path_1.basename)(srcFile)) {
|
|
118
118
|
// Ensuring the main file has a `.js` extension.
|
|
119
|
-
const normalizedSrcFile = (0,
|
|
119
|
+
const normalizedSrcFile = (0, fs_js_1.getPathWithExtension)(srcFile, '.js');
|
|
120
120
|
bundlePaths.set(absolutePath, normalizedSrcFile);
|
|
121
121
|
}
|
|
122
122
|
else if (extension === '.js' || filename === `${bundleFilename}.map`) {
|
|
@@ -126,6 +126,6 @@ const getBundlePaths = ({ destFolder, outputs, srcFile, }) => {
|
|
|
126
126
|
return bundlePaths;
|
|
127
127
|
};
|
|
128
128
|
const getCleanupFunction = (paths) => async () => {
|
|
129
|
-
await Promise.all(paths.filter(Boolean).map(
|
|
129
|
+
await Promise.all(paths.filter(Boolean).map(fs_js_1.safeUnlink));
|
|
130
130
|
};
|
|
131
131
|
//# sourceMappingURL=bundler.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { BundleFunction } from '
|
|
1
|
+
import type { BundleFunction } from '../index.js';
|
|
2
2
|
declare const bundler: {
|
|
3
3
|
bundle: BundleFunction;
|
|
4
|
-
getSrcFiles: import("
|
|
4
|
+
getSrcFiles: import("../index.js").GetSrcFilesFunction;
|
|
5
5
|
};
|
|
6
6
|
export default bundler;
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const path_1 = require("path");
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
4
|
+
const fs_js_1 = require("../../../../utils/fs.js");
|
|
5
|
+
const non_nullable_js_1 = require("../../../../utils/non_nullable.js");
|
|
6
|
+
const base_path_js_1 = require("../../utils/base_path.js");
|
|
7
|
+
const bundler_js_1 = require("./bundler.js");
|
|
8
|
+
const special_cases_js_1 = require("./special_cases.js");
|
|
9
|
+
const src_files_js_1 = require("./src_files.js");
|
|
10
10
|
const getFunctionBasePath = ({ basePathFromConfig, mainFile, repositoryRoot, supportingSrcFiles, }) => {
|
|
11
11
|
// If there is a base path defined in the config, we use that. To account for
|
|
12
12
|
// paths outside of `basePathFromConfig` but inside `repositoryRoot`, we use
|
|
13
13
|
// the common path prefix between the two.
|
|
14
14
|
if (basePathFromConfig !== undefined) {
|
|
15
|
-
return (0,
|
|
15
|
+
return (0, base_path_js_1.getBasePath)([basePathFromConfig, repositoryRoot].filter(non_nullable_js_1.nonNullable));
|
|
16
16
|
}
|
|
17
17
|
// If not, the base path is the common path prefix between all the supporting
|
|
18
18
|
// files and the main file.
|
|
19
19
|
const dirnames = [...supportingSrcFiles, mainFile].map((filePath) => (0, path_1.normalize)((0, path_1.dirname)(filePath)));
|
|
20
|
-
return (0,
|
|
20
|
+
return (0, base_path_js_1.getBasePath)(dirnames);
|
|
21
21
|
};
|
|
22
22
|
// Convenience method for retrieving external and ignored modules from
|
|
23
23
|
// different places and merging them together.
|
|
24
24
|
const getExternalAndIgnoredModules = async ({ config, srcDir }) => {
|
|
25
25
|
const { externalNodeModules: externalModulesFromConfig = [], ignoredNodeModules: ignoredModulesFromConfig = [] } = config;
|
|
26
|
-
const { externalModules: externalModulesFromSpecialCases, ignoredModules: ignoredModulesFromSpecialCases } = await (0,
|
|
26
|
+
const { externalModules: externalModulesFromSpecialCases, ignoredModules: ignoredModulesFromSpecialCases } = await (0, special_cases_js_1.getExternalAndIgnoredModulesFromSpecialCases)({ srcDir });
|
|
27
27
|
const externalModules = [...new Set([...externalModulesFromConfig, ...externalModulesFromSpecialCases])];
|
|
28
28
|
const ignoredModules = [...ignoredModulesFromConfig, ...ignoredModulesFromSpecialCases];
|
|
29
29
|
return { externalModules, ignoredModules };
|
|
30
30
|
};
|
|
31
31
|
const bundle = async ({ basePath, config = {}, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, repositoryRoot, runtime, srcDir, srcPath, stat, }) => {
|
|
32
32
|
const { externalModules, ignoredModules } = await getExternalAndIgnoredModules({ config, srcDir });
|
|
33
|
-
const { additionalPaths, bundlePaths, cleanTempFiles, inputs, nativeNodeModules = {}, nodeModulesWithDynamicImports, warnings, } = await (0,
|
|
33
|
+
const { additionalPaths, bundlePaths, cleanTempFiles, inputs, nativeNodeModules = {}, nodeModulesWithDynamicImports, warnings, } = await (0, bundler_js_1.bundleJsFile)({
|
|
34
34
|
additionalModulePaths: pluginsModulesPath ? [pluginsModulesPath] : [],
|
|
35
35
|
basePath,
|
|
36
36
|
config,
|
|
@@ -41,7 +41,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
|
|
|
41
41
|
srcFile: mainFile,
|
|
42
42
|
});
|
|
43
43
|
const bundlerWarnings = warnings.length === 0 ? undefined : warnings;
|
|
44
|
-
const srcFiles = await (0,
|
|
44
|
+
const srcFiles = await (0, src_files_js_1.getSrcFiles)({
|
|
45
45
|
basePath,
|
|
46
46
|
config: {
|
|
47
47
|
...config,
|
|
@@ -64,7 +64,7 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
|
|
|
64
64
|
// path of the original, pre-bundling function file. We'll add the actual
|
|
65
65
|
// bundled file further below.
|
|
66
66
|
const supportingSrcFiles = srcFiles.filter((path) => path !== mainFile);
|
|
67
|
-
const normalizedMainFile = (0,
|
|
67
|
+
const normalizedMainFile = (0, fs_js_1.getPathWithExtension)(mainFile, '.js');
|
|
68
68
|
const functionBasePath = getFunctionBasePath({
|
|
69
69
|
basePathFromConfig: basePath,
|
|
70
70
|
mainFile,
|
|
@@ -84,6 +84,6 @@ const bundle = async ({ basePath, config = {}, extension, featureFlags, filename
|
|
|
84
84
|
srcFiles: [...supportingSrcFiles, ...bundlePaths.keys()],
|
|
85
85
|
};
|
|
86
86
|
};
|
|
87
|
-
const bundler = { bundle, getSrcFiles:
|
|
87
|
+
const bundler = { bundle, getSrcFiles: src_files_js_1.getSrcFiles };
|
|
88
88
|
exports.default = bundler;
|
|
89
89
|
//# sourceMappingURL=index.js.map
|
|
@@ -8,7 +8,7 @@ const path_1 = require("path");
|
|
|
8
8
|
const find_up_1 = __importDefault(require("find-up"));
|
|
9
9
|
const read_package_json_fast_1 = __importDefault(require("read-package-json-fast"));
|
|
10
10
|
const unixify_1 = __importDefault(require("unixify"));
|
|
11
|
-
const
|
|
11
|
+
const index_js_1 = require("../../parser/index.js");
|
|
12
12
|
// This plugin intercepts module imports using dynamic expressions and does a
|
|
13
13
|
// couple of things with them. First of all, it figures out whether the call
|
|
14
14
|
// is being made from within a Node module, and if so it adds the name of the
|
|
@@ -28,7 +28,7 @@ const getDynamicImportsPlugin = ({ basePath, includedPaths, moduleNames, process
|
|
|
28
28
|
// Also don't parse the expression if we're not interested in processing
|
|
29
29
|
// the dynamic import expressions.
|
|
30
30
|
if (basePath && processImports) {
|
|
31
|
-
const { includedPathsGlob, type: expressionType } = (0,
|
|
31
|
+
const { includedPathsGlob, type: expressionType } = (0, index_js_1.parseExpression)({ basePath, expression, resolveDir }) || {};
|
|
32
32
|
if (includedPathsGlob) {
|
|
33
33
|
// The parser has found a glob of paths that should be included in the
|
|
34
34
|
// bundle to make this import work, so we add it to `includedPaths`.
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.getNativeModulesPlugin = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const read_package_json_fast_1 = __importDefault(require("read-package-json-fast"));
|
|
9
|
-
const
|
|
9
|
+
const detect_native_module_js_1 = require("../../utils/detect_native_module.js");
|
|
10
10
|
// Filters out relative or absolute file paths.
|
|
11
11
|
const packageFilter = /^([^./]*)$/;
|
|
12
12
|
// Filters valid package names and extracts the base directory.
|
|
@@ -14,7 +14,7 @@ const packageName = /^([^@][^/]*|@[^/]*\/[^/]+)(?:\/|$)/;
|
|
|
14
14
|
const findNativeModule = (packageJsonPath, cache) => {
|
|
15
15
|
if (cache[packageJsonPath] === undefined) {
|
|
16
16
|
// eslint-disable-next-line no-param-reassign, promise/prefer-await-to-then
|
|
17
|
-
cache[packageJsonPath] = (0, read_package_json_fast_1.default)(packageJsonPath).then((data) => [Boolean((0,
|
|
17
|
+
cache[packageJsonPath] = (0, read_package_json_fast_1.default)(packageJsonPath).then((data) => [Boolean((0, detect_native_module_js_1.isNativeModule)(data)), data], () => [undefined, {}]);
|
|
18
18
|
}
|
|
19
19
|
return cache[packageJsonPath];
|
|
20
20
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExternalAndIgnoredModulesFromSpecialCases = void 0;
|
|
4
|
-
const
|
|
4
|
+
const package_json_js_1 = require("../../utils/package_json.js");
|
|
5
5
|
const EXTERNAL_MODULES = ['@prisma/client'];
|
|
6
6
|
const IGNORED_MODULES = ['aws-sdk'];
|
|
7
7
|
const getModulesForNextJs = ({ dependencies, devDependencies }) => {
|
|
@@ -14,7 +14,7 @@ const getModulesForNextJs = ({ dependencies, devDependencies }) => {
|
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
const getExternalAndIgnoredModulesFromSpecialCases = async ({ srcDir }) => {
|
|
17
|
-
const { dependencies = {}, devDependencies = {} } = await (0,
|
|
17
|
+
const { dependencies = {}, devDependencies = {} } = await (0, package_json_js_1.getPackageJsonIfAvailable)(srcDir);
|
|
18
18
|
const { externalModules: nextJsExternalModules, ignoredModules: nextJsIgnoredModules } = getModulesForNextJs({
|
|
19
19
|
dependencies,
|
|
20
20
|
devDependencies,
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { GetSrcFilesFunction } from '
|
|
1
|
+
import type { GetSrcFilesFunction } from '../index.js';
|
|
2
2
|
export declare const getSrcFiles: GetSrcFilesFunction;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSrcFiles = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
4
|
+
const included_files_js_1 = require("../../utils/included_files.js");
|
|
5
|
+
const package_json_js_1 = require("../../utils/package_json.js");
|
|
6
|
+
const traversal_cache_js_1 = require("../../utils/traversal_cache.js");
|
|
7
|
+
const traverse_js_1 = require("../zisi/traverse.js");
|
|
8
8
|
const getSrcFiles = async ({ config, mainFile, pluginsModulesPath, srcDir }) => {
|
|
9
9
|
const { externalNodeModules = [], includedFiles = [], includedFilesBasePath } = config;
|
|
10
|
-
const { exclude: excludedPaths, paths: includedFilePaths } = await (0,
|
|
10
|
+
const { exclude: excludedPaths, paths: includedFilePaths } = await (0, included_files_js_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
11
11
|
const dependencyPaths = await getSrcFilesForDependencies({
|
|
12
12
|
dependencies: externalNodeModules,
|
|
13
13
|
basedir: srcDir,
|
|
14
14
|
pluginsModulesPath,
|
|
15
15
|
});
|
|
16
|
-
const includedPaths = (0,
|
|
16
|
+
const includedPaths = (0, included_files_js_1.filterExcludedPaths)([...dependencyPaths, ...includedFilePaths], excludedPaths);
|
|
17
17
|
return [...includedPaths, mainFile];
|
|
18
18
|
};
|
|
19
19
|
exports.getSrcFiles = getSrcFiles;
|
|
20
|
-
const getSrcFilesForDependencies = async function ({ dependencies: dependencyNames, basedir, state = (0,
|
|
20
|
+
const getSrcFilesForDependencies = async function ({ dependencies: dependencyNames, basedir, state = (0, traversal_cache_js_1.getNewCache)(), pluginsModulesPath, }) {
|
|
21
21
|
if (dependencyNames.length === 0) {
|
|
22
22
|
return [];
|
|
23
23
|
}
|
|
24
|
-
const packageJson = await (0,
|
|
24
|
+
const packageJson = await (0, package_json_js_1.getPackageJson)(basedir);
|
|
25
25
|
const dependencies = await Promise.all(dependencyNames.map((dependencyName) => getSrcFilesForDependency({
|
|
26
26
|
dependency: dependencyName,
|
|
27
27
|
basedir,
|
|
@@ -32,9 +32,9 @@ const getSrcFilesForDependencies = async function ({ dependencies: dependencyNam
|
|
|
32
32
|
const paths = new Set(dependencies.flat());
|
|
33
33
|
return [...paths];
|
|
34
34
|
};
|
|
35
|
-
const getSrcFilesForDependency = async function ({ dependency, basedir, state = (0,
|
|
35
|
+
const getSrcFilesForDependency = async function ({ dependency, basedir, state = (0, traversal_cache_js_1.getNewCache)(), packageJson, pluginsModulesPath, }) {
|
|
36
36
|
try {
|
|
37
|
-
const paths = await (0,
|
|
37
|
+
const paths = await (0, traverse_js_1.getDependencyPathsForDependency)({ dependency, basedir, state, packageJson, pluginsModulesPath });
|
|
38
38
|
return paths;
|
|
39
39
|
}
|
|
40
40
|
catch (error) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Message } from '@netlify/esbuild';
|
|
2
|
-
import { FunctionConfig } from '../../../config';
|
|
3
|
-
import { FeatureFlag, FeatureFlags } from '../../../feature_flags';
|
|
4
|
-
import { FunctionSource } from '../../../function';
|
|
5
|
-
import { ModuleFormat } from '../utils/module_format';
|
|
2
|
+
import { FunctionConfig } from '../../../config.js';
|
|
3
|
+
import { FeatureFlag, FeatureFlags } from '../../../feature_flags.js';
|
|
4
|
+
import { FunctionSource } from '../../../function.js';
|
|
5
|
+
import { ModuleFormat } from '../utils/module_format.js';
|
|
6
6
|
export declare type NodeBundlerName = 'esbuild' | 'esbuild_zisi' | 'nft' | 'zisi';
|
|
7
7
|
declare type BundlerWarning = Message;
|
|
8
8
|
declare type CleanupFunction = () => Promise<void>;
|