@netlify/zip-it-and-ship-it 5.4.0 → 5.5.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/README.md +1 -1
- package/dist/archive.js +3 -14
- package/dist/bin.js +13 -35
- package/dist/config.d.ts +1 -0
- package/dist/feature_flags.js +4 -1
- package/dist/main.js +42 -70
- package/dist/manifest.js +4 -13
- package/dist/runtimes/detect_runtime.js +16 -27
- package/dist/runtimes/go/builder.js +5 -14
- package/dist/runtimes/go/index.js +61 -48
- package/dist/runtimes/index.js +34 -37
- package/dist/runtimes/node/bundlers/esbuild/bundler.js +81 -92
- package/dist/runtimes/node/bundlers/esbuild/index.js +14 -18
- package/dist/runtimes/node/bundlers/esbuild/plugin_dynamic_imports.js +13 -22
- package/dist/runtimes/node/bundlers/esbuild/plugin_native_modules.js +3 -13
- package/dist/runtimes/node/bundlers/esbuild/special_cases.js +8 -17
- package/dist/runtimes/node/bundlers/esbuild/src_files.js +28 -41
- package/dist/runtimes/node/bundlers/nft/es_modules.js +16 -22
- package/dist/runtimes/node/bundlers/nft/index.js +47 -60
- package/dist/runtimes/node/bundlers/nft/transpile.js +3 -12
- package/dist/runtimes/node/bundlers/zisi/index.js +7 -13
- package/dist/runtimes/node/bundlers/zisi/list_imports.js +5 -14
- package/dist/runtimes/node/bundlers/zisi/published.js +8 -19
- package/dist/runtimes/node/bundlers/zisi/resolve.js +37 -55
- package/dist/runtimes/node/bundlers/zisi/side_files.js +6 -17
- package/dist/runtimes/node/bundlers/zisi/src_files.js +58 -75
- package/dist/runtimes/node/bundlers/zisi/traverse.js +41 -56
- package/dist/runtimes/node/bundlers/zisi/tree_files.js +8 -19
- package/dist/runtimes/node/finder.js +46 -63
- package/dist/runtimes/node/in_source_config/index.js +5 -14
- package/dist/runtimes/node/index.js +64 -87
- package/dist/runtimes/node/parser/index.js +11 -20
- package/dist/runtimes/node/utils/detect_es_module.js +4 -15
- package/dist/runtimes/node/utils/included_files.js +3 -12
- package/dist/runtimes/node/utils/package_json.js +19 -27
- package/dist/runtimes/node/utils/zip.js +63 -94
- package/dist/runtimes/rust/builder.js +23 -36
- package/dist/runtimes/rust/index.js +46 -61
- package/dist/utils/archive_size.js +5 -14
- package/dist/utils/format_result.js +6 -1
- package/dist/utils/fs.d.ts +6 -10
- package/dist/utils/fs.js +35 -63
- package/dist/zip.d.ts +1 -0
- package/dist/zip.js +59 -72
- package/dist/zip_binary.js +5 -16
- package/package.json +8 -15
package/dist/runtimes/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -25,22 +16,25 @@ const rust_1 = __importDefault(require("./rust"));
|
|
|
25
16
|
* and an array with the paths that haven't been recognized by the runtime
|
|
26
17
|
* (`remainingPaths`).
|
|
27
18
|
*/
|
|
28
|
-
const findFunctionsInRuntime = function ({ dedupe = false, featureFlags, fsCache, paths, runtime, }) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
19
|
+
const findFunctionsInRuntime = async function ({ dedupe = false, featureFlags, fsCache, paths, runtime, }) {
|
|
20
|
+
const functions = await runtime.findFunctionsInPaths({ featureFlags, fsCache, paths });
|
|
21
|
+
// If `dedupe` is true, we use the function name (`filename`) as the map key,
|
|
22
|
+
// so that `function-1.js` will overwrite `function-1.go`. Otherwise, we use
|
|
23
|
+
// `srcPath`, so that both functions are returned.
|
|
24
|
+
const key = dedupe ? 'name' : 'srcPath';
|
|
25
|
+
// Augmenting the function objects with additional information.
|
|
26
|
+
const augmentedFunctions = functions.map((func) => [
|
|
27
|
+
func[key],
|
|
28
|
+
{
|
|
29
|
+
...func,
|
|
30
|
+
extension: (0, path_1.extname)(func.mainFile),
|
|
31
|
+
filename: (0, path_1.basename)(func.srcPath),
|
|
32
|
+
runtime,
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
const usedPaths = new Set(augmentedFunctions.map(([path]) => path));
|
|
36
|
+
const remainingPaths = paths.filter((path) => !usedPaths.has(path));
|
|
37
|
+
return { functions: augmentedFunctions, remainingPaths };
|
|
44
38
|
};
|
|
45
39
|
// An object to cache filesystem operations. This allows different functions
|
|
46
40
|
// to perform IO operations on the same file (i.e. getting its stats or its
|
|
@@ -53,15 +47,15 @@ const RUNTIMES = [node_1.default, go_1.default, rust_1.default];
|
|
|
53
47
|
/**
|
|
54
48
|
* Gets a list of functions found in a list of paths.
|
|
55
49
|
*/
|
|
56
|
-
const getFunctionsFromPaths = (paths, { config, dedupe = false, featureFlags = feature_flags_1.defaultFlags, } = {}) =>
|
|
50
|
+
const getFunctionsFromPaths = async (paths, { config, dedupe = false, featureFlags = feature_flags_1.defaultFlags, } = {}) => {
|
|
57
51
|
const fsCache = makeFsCache();
|
|
58
52
|
// We cycle through the ordered array of runtimes, passing each one of them
|
|
59
53
|
// through `findFunctionsInRuntime`. For each iteration, we collect all the
|
|
60
54
|
// functions found plus the list of paths that still need to be evaluated,
|
|
61
55
|
// using them as the input for the next iteration until the last runtime.
|
|
62
|
-
const { functions } =
|
|
63
|
-
const { functions: aggregateFunctions, remainingPaths: aggregatePaths } =
|
|
64
|
-
const { functions: runtimeFunctions, remainingPaths: runtimePaths } =
|
|
56
|
+
const { functions } = await RUNTIMES.reduce(async (aggregate, runtime) => {
|
|
57
|
+
const { functions: aggregateFunctions, remainingPaths: aggregatePaths } = await aggregate;
|
|
58
|
+
const { functions: runtimeFunctions, remainingPaths: runtimePaths } = await findFunctionsInRuntime({
|
|
65
59
|
dedupe,
|
|
66
60
|
featureFlags,
|
|
67
61
|
fsCache,
|
|
@@ -72,27 +66,30 @@ const getFunctionsFromPaths = (paths, { config, dedupe = false, featureFlags = f
|
|
|
72
66
|
functions: [...aggregateFunctions, ...runtimeFunctions],
|
|
73
67
|
remainingPaths: runtimePaths,
|
|
74
68
|
};
|
|
75
|
-
}
|
|
69
|
+
}, Promise.resolve({ functions: [], remainingPaths: paths }));
|
|
76
70
|
const functionsWithConfig = functions.map(([name, func]) => [
|
|
77
71
|
name,
|
|
78
|
-
|
|
72
|
+
{ ...func, config: (0, config_1.getConfigForFunction)({ config, func }) },
|
|
79
73
|
]);
|
|
80
74
|
return new Map(functionsWithConfig);
|
|
81
|
-
}
|
|
75
|
+
};
|
|
82
76
|
exports.getFunctionsFromPaths = getFunctionsFromPaths;
|
|
83
77
|
/**
|
|
84
78
|
* Gets a list of functions found in a list of paths.
|
|
85
79
|
*/
|
|
86
|
-
const getFunctionFromPath = (path, { config, featureFlags = feature_flags_1.defaultFlags } = {}) =>
|
|
80
|
+
const getFunctionFromPath = async (path, { config, featureFlags = feature_flags_1.defaultFlags } = {}) => {
|
|
87
81
|
const fsCache = makeFsCache();
|
|
88
82
|
for (const runtime of RUNTIMES) {
|
|
89
|
-
|
|
90
|
-
const func = yield runtime.findFunctionInPath({ path, fsCache, featureFlags });
|
|
83
|
+
const func = await runtime.findFunctionInPath({ path, fsCache, featureFlags });
|
|
91
84
|
if (func) {
|
|
92
|
-
return
|
|
85
|
+
return {
|
|
86
|
+
...func,
|
|
87
|
+
runtime,
|
|
88
|
+
config: (0, config_1.getConfigForFunction)({ config, func: { ...func, runtime } }),
|
|
89
|
+
};
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
92
|
return undefined;
|
|
96
|
-
}
|
|
93
|
+
};
|
|
97
94
|
exports.getFunctionFromPath = getFunctionFromPath;
|
|
98
95
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.ESBUILD_LOG_LIMIT = exports.bundleJsFile = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
@@ -27,86 +18,84 @@ exports.ESBUILD_LOG_LIMIT = ESBUILD_LOG_LIMIT;
|
|
|
27
18
|
// the extensions that esbuild will look for, in this order.
|
|
28
19
|
const RESOLVE_EXTENSIONS = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.json'];
|
|
29
20
|
// eslint-disable-next-line max-statements
|
|
30
|
-
const bundleJsFile = function ({ additionalModulePaths, basePath, config, externalModules = [], ignoredModules = [], name, srcDir, srcFile, }) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
});
|
|
21
|
+
const bundleJsFile = async function ({ additionalModulePaths, basePath, config, externalModules = [], ignoredModules = [], name, srcDir, srcFile, }) {
|
|
22
|
+
// We use a temporary directory as the destination for esbuild files to avoid
|
|
23
|
+
// any naming conflicts with files generated by other functions.
|
|
24
|
+
const targetDirectory = await (0, tmp_promise_1.tmpName)();
|
|
25
|
+
// De-duping external and ignored modules.
|
|
26
|
+
const external = [...new Set([...externalModules, ...ignoredModules])];
|
|
27
|
+
// To be populated by the native modules plugin with the names, versions and
|
|
28
|
+
// paths of any Node modules with native dependencies.
|
|
29
|
+
const nativeNodeModules = {};
|
|
30
|
+
// To be populated by the dynamic imports plugin with the names of the Node
|
|
31
|
+
// modules that include imports with dynamic expressions.
|
|
32
|
+
const nodeModulesWithDynamicImports = new Set();
|
|
33
|
+
// To be populated by the dynamic imports plugin with any paths (in a glob
|
|
34
|
+
// format) to be included in the bundle in order to make a dynamic import
|
|
35
|
+
// work at runtime.
|
|
36
|
+
const dynamicImportsIncludedPaths = new Set();
|
|
37
|
+
// The list of esbuild plugins to enable for this build.
|
|
38
|
+
const plugins = [
|
|
39
|
+
(0, plugin_node_builtin_1.getNodeBuiltinPlugin)(),
|
|
40
|
+
(0, plugin_native_modules_1.getNativeModulesPlugin)(nativeNodeModules),
|
|
41
|
+
(0, plugin_dynamic_imports_1.getDynamicImportsPlugin)({
|
|
42
|
+
basePath,
|
|
43
|
+
includedPaths: dynamicImportsIncludedPaths,
|
|
44
|
+
moduleNames: nodeModulesWithDynamicImports,
|
|
45
|
+
processImports: config.processDynamicNodeImports !== false,
|
|
46
|
+
srcDir,
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
// The version of ECMAScript to use as the build target. This will determine
|
|
50
|
+
// whether certain features are transpiled down or left untransformed.
|
|
51
|
+
const nodeTarget = (0, bundler_target_1.getBundlerTarget)(config.nodeVersion);
|
|
52
|
+
// esbuild will format `sources` relative to the sourcemap file, which lives
|
|
53
|
+
// in `destFolder`. We use `sourceRoot` to establish that relation. They are
|
|
54
|
+
// URLs, not paths, so even on Windows they should use forward slashes.
|
|
55
|
+
const sourceRoot = targetDirectory.replace(/\\/g, '/');
|
|
56
|
+
try {
|
|
57
|
+
const { metafile = { inputs: {}, outputs: {} }, warnings } = await (0, esbuild_1.build)({
|
|
58
|
+
bundle: true,
|
|
59
|
+
entryPoints: [srcFile],
|
|
60
|
+
external,
|
|
61
|
+
logLevel: 'warning',
|
|
62
|
+
logLimit: ESBUILD_LOG_LIMIT,
|
|
63
|
+
metafile: true,
|
|
64
|
+
nodePaths: additionalModulePaths,
|
|
65
|
+
outdir: targetDirectory,
|
|
66
|
+
platform: 'node',
|
|
67
|
+
plugins,
|
|
68
|
+
resolveExtensions: RESOLVE_EXTENSIONS,
|
|
69
|
+
sourcemap: Boolean(config.nodeSourcemap),
|
|
70
|
+
sourceRoot,
|
|
71
|
+
target: [nodeTarget],
|
|
72
|
+
});
|
|
73
|
+
const bundlePaths = getBundlePaths({
|
|
74
|
+
destFolder: targetDirectory,
|
|
75
|
+
outputs: metafile.outputs,
|
|
76
|
+
srcFile,
|
|
77
|
+
});
|
|
78
|
+
const inputs = Object.keys(metafile.inputs).map((path) => (0, path_1.resolve)(path));
|
|
79
|
+
const cleanTempFiles = getCleanupFunction([...bundlePaths.keys()]);
|
|
80
|
+
return {
|
|
81
|
+
additionalPaths: [...dynamicImportsIncludedPaths],
|
|
82
|
+
bundlePaths,
|
|
83
|
+
cleanTempFiles,
|
|
84
|
+
inputs,
|
|
85
|
+
nativeNodeModules,
|
|
86
|
+
nodeModulesWithDynamicImports: [...nodeModulesWithDynamicImports],
|
|
87
|
+
warnings,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
const bundler = 'esbuild';
|
|
92
|
+
const runtime = 'js';
|
|
93
|
+
error.customErrorInfo = {
|
|
94
|
+
type: 'functionsBundling',
|
|
95
|
+
location: { bundler, functionName: name, runtime },
|
|
96
|
+
};
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
110
99
|
};
|
|
111
100
|
exports.bundleJsFile = bundleJsFile;
|
|
112
101
|
// Takes the `outputs` object produced by esbuild and returns a Map with the
|
|
@@ -137,7 +126,7 @@ const getBundlePaths = ({ destFolder, outputs, srcFile, }) => {
|
|
|
137
126
|
});
|
|
138
127
|
return bundlePaths;
|
|
139
128
|
};
|
|
140
|
-
const getCleanupFunction = (paths) => () =>
|
|
141
|
-
|
|
142
|
-
}
|
|
129
|
+
const getCleanupFunction = (paths) => async () => {
|
|
130
|
+
await Promise.all(paths.filter(Boolean).map(fs_1.safeUnlink));
|
|
131
|
+
};
|
|
143
132
|
//# sourceMappingURL=bundler.js.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const path_1 = require("path");
|
|
13
4
|
const fs_1 = require("../../../../utils/fs");
|
|
@@ -30,16 +21,16 @@ const getFunctionBasePath = ({ basePathFromConfig, mainFile, repositoryRoot, sup
|
|
|
30
21
|
};
|
|
31
22
|
// Convenience method for retrieving external and ignored modules from
|
|
32
23
|
// different places and merging them together.
|
|
33
|
-
const getExternalAndIgnoredModules = ({ config, srcDir }) =>
|
|
24
|
+
const getExternalAndIgnoredModules = async ({ config, srcDir }) => {
|
|
34
25
|
const { externalNodeModules: externalModulesFromConfig = [], ignoredNodeModules: ignoredModulesFromConfig = [] } = config;
|
|
35
|
-
const { externalModules: externalModulesFromSpecialCases, ignoredModules: ignoredModulesFromSpecialCases } =
|
|
26
|
+
const { externalModules: externalModulesFromSpecialCases, ignoredModules: ignoredModulesFromSpecialCases } = await (0, special_cases_1.getExternalAndIgnoredModulesFromSpecialCases)({ srcDir });
|
|
36
27
|
const externalModules = [...new Set([...externalModulesFromConfig, ...externalModulesFromSpecialCases])];
|
|
37
28
|
const ignoredModules = [...ignoredModulesFromConfig, ...ignoredModulesFromSpecialCases];
|
|
38
29
|
return { externalModules, ignoredModules };
|
|
39
|
-
}
|
|
40
|
-
const bundle = ({ basePath, config = {}, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, repositoryRoot, runtime, srcDir, srcPath, stat, }) =>
|
|
41
|
-
const { externalModules, ignoredModules } =
|
|
42
|
-
const { additionalPaths, bundlePaths, cleanTempFiles, inputs, nativeNodeModules = {}, nodeModulesWithDynamicImports, warnings, } =
|
|
30
|
+
};
|
|
31
|
+
const bundle = async ({ basePath, config = {}, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, repositoryRoot, runtime, srcDir, srcPath, stat, }) => {
|
|
32
|
+
const { externalModules, ignoredModules } = await getExternalAndIgnoredModules({ config, srcDir });
|
|
33
|
+
const { additionalPaths, bundlePaths, cleanTempFiles, inputs, nativeNodeModules = {}, nodeModulesWithDynamicImports, warnings, } = await (0, bundler_1.bundleJsFile)({
|
|
43
34
|
additionalModulePaths: pluginsModulesPath ? [pluginsModulesPath] : [],
|
|
44
35
|
basePath,
|
|
45
36
|
config,
|
|
@@ -50,9 +41,14 @@ const bundle = ({ basePath, config = {}, extension, featureFlags, filename, main
|
|
|
50
41
|
srcFile: mainFile,
|
|
51
42
|
});
|
|
52
43
|
const bundlerWarnings = warnings.length === 0 ? undefined : warnings;
|
|
53
|
-
const srcFiles =
|
|
44
|
+
const srcFiles = await (0, src_files_1.getSrcFiles)({
|
|
54
45
|
basePath,
|
|
55
|
-
config:
|
|
46
|
+
config: {
|
|
47
|
+
...config,
|
|
48
|
+
externalNodeModules: [...externalModules, ...Object.keys(nativeNodeModules)],
|
|
49
|
+
includedFiles: [...(config.includedFiles || []), ...additionalPaths],
|
|
50
|
+
includedFilesBasePath: config.includedFilesBasePath || basePath,
|
|
51
|
+
},
|
|
56
52
|
extension,
|
|
57
53
|
featureFlags,
|
|
58
54
|
filename,
|
|
@@ -86,7 +82,7 @@ const bundle = ({ basePath, config = {}, extension, featureFlags, filename, main
|
|
|
86
82
|
nodeModulesWithDynamicImports,
|
|
87
83
|
srcFiles: [...supportingSrcFiles, ...bundlePaths.keys()],
|
|
88
84
|
};
|
|
89
|
-
}
|
|
85
|
+
};
|
|
90
86
|
const bundler = { bundle, getSrcFiles: src_files_1.getSrcFiles };
|
|
91
87
|
exports.default = bundler;
|
|
92
88
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -30,7 +21,7 @@ const getDynamicImportsPlugin = ({ basePath, includedPaths, moduleNames, process
|
|
|
30
21
|
setup(build) {
|
|
31
22
|
const cache = new Map();
|
|
32
23
|
// eslint-disable-next-line complexity
|
|
33
|
-
build.onDynamicImport({ filter: /.*/ }, (args) =>
|
|
24
|
+
build.onDynamicImport({ filter: /.*/ }, async (args) => {
|
|
34
25
|
const { expression, resolveDir } = args;
|
|
35
26
|
// Don't attempt to parse the expression if the base path isn't defined,
|
|
36
27
|
// since we won't be able to generate the globs for the included paths.
|
|
@@ -56,27 +47,27 @@ const getDynamicImportsPlugin = ({ basePath, includedPaths, moduleNames, process
|
|
|
56
47
|
// If we're here, it means we weren't able to solve the dynamic import.
|
|
57
48
|
// We add it to the list of modules with dynamic imports, which allows
|
|
58
49
|
// consumers like Netlify Build or CLI to advise users on how to proceed.
|
|
59
|
-
|
|
60
|
-
})
|
|
50
|
+
await registerModuleWithDynamicImports({ cache, moduleNames, resolveDir, srcDir });
|
|
51
|
+
});
|
|
61
52
|
},
|
|
62
53
|
});
|
|
63
54
|
exports.getDynamicImportsPlugin = getDynamicImportsPlugin;
|
|
64
|
-
const getPackageName = ({ resolveDir, srcDir }) =>
|
|
65
|
-
const packageJsonPath =
|
|
55
|
+
const getPackageName = async ({ resolveDir, srcDir }) => {
|
|
56
|
+
const packageJsonPath = await (0, find_up_1.default)(async (directory) => {
|
|
66
57
|
// We stop traversing if we're about to leave the boundaries of the
|
|
67
58
|
// function directory or any node_modules directory.
|
|
68
59
|
if (directory === srcDir || (0, path_1.basename)(directory) === 'node_modules') {
|
|
69
60
|
return find_up_1.default.stop;
|
|
70
61
|
}
|
|
71
62
|
const path = (0, path_1.join)(directory, 'package.json');
|
|
72
|
-
const hasPackageJson =
|
|
63
|
+
const hasPackageJson = await find_up_1.default.exists(path);
|
|
73
64
|
return hasPackageJson ? path : undefined;
|
|
74
|
-
}
|
|
65
|
+
}, { cwd: resolveDir });
|
|
75
66
|
if (packageJsonPath !== undefined) {
|
|
76
|
-
const { name } =
|
|
67
|
+
const { name } = await (0, read_package_json_fast_1.default)(packageJsonPath);
|
|
77
68
|
return name;
|
|
78
69
|
}
|
|
79
|
-
}
|
|
70
|
+
};
|
|
80
71
|
const getPackageNameCached = ({ cache, resolveDir, srcDir, }) => {
|
|
81
72
|
if (!cache.has(resolveDir)) {
|
|
82
73
|
cache.set(resolveDir, getPackageName({ resolveDir, srcDir }));
|
|
@@ -95,15 +86,15 @@ const getShimContents = ({ expressionType, resolveDir, srcDir, }) => {
|
|
|
95
86
|
return `module.exports = args => require(${requireArg})`;
|
|
96
87
|
}
|
|
97
88
|
};
|
|
98
|
-
const registerModuleWithDynamicImports = ({ cache, moduleNames, resolveDir, srcDir, }) =>
|
|
89
|
+
const registerModuleWithDynamicImports = async ({ cache, moduleNames, resolveDir, srcDir, }) => {
|
|
99
90
|
try {
|
|
100
|
-
const packageName =
|
|
91
|
+
const packageName = await getPackageNameCached({ cache, resolveDir, srcDir });
|
|
101
92
|
if (packageName !== undefined) {
|
|
102
93
|
moduleNames.add(packageName);
|
|
103
94
|
}
|
|
104
95
|
}
|
|
105
|
-
catch
|
|
96
|
+
catch {
|
|
106
97
|
// no-op
|
|
107
98
|
}
|
|
108
|
-
}
|
|
99
|
+
};
|
|
109
100
|
//# sourceMappingURL=plugin_dynamic_imports.js.map
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -32,7 +23,7 @@ const getNativeModulesPlugin = (externalizedModules) => ({
|
|
|
32
23
|
setup(build) {
|
|
33
24
|
const cache = {};
|
|
34
25
|
// eslint-disable-next-line complexity, max-statements
|
|
35
|
-
build.onResolve({ filter: packageFilter }, (args) =>
|
|
26
|
+
build.onResolve({ filter: packageFilter }, async (args) => {
|
|
36
27
|
const pkg = packageName.exec(args.path);
|
|
37
28
|
if (!pkg)
|
|
38
29
|
return;
|
|
@@ -41,8 +32,7 @@ const getNativeModulesPlugin = (externalizedModules) => ({
|
|
|
41
32
|
if (path_1.default.basename(directory) !== 'node_modules') {
|
|
42
33
|
const modulePath = path_1.default.join(directory, 'node_modules', pkg[1]);
|
|
43
34
|
const packageJsonPath = path_1.default.join(modulePath, 'package.json');
|
|
44
|
-
|
|
45
|
-
const [isNative, packageJsonData] = yield findNativeModule(packageJsonPath, cache);
|
|
35
|
+
const [isNative, packageJsonData] = await findNativeModule(packageJsonPath, cache);
|
|
46
36
|
// eslint-disable-next-line max-depth
|
|
47
37
|
if (isNative === true) {
|
|
48
38
|
// eslint-disable-next-line max-depth
|
|
@@ -65,7 +55,7 @@ const getNativeModulesPlugin = (externalizedModules) => ({
|
|
|
65
55
|
}
|
|
66
56
|
directory = parentDirectory;
|
|
67
57
|
}
|
|
68
|
-
})
|
|
58
|
+
});
|
|
69
59
|
},
|
|
70
60
|
});
|
|
71
61
|
exports.getNativeModulesPlugin = getNativeModulesPlugin;
|
|
@@ -1,29 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.getExternalAndIgnoredModulesFromSpecialCases = void 0;
|
|
13
4
|
const package_json_1 = require("../../utils/package_json");
|
|
14
5
|
const EXTERNAL_MODULES = ['@prisma/client'];
|
|
15
6
|
const IGNORED_MODULES = ['aws-sdk'];
|
|
16
|
-
const getPackageJsonIfAvailable = (srcDir) =>
|
|
7
|
+
const getPackageJsonIfAvailable = async (srcDir) => {
|
|
17
8
|
try {
|
|
18
|
-
const packageJson =
|
|
9
|
+
const packageJson = await (0, package_json_1.getPackageJson)(srcDir);
|
|
19
10
|
return packageJson;
|
|
20
11
|
}
|
|
21
|
-
catch
|
|
12
|
+
catch {
|
|
22
13
|
return {};
|
|
23
14
|
}
|
|
24
|
-
}
|
|
15
|
+
};
|
|
25
16
|
const getModulesForNextJs = ({ dependencies, devDependencies }) => {
|
|
26
|
-
const allDependencies =
|
|
17
|
+
const allDependencies = { ...dependencies, ...devDependencies };
|
|
27
18
|
const externalModules = allDependencies.next ? ['critters', 'nanoid'] : [];
|
|
28
19
|
const ignoredModules = [];
|
|
29
20
|
return {
|
|
@@ -31,8 +22,8 @@ const getModulesForNextJs = ({ dependencies, devDependencies }) => {
|
|
|
31
22
|
ignoredModules,
|
|
32
23
|
};
|
|
33
24
|
};
|
|
34
|
-
const getExternalAndIgnoredModulesFromSpecialCases = ({ srcDir }) =>
|
|
35
|
-
const { dependencies = {}, devDependencies = {} } =
|
|
25
|
+
const getExternalAndIgnoredModulesFromSpecialCases = async ({ srcDir }) => {
|
|
26
|
+
const { dependencies = {}, devDependencies = {} } = await getPackageJsonIfAvailable(srcDir);
|
|
36
27
|
const { externalModules: nextJsExternalModules, ignoredModules: nextJsIgnoredModules } = getModulesForNextJs({
|
|
37
28
|
dependencies,
|
|
38
29
|
devDependencies,
|
|
@@ -43,6 +34,6 @@ const getExternalAndIgnoredModulesFromSpecialCases = ({ srcDir }) => __awaiter(v
|
|
|
43
34
|
externalModules,
|
|
44
35
|
ignoredModules,
|
|
45
36
|
};
|
|
46
|
-
}
|
|
37
|
+
};
|
|
47
38
|
exports.getExternalAndIgnoredModulesFromSpecialCases = getExternalAndIgnoredModulesFromSpecialCases;
|
|
48
39
|
//# sourceMappingURL=special_cases.js.map
|