@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
|
@@ -1,60 +1,47 @@
|
|
|
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.getSrcFiles = void 0;
|
|
13
4
|
const included_files_1 = require("../../utils/included_files");
|
|
14
5
|
const package_json_1 = require("../../utils/package_json");
|
|
15
6
|
const traversal_cache_1 = require("../../utils/traversal_cache");
|
|
16
7
|
const traverse_1 = require("../zisi/traverse");
|
|
17
|
-
const getSrcFiles = ({ config, mainFile, pluginsModulesPath, srcDir }) =>
|
|
8
|
+
const getSrcFiles = async ({ config, mainFile, pluginsModulesPath, srcDir }) => {
|
|
18
9
|
const { externalNodeModules = [], includedFiles = [], includedFilesBasePath } = config;
|
|
19
|
-
const { exclude: excludedPaths, paths: includedFilePaths } =
|
|
20
|
-
const dependencyPaths =
|
|
10
|
+
const { exclude: excludedPaths, paths: includedFilePaths } = await (0, included_files_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
11
|
+
const dependencyPaths = await getSrcFilesForDependencies({
|
|
21
12
|
dependencies: externalNodeModules,
|
|
22
13
|
basedir: srcDir,
|
|
23
14
|
pluginsModulesPath,
|
|
24
15
|
});
|
|
25
16
|
const includedPaths = (0, included_files_1.filterExcludedPaths)([...dependencyPaths, ...includedFilePaths], excludedPaths);
|
|
26
17
|
return [...includedPaths, mainFile];
|
|
27
|
-
}
|
|
18
|
+
};
|
|
28
19
|
exports.getSrcFiles = getSrcFiles;
|
|
29
|
-
const getSrcFilesForDependencies = function ({ dependencies: dependencyNames, basedir, state = (0, traversal_cache_1.getNewCache)(), pluginsModulesPath, }) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return [...paths];
|
|
44
|
-
});
|
|
20
|
+
const getSrcFilesForDependencies = async function ({ dependencies: dependencyNames, basedir, state = (0, traversal_cache_1.getNewCache)(), pluginsModulesPath, }) {
|
|
21
|
+
if (dependencyNames.length === 0) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const packageJson = await (0, package_json_1.getPackageJson)(basedir);
|
|
25
|
+
const dependencies = await Promise.all(dependencyNames.map((dependencyName) => getSrcFilesForDependency({
|
|
26
|
+
dependency: dependencyName,
|
|
27
|
+
basedir,
|
|
28
|
+
state,
|
|
29
|
+
packageJson,
|
|
30
|
+
pluginsModulesPath,
|
|
31
|
+
})));
|
|
32
|
+
const paths = new Set(dependencies.flat());
|
|
33
|
+
return [...paths];
|
|
45
34
|
};
|
|
46
|
-
const getSrcFilesForDependency = function ({ dependency, basedir, state = (0, traversal_cache_1.getNewCache)(), packageJson, pluginsModulesPath, }) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
throw error;
|
|
35
|
+
const getSrcFilesForDependency = async function ({ dependency, basedir, state = (0, traversal_cache_1.getNewCache)(), packageJson, pluginsModulesPath, }) {
|
|
36
|
+
try {
|
|
37
|
+
const paths = await (0, traverse_1.getDependencyPathsForDependency)({ dependency, basedir, state, packageJson, pluginsModulesPath });
|
|
38
|
+
return paths;
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (error.code === 'MODULE_NOT_FOUND') {
|
|
42
|
+
return [];
|
|
57
43
|
}
|
|
58
|
-
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
59
46
|
};
|
|
60
47
|
//# sourceMappingURL=src_files.js.map
|
|
@@ -1,32 +1,26 @@
|
|
|
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.transpileESM = void 0;
|
|
13
4
|
const path_1 = require("path");
|
|
14
5
|
const fs_1 = require("../../../../utils/fs");
|
|
15
6
|
const transpile_1 = require("./transpile");
|
|
16
|
-
const getPatchedESMPackages = (packages, fsCache) =>
|
|
17
|
-
const patchedPackages =
|
|
7
|
+
const getPatchedESMPackages = async (packages, fsCache) => {
|
|
8
|
+
const patchedPackages = await Promise.all(packages.map((path) => patchESMPackage(path, fsCache)));
|
|
18
9
|
const patchedPackagesMap = new Map();
|
|
19
10
|
packages.forEach((packagePath, index) => {
|
|
20
11
|
patchedPackagesMap.set(packagePath, patchedPackages[index]);
|
|
21
12
|
});
|
|
22
13
|
return patchedPackagesMap;
|
|
23
|
-
}
|
|
24
|
-
const patchESMPackage = (path, fsCache) =>
|
|
25
|
-
const file = (
|
|
14
|
+
};
|
|
15
|
+
const patchESMPackage = async (path, fsCache) => {
|
|
16
|
+
const file = (await (0, fs_1.cachedReadFile)(fsCache, path, 'utf8'));
|
|
26
17
|
const packageJson = JSON.parse(file);
|
|
27
|
-
const patchedPackageJson =
|
|
18
|
+
const patchedPackageJson = {
|
|
19
|
+
...packageJson,
|
|
20
|
+
type: 'commonjs',
|
|
21
|
+
};
|
|
28
22
|
return JSON.stringify(patchedPackageJson);
|
|
29
|
-
}
|
|
23
|
+
};
|
|
30
24
|
const shouldTranspile = (path, cache, esmPaths, reasons) => {
|
|
31
25
|
if (cache.has(path)) {
|
|
32
26
|
return cache.get(path);
|
|
@@ -51,7 +45,7 @@ const shouldTranspile = (path, cache, esmPaths, reasons) => {
|
|
|
51
45
|
cache.set(path, shouldTranspilePath);
|
|
52
46
|
return shouldTranspilePath;
|
|
53
47
|
};
|
|
54
|
-
const transpileESM = ({ basePath, config, esmPaths, fsCache, reasons, }) =>
|
|
48
|
+
const transpileESM = async ({ basePath, config, esmPaths, fsCache, reasons, }) => {
|
|
55
49
|
const cache = new Map();
|
|
56
50
|
const pathsToTranspile = [...esmPaths].filter((path) => shouldTranspile(path, cache, esmPaths, reasons));
|
|
57
51
|
const pathsToTranspileSet = new Set(pathsToTranspile);
|
|
@@ -64,13 +58,13 @@ const transpileESM = ({ basePath, config, esmPaths, fsCache, reasons, }) => __aw
|
|
|
64
58
|
return needsPatch;
|
|
65
59
|
})
|
|
66
60
|
.map(([path]) => (basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path)));
|
|
67
|
-
const rewrites =
|
|
68
|
-
|
|
61
|
+
const rewrites = await getPatchedESMPackages(packageJsonPaths, fsCache);
|
|
62
|
+
await Promise.all(pathsToTranspile.map(async (path) => {
|
|
69
63
|
const absolutePath = basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path);
|
|
70
|
-
const transpiled =
|
|
64
|
+
const transpiled = await (0, transpile_1.transpile)(absolutePath, config);
|
|
71
65
|
rewrites.set(absolutePath, transpiled);
|
|
72
|
-
}))
|
|
66
|
+
}));
|
|
73
67
|
return rewrites;
|
|
74
|
-
}
|
|
68
|
+
};
|
|
75
69
|
exports.transpileESM = transpileESM;
|
|
76
70
|
//# sourceMappingURL=es_modules.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
|
};
|
|
@@ -24,10 +15,10 @@ const es_modules_1 = require("./es_modules");
|
|
|
24
15
|
// Paths that will be excluded from the tracing process.
|
|
25
16
|
const ignore = ['node_modules/aws-sdk/**'];
|
|
26
17
|
const appearsToBeModuleName = (name) => !name.startsWith('.');
|
|
27
|
-
const bundle = ({ basePath, config, mainFile, pluginsModulesPath, repositoryRoot = basePath, }) =>
|
|
18
|
+
const bundle = async ({ basePath, config, mainFile, pluginsModulesPath, repositoryRoot = basePath, }) => {
|
|
28
19
|
const { includedFiles = [], includedFilesBasePath } = config;
|
|
29
|
-
const { exclude: excludedPaths, paths: includedFilePaths } =
|
|
30
|
-
const { paths: dependencyPaths, rewrites } =
|
|
20
|
+
const { exclude: excludedPaths, paths: includedFilePaths } = await (0, included_files_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath || basePath);
|
|
21
|
+
const { paths: dependencyPaths, rewrites } = await traceFilesAndTranspile({
|
|
31
22
|
basePath: repositoryRoot,
|
|
32
23
|
config,
|
|
33
24
|
mainFile,
|
|
@@ -44,63 +35,59 @@ const bundle = ({ basePath, config, mainFile, pluginsModulesPath, repositoryRoot
|
|
|
44
35
|
rewrites,
|
|
45
36
|
srcFiles,
|
|
46
37
|
};
|
|
47
|
-
}
|
|
38
|
+
};
|
|
48
39
|
const ignoreFunction = (path) => {
|
|
49
40
|
const normalizedPath = (0, unixify_1.default)(path);
|
|
50
41
|
const shouldIgnore = ignore.some((expression) => (0, minimatch_1.default)(normalizedPath, expression));
|
|
51
42
|
return shouldIgnore;
|
|
52
43
|
};
|
|
53
|
-
const traceFilesAndTranspile = function ({ basePath, config, mainFile, pluginsModulesPath, }) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
return null;
|
|
67
|
-
}
|
|
68
|
-
throw error;
|
|
69
|
-
}
|
|
70
|
-
}),
|
|
71
|
-
resolve: (specifier, parent, ...args) => __awaiter(this, void 0, void 0, function* () {
|
|
72
|
-
try {
|
|
73
|
-
return yield (0, resolve_dependency_1.default)(specifier, parent, ...args);
|
|
44
|
+
const traceFilesAndTranspile = async function ({ basePath, config, mainFile, pluginsModulesPath, }) {
|
|
45
|
+
const fsCache = {};
|
|
46
|
+
const { fileList: dependencyPaths, esmFileList, reasons, } = await (0, nft_1.nodeFileTrace)([mainFile], {
|
|
47
|
+
base: basePath,
|
|
48
|
+
ignore: ignoreFunction,
|
|
49
|
+
readFile: async (path) => {
|
|
50
|
+
try {
|
|
51
|
+
const source = (await (0, fs_1.cachedReadFile)(fsCache, path, 'utf8'));
|
|
52
|
+
return source;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error.code === 'ENOENT' || error.code === 'EISDIR') {
|
|
56
|
+
return null;
|
|
74
57
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
resolve: async (specifier, parent, ...args) => {
|
|
62
|
+
try {
|
|
63
|
+
return await (0, resolve_dependency_1.default)(specifier, parent, ...args);
|
|
64
|
+
}
|
|
65
|
+
catch (error) {
|
|
66
|
+
// If we get a `MODULE_NOT_FOUND` error for what appears to be a module
|
|
67
|
+
// name, we try to resolve it a second time using `pluginsModulesPath`
|
|
68
|
+
// as the base directory.
|
|
69
|
+
if (error.code === 'MODULE_NOT_FOUND' && pluginsModulesPath && appearsToBeModuleName(specifier)) {
|
|
70
|
+
const newParent = (0, path_1.join)(pluginsModulesPath, (0, path_1.basename)(parent));
|
|
71
|
+
return await (0, resolve_dependency_1.default)(specifier, newParent, ...args);
|
|
84
72
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
const rewrites = yield (0, es_modules_1.transpileESM)({ basePath, config, esmPaths: esmFileList, fsCache, reasons });
|
|
89
|
-
return {
|
|
90
|
-
paths: normalizedDependencyPaths,
|
|
91
|
-
rewrites,
|
|
92
|
-
};
|
|
73
|
+
throw error;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
93
76
|
});
|
|
77
|
+
const normalizedDependencyPaths = [...dependencyPaths].map((path) => basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path));
|
|
78
|
+
const rewrites = await (0, es_modules_1.transpileESM)({ basePath, config, esmPaths: esmFileList, fsCache, reasons });
|
|
79
|
+
return {
|
|
80
|
+
paths: normalizedDependencyPaths,
|
|
81
|
+
rewrites,
|
|
82
|
+
};
|
|
94
83
|
};
|
|
95
|
-
const getSrcFiles = function ({ basePath, config, mainFile }) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return includedPaths;
|
|
103
|
-
});
|
|
84
|
+
const getSrcFiles = async function ({ basePath, config, mainFile }) {
|
|
85
|
+
const { includedFiles = [], includedFilesBasePath } = config;
|
|
86
|
+
const { exclude: excludedPaths, paths: includedFilePaths } = await (0, included_files_1.getPathsOfIncludedFiles)(includedFiles, includedFilesBasePath);
|
|
87
|
+
const { fileList: dependencyPaths } = await (0, nft_1.nodeFileTrace)([mainFile], { base: basePath, ignore: ignoreFunction });
|
|
88
|
+
const normalizedDependencyPaths = [...dependencyPaths].map((path) => basePath ? (0, path_1.resolve)(basePath, path) : (0, path_1.resolve)(path));
|
|
89
|
+
const includedPaths = (0, included_files_1.filterExcludedPaths)([...normalizedDependencyPaths, ...includedFilePaths], excludedPaths);
|
|
90
|
+
return includedPaths;
|
|
104
91
|
};
|
|
105
92
|
const bundler = { bundle, getSrcFiles };
|
|
106
93
|
exports.default = bundler;
|
|
@@ -1,22 +1,13 @@
|
|
|
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.transpile = void 0;
|
|
13
4
|
const esbuild_1 = require("@netlify/esbuild");
|
|
14
5
|
const bundler_target_1 = require("../esbuild/bundler_target");
|
|
15
|
-
const transpile = (path, config) =>
|
|
6
|
+
const transpile = async (path, config) => {
|
|
16
7
|
// The version of ECMAScript to use as the build target. This will determine
|
|
17
8
|
// whether certain features are transpiled down or left untransformed.
|
|
18
9
|
const nodeTarget = (0, bundler_target_1.getBundlerTarget)(config.nodeVersion);
|
|
19
|
-
const transpiled =
|
|
10
|
+
const transpiled = await (0, esbuild_1.build)({
|
|
20
11
|
bundle: false,
|
|
21
12
|
entryPoints: [path],
|
|
22
13
|
format: 'cjs',
|
|
@@ -27,6 +18,6 @@ const transpile = (path, config) => __awaiter(void 0, void 0, void 0, function*
|
|
|
27
18
|
write: false,
|
|
28
19
|
});
|
|
29
20
|
return transpiled.outputFiles[0].text;
|
|
30
|
-
}
|
|
21
|
+
};
|
|
31
22
|
exports.transpile = transpile;
|
|
32
23
|
//# sourceMappingURL=transpile.js.map
|
|
@@ -1,21 +1,15 @@
|
|
|
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 base_path_1 = require("../../utils/base_path");
|
|
14
5
|
const src_files_1 = require("./src_files");
|
|
15
|
-
const bundle = ({ basePath, config, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, runtime, srcDir, srcPath, stat, }) =>
|
|
16
|
-
const srcFiles =
|
|
6
|
+
const bundle = async ({ basePath, config, extension, featureFlags, filename, mainFile, name, pluginsModulesPath, runtime, srcDir, srcPath, stat, }) => {
|
|
7
|
+
const srcFiles = await (0, src_files_1.getSrcFiles)({
|
|
17
8
|
basePath,
|
|
18
|
-
config:
|
|
9
|
+
config: {
|
|
10
|
+
...config,
|
|
11
|
+
includedFilesBasePath: config.includedFilesBasePath || basePath,
|
|
12
|
+
},
|
|
19
13
|
extension,
|
|
20
14
|
featureFlags,
|
|
21
15
|
filename,
|
|
@@ -34,7 +28,7 @@ const bundle = ({ basePath, config, extension, featureFlags, filename, mainFile,
|
|
|
34
28
|
mainFile,
|
|
35
29
|
srcFiles,
|
|
36
30
|
};
|
|
37
|
-
}
|
|
31
|
+
};
|
|
38
32
|
const bundler = { bundle, getSrcFiles: src_files_1.getSrcFiles };
|
|
39
33
|
exports.default = bundler;
|
|
40
34
|
//# sourceMappingURL=index.js.map
|
|
@@ -18,15 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
18
18
|
__setModuleDefault(result, mod);
|
|
19
19
|
return result;
|
|
20
20
|
};
|
|
21
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
-
});
|
|
29
|
-
};
|
|
30
21
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
23
|
};
|
|
@@ -56,17 +47,17 @@ const getListImportsPlugin = ({ imports, path }) => ({
|
|
|
56
47
|
});
|
|
57
48
|
},
|
|
58
49
|
});
|
|
59
|
-
const listImports = ({ functionName, path }) =>
|
|
50
|
+
const listImports = async ({ functionName, path }) => {
|
|
60
51
|
// We're not interested in the output that esbuild generates, we're just
|
|
61
52
|
// using it for its parsing capabilities in order to find import/require
|
|
62
53
|
// statements. However, if we don't give esbuild a path in `outfile`, it
|
|
63
54
|
// will pipe the output to stdout, which we also don't want. So we create
|
|
64
55
|
// a temporary file to serve as the esbuild output and then get rid of it
|
|
65
56
|
// when we're done.
|
|
66
|
-
const targetPath =
|
|
57
|
+
const targetPath = await (0, tmp_promise_1.tmpName)();
|
|
67
58
|
const imports = new Set();
|
|
68
59
|
try {
|
|
69
|
-
|
|
60
|
+
await esbuild.build({
|
|
70
61
|
bundle: true,
|
|
71
62
|
entryPoints: [path],
|
|
72
63
|
logLevel: 'error',
|
|
@@ -87,9 +78,9 @@ const listImports = ({ functionName, path }) => __awaiter(void 0, void 0, void 0
|
|
|
87
78
|
throw error;
|
|
88
79
|
}
|
|
89
80
|
finally {
|
|
90
|
-
|
|
81
|
+
await (0, fs_1.safeUnlink)(targetPath);
|
|
91
82
|
}
|
|
92
83
|
return [...imports];
|
|
93
|
-
}
|
|
84
|
+
};
|
|
94
85
|
exports.listImports = listImports;
|
|
95
86
|
//# sourceMappingURL=list_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
|
};
|
|
@@ -17,17 +8,15 @@ const util_1 = require("util");
|
|
|
17
8
|
const glob_1 = __importDefault(require("glob"));
|
|
18
9
|
const pGlob = (0, util_1.promisify)(glob_1.default);
|
|
19
10
|
// We use all the files published by the Node.js except some that are not needed
|
|
20
|
-
const getPublishedFiles = function (modulePath) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
dot: true,
|
|
28
|
-
});
|
|
29
|
-
return publishedFiles;
|
|
11
|
+
const getPublishedFiles = async function (modulePath) {
|
|
12
|
+
const ignore = getIgnoredFiles(modulePath);
|
|
13
|
+
const publishedFiles = await pGlob(`${modulePath}/**`, {
|
|
14
|
+
ignore,
|
|
15
|
+
nodir: true,
|
|
16
|
+
absolute: true,
|
|
17
|
+
dot: true,
|
|
30
18
|
});
|
|
19
|
+
return publishedFiles;
|
|
31
20
|
};
|
|
32
21
|
exports.getPublishedFiles = getPublishedFiles;
|
|
33
22
|
const getIgnoredFiles = function (modulePath) {
|
|
@@ -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
|
};
|
|
@@ -26,30 +17,28 @@ const BACKSLASH_REGEXP = /\\/g;
|
|
|
26
17
|
// - this is important because if a file does a `require('./symlink')`, we
|
|
27
18
|
// need to bundle the symlink and its target, not only the target
|
|
28
19
|
// - `path.resolve()` cannot be used for relative|absolute file paths
|
|
29
|
-
// because it does not resolve
|
|
20
|
+
// because it does not resolve omitted file extension,
|
|
30
21
|
// e.g. `require('./file')` instead of `require('./file.js')`
|
|
31
22
|
// - the CLI flag `--preserve-symlinks` can be used with Node.js, but it
|
|
32
23
|
// cannot be set runtime
|
|
33
24
|
// However it does not give helpful error messages.
|
|
34
25
|
// https://github.com/browserify/resolve/issues/223
|
|
35
26
|
// So, on errors, we fallback to `require.resolve()`
|
|
36
|
-
const resolvePackage = function (moduleName, baseDirs) {
|
|
37
|
-
|
|
27
|
+
const resolvePackage = async function (moduleName, baseDirs) {
|
|
28
|
+
try {
|
|
29
|
+
return await resolvePathPreserveSymlinks(`${moduleName}/package.json`, baseDirs);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if ((0, semver_1.lt)(process_1.version, REQUEST_RESOLVE_MIN_VERSION)) {
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
38
35
|
try {
|
|
39
|
-
return
|
|
36
|
+
return resolvePathFollowSymlinks(`${moduleName}/package.json`, baseDirs);
|
|
40
37
|
}
|
|
41
|
-
catch (
|
|
42
|
-
|
|
43
|
-
throw error;
|
|
44
|
-
}
|
|
45
|
-
try {
|
|
46
|
-
return resolvePathFollowSymlinks(`${moduleName}/package.json`, baseDirs);
|
|
47
|
-
}
|
|
48
|
-
catch (error_) {
|
|
49
|
-
return yield resolvePackageFallback(moduleName, baseDirs, error_);
|
|
50
|
-
}
|
|
38
|
+
catch (error_) {
|
|
39
|
+
return await resolvePackageFallback(moduleName, baseDirs, error_);
|
|
51
40
|
}
|
|
52
|
-
}
|
|
41
|
+
}
|
|
53
42
|
};
|
|
54
43
|
exports.resolvePackage = resolvePackage;
|
|
55
44
|
// TODO: remove after dropping support for Node <8.9.0
|
|
@@ -72,20 +61,17 @@ const resolvePathPreserveSymlinksForDir = function (path, basedir) {
|
|
|
72
61
|
// the resolve library has a `paths` option but it's not the same as multiple basedirs
|
|
73
62
|
// see https://github.com/browserify/resolve/issues/188#issuecomment-679010477
|
|
74
63
|
// we return the first resolved location or the first error if all failed
|
|
75
|
-
const resolvePathPreserveSymlinks = function (path, baseDirs) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
// eslint-disable-next-line no-await-in-loop
|
|
81
|
-
return yield resolvePathPreserveSymlinksForDir(path, basedir);
|
|
82
|
-
}
|
|
83
|
-
catch (error) {
|
|
84
|
-
firstError = firstError || error;
|
|
85
|
-
}
|
|
64
|
+
const resolvePathPreserveSymlinks = async function (path, baseDirs) {
|
|
65
|
+
let firstError;
|
|
66
|
+
for (const basedir of baseDirs) {
|
|
67
|
+
try {
|
|
68
|
+
return await resolvePathPreserveSymlinksForDir(path, basedir);
|
|
86
69
|
}
|
|
87
|
-
|
|
88
|
-
|
|
70
|
+
catch (error) {
|
|
71
|
+
firstError = firstError || error;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
throw firstError;
|
|
89
75
|
};
|
|
90
76
|
exports.resolvePathPreserveSymlinks = resolvePathPreserveSymlinks;
|
|
91
77
|
const resolvePathFollowSymlinks = function (path, baseDirs) {
|
|
@@ -99,24 +85,20 @@ const resolvePathFollowSymlinks = function (path, baseDirs) {
|
|
|
99
85
|
// - has a `package.json`
|
|
100
86
|
// Theoretically, this might not the root `package.json`, but this is very
|
|
101
87
|
// unlikely, and we don't have any better alternative.
|
|
102
|
-
const resolvePackageFallback = function (moduleName, baseDirs, error) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
return packagePath;
|
|
110
|
-
});
|
|
88
|
+
const resolvePackageFallback = async function (moduleName, baseDirs, error) {
|
|
89
|
+
const mainFilePath = resolvePathFollowSymlinks(moduleName, baseDirs);
|
|
90
|
+
const packagePath = await (0, find_up_1.default)(isPackageDir.bind(null, moduleName), { cwd: mainFilePath, type: 'directory' });
|
|
91
|
+
if (packagePath === undefined) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
return packagePath;
|
|
111
95
|
};
|
|
112
|
-
const isPackageDir = function (moduleName, dir) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return dir;
|
|
120
|
-
});
|
|
96
|
+
const isPackageDir = async function (moduleName, dir) {
|
|
97
|
+
// Need to use `endsWith()` to take into account `@scope/package`.
|
|
98
|
+
// Backslashes need to be converted for Windows.
|
|
99
|
+
if (!dir.replace(BACKSLASH_REGEXP, '/').endsWith(moduleName) || !(await (0, path_exists_1.default)(`${dir}/package.json`))) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
return dir;
|
|
121
103
|
};
|
|
122
104
|
//# sourceMappingURL=resolve.js.map
|
|
@@ -1,26 +1,15 @@
|
|
|
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.getSideFiles = void 0;
|
|
13
4
|
const published_1 = require("./published");
|
|
14
5
|
// Some modules generate source files on `postinstall` that are not located
|
|
15
6
|
// inside the module's directory itself.
|
|
16
|
-
const getSideFiles = function (modulePath, moduleName) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return yield (0, published_1.getPublishedFiles)(`${modulePath}/${sideFiles}`);
|
|
23
|
-
});
|
|
7
|
+
const getSideFiles = async function (modulePath, moduleName) {
|
|
8
|
+
const sideFiles = SIDE_FILES[moduleName];
|
|
9
|
+
if (sideFiles === undefined) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
return await (0, published_1.getPublishedFiles)(`${modulePath}/${sideFiles}`);
|
|
24
13
|
};
|
|
25
14
|
exports.getSideFiles = getSideFiles;
|
|
26
15
|
const SIDE_FILES = {
|