@vercel/static-build
Advanced tools
Comparing version 0.17.12 to 0.17.13-canary.0
@@ -6,9 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.readBuildOutputDirectory = exports.writePackageJson = exports.readPackageJson = exports.fileExists = void 0; | ||
exports.isObjectEmpty = exports.writePackageJson = exports.readPackageJson = exports.fileExists = void 0; | ||
const fs_1 = require("fs"); | ||
const build_utils_1 = require("@vercel/build-utils"); | ||
const launcher_1 = require("../launcher"); | ||
const build_utils_2 = __importDefault(require("../build-utils")); | ||
const path_1 = __importDefault(require("path")); | ||
const { createLambda, debug, getLatestNodeVersion, glob } = build_utils_2.default; | ||
async function fileExists(path) { | ||
@@ -38,51 +34,8 @@ return fs_1.promises.access(path, fs_1.constants.F_OK).then(() => true, () => false); | ||
exports.writePackageJson = writePackageJson; | ||
/** | ||
* Reads the .vercel_build_output directory and returns and object | ||
* that should be merged with the build outputs. | ||
* | ||
* At the moment only `functions/node` is supported. | ||
*/ | ||
async function readBuildOutputDirectory({ workPath, }) { | ||
const output = {}; | ||
const nodeFunctionPath = path_1.default.join(workPath, '.vercel_build_output', 'functions', 'node'); | ||
const nodeFunctionFiles = await glob('**/index.js', { | ||
cwd: nodeFunctionPath, | ||
}); | ||
const nodeBridgeData = await fs_1.promises.readFile(path_1.default.join(__dirname, 'bridge.js')); | ||
for (const fileName of Object.keys(nodeFunctionFiles)) { | ||
const launcherFileName = '___now_launcher'; | ||
const bridgeFileName = '___now_bridge'; | ||
const launcherFiles = { | ||
[`${launcherFileName}.js`]: new build_utils_1.FileBlob({ | ||
data: launcher_1.makeNowLauncher({ | ||
entrypointPath: `./index.js`, | ||
bridgePath: `./${bridgeFileName}`, | ||
helpersPath: '', | ||
sourcemapSupportPath: '', | ||
shouldAddHelpers: false, | ||
shouldAddSourcemapSupport: false, | ||
}), | ||
}), | ||
[`${bridgeFileName}.js`]: new build_utils_1.FileBlob({ | ||
data: nodeBridgeData, | ||
}), | ||
}; | ||
const requiredFiles = await glob('**', { | ||
cwd: path_1.default.join(nodeFunctionPath, path_1.default.dirname(fileName)), | ||
}); | ||
const lambda = await createLambda({ | ||
files: { | ||
...requiredFiles, | ||
...launcherFiles, | ||
}, | ||
handler: `${launcherFileName}.launcher`, | ||
runtime: getLatestNodeVersion().runtime, | ||
}); | ||
const parsed = path_1.default.parse(fileName); | ||
const newPath = path_1.default.join(parsed.dir, parsed.name); | ||
output[newPath] = lambda; | ||
debug(`Created Lambda "${newPath}" from "${path_1.default.join(nodeFunctionPath, fileName)}".`); | ||
function isObjectEmpty(object) { | ||
for (const _prop in object) { | ||
return false; | ||
} | ||
return { output }; | ||
return true; | ||
} | ||
exports.readBuildOutputDirectory = readBuildOutputDirectory; | ||
exports.isObjectEmpty = isObjectEmpty; |
{ | ||
"name": "@vercel/static-build", | ||
"version": "0.17.12", | ||
"version": "0.17.13-canary.0", | ||
"license": "MIT", | ||
@@ -34,3 +34,3 @@ "main": "./dist/index", | ||
}, | ||
"gitHead": "a2c56425f426272364bc39abde6e8cb82267b3ad" | ||
"gitHead": "4205d643a17d1b717b6dad6430462ae5196df591" | ||
} |
Sorry, the diff of this file is too big to display
568308
10
9339
42