serverless-esbuild
Advanced tools
Comparing version 1.53.0 to 1.54.0
@@ -29,4 +29,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.bundle = void 0; | ||
exports.bundle = bundle; | ||
const assert_1 = __importDefault(require("assert")); | ||
const effect_1 = require("effect"); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
@@ -38,3 +39,3 @@ const p_map_1 = __importDefault(require("p-map")); | ||
const utils_1 = require("./utils"); | ||
const getStringArray = (input) => (0, helper_1.asArray)(input).filter(helper_1.isString); | ||
const getStringArray = (input) => (0, helper_1.asArray)(input).filter(effect_1.Predicate.isString); | ||
async function bundle() { | ||
@@ -151,3 +152,2 @@ (0, assert_1.default)(this.buildOptions, 'buildOptions is not defined'); | ||
} | ||
exports.bundle = bundle; | ||
//# sourceMappingURL=bundle.js.map |
@@ -5,3 +5,2 @@ import type Serverless from 'serverless'; | ||
export declare function asArray<T>(data: T | T[]): T[]; | ||
export declare const isString: (input: unknown) => input is string; | ||
export declare function assertIsString(input: unknown, message?: string): asserts input is string; | ||
@@ -48,4 +47,4 @@ export declare function extractFunctionEntries(cwd: string, provider: string, functions: Record<string, Serverless.FunctionDefinitionHandler>, resolveExtensions?: string[]): FunctionEntry[]; | ||
export declare function assertIsSupportedRuntime(input: unknown): asserts input is NodeMatcherKey; | ||
export declare const buildServerlessV3LoggerFromLegacyLogger: (legacyLogger: Serverless['cli'], verbose?: boolean) => ServerlessPlugin.Logging['log']; | ||
export declare const buildServerlessV3LoggerFromLegacyLogger: (legacyLogger: Serverless["cli"], verbose?: boolean) => ServerlessPlugin.Logging["log"]; | ||
export declare const stripEntryResolveExtensions: (file: IFile, extensions: string[]) => IFile; | ||
//# sourceMappingURL=helper.d.ts.map |
@@ -29,4 +29,9 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.stripEntryResolveExtensions = exports.buildServerlessV3LoggerFromLegacyLogger = exports.assertIsSupportedRuntime = exports.isNodeMatcherKey = exports.providerRuntimeMatcher = exports.doSharePath = exports.getDepsFromBundle = exports.isESM = exports.flatDep = exports.extractFunctionEntries = exports.assertIsString = exports.isString = exports.asArray = void 0; | ||
exports.stripEntryResolveExtensions = exports.buildServerlessV3LoggerFromLegacyLogger = exports.isNodeMatcherKey = exports.providerRuntimeMatcher = exports.doSharePath = exports.getDepsFromBundle = exports.isESM = exports.flatDep = void 0; | ||
exports.asArray = asArray; | ||
exports.assertIsString = assertIsString; | ||
exports.extractFunctionEntries = extractFunctionEntries; | ||
exports.assertIsSupportedRuntime = assertIsSupportedRuntime; | ||
const assert_1 = __importStar(require("assert")); | ||
const effect_1 = require("effect"); | ||
const os_1 = __importDefault(require("os")); | ||
@@ -42,11 +47,7 @@ const path_1 = __importDefault(require("path")); | ||
} | ||
exports.asArray = asArray; | ||
const isString = (input) => typeof input === 'string'; | ||
exports.isString = isString; | ||
function assertIsString(input, message = 'input is not a string') { | ||
if (!(0, exports.isString)(input)) { | ||
if (!effect_1.Predicate.isString(input)) { | ||
throw new assert_1.AssertionError({ message, actual: input }); | ||
} | ||
} | ||
exports.assertIsString = assertIsString; | ||
function extractFunctionEntries(cwd, provider, functions, resolveExtensions) { | ||
@@ -81,7 +82,8 @@ // The Google provider will use the entrypoint not from the definition of the | ||
(0, assert_1.default)(func, `${functionAlias} not found in functions`); | ||
const { handler } = func; | ||
const fnName = path_1.default.extname(handler); | ||
const fnNameLastAppearanceIndex = handler.lastIndexOf(fnName); | ||
const { handler, esbuildEntrypoint } = func; | ||
const entrypoint = esbuildEntrypoint || handler; | ||
const fnName = path_1.default.extname(entrypoint); | ||
const fnNameLastAppearanceIndex = entrypoint.lastIndexOf(fnName); | ||
// replace only last instance to allow the same name for file and handler | ||
const fileName = handler.substring(0, fnNameLastAppearanceIndex); | ||
const fileName = entrypoint.substring(0, fnNameLastAppearanceIndex); | ||
const extensions = resolveExtensions ?? constants_1.DEFAULT_EXTENSIONS; | ||
@@ -111,3 +113,2 @@ for (const extension of extensions) { | ||
} | ||
exports.extractFunctionEntries = extractFunctionEntries; | ||
/** | ||
@@ -196,3 +197,3 @@ * Takes a dependency graph and returns a flat list of required production dependencies for all or the filtered deps | ||
}); | ||
const baseDeps = deps.map(getBaseDep).filter(exports.isString); | ||
const baseDeps = deps.map(getBaseDep).filter(effect_1.Predicate.isString); | ||
return (0, ramda_1.uniq)(baseDeps); | ||
@@ -256,3 +257,2 @@ }; | ||
} | ||
exports.assertIsSupportedRuntime = assertIsSupportedRuntime; | ||
const buildServerlessV3LoggerFromLegacyLogger = (legacyLogger, verbose) => ({ | ||
@@ -259,0 +259,0 @@ error: legacyLogger.log.bind(legacyLogger), |
@@ -5,4 +5,5 @@ "use strict"; | ||
}; | ||
const assert_1 = __importDefault(require("assert")); | ||
const path_1 = __importDefault(require("path")); | ||
const node_assert_1 = __importDefault(require("node:assert")); | ||
const node_path_1 = __importDefault(require("node:path")); | ||
const effect_1 = require("effect"); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
@@ -131,4 +132,4 @@ const globby_1 = __importDefault(require("globby")); | ||
this.packageOutputPath = this.options.package || constants_1.SERVERLESS_FOLDER; | ||
this.workDirPath = path_1.default.join(this.serviceDirPath, this.outputWorkFolder); | ||
this.buildDirPath = path_1.default.join(this.workDirPath, this.outputBuildFolder); | ||
this.workDirPath = node_path_1.default.join(this.serviceDirPath, this.outputWorkFolder); | ||
this.buildDirPath = node_path_1.default.join(this.workDirPath, this.outputBuildFolder); | ||
} | ||
@@ -182,3 +183,3 @@ /** | ||
} | ||
const plugins = require(path_1.default.join(this.serviceDirPath, this.buildOptions.plugins)); | ||
const plugins = require(node_path_1.default.join(this.serviceDirPath, this.buildOptions.plugins)); | ||
if (typeof plugins === 'function') { | ||
@@ -202,3 +203,3 @@ return plugins(this.serverless); | ||
for (const fn of Object.values(this.functions)) { | ||
const fnPatterns = (0, helper_1.asArray)(fn.package?.patterns).filter(helper_1.isString); | ||
const fnPatterns = (0, helper_1.asArray)(fn.package?.patterns).filter(effect_1.Predicate.isString); | ||
for (const pattern of fnPatterns) { | ||
@@ -257,3 +258,3 @@ if (pattern.startsWith('!')) { | ||
const configPath = this.serverless.service.custom?.esbuild?.config; | ||
const config = configPath ? require(path_1.default.join(this.serviceDirPath, configPath)) : undefined; | ||
const config = configPath ? require(node_path_1.default.join(this.serviceDirPath, configPath)) : undefined; | ||
return withResolvedOptions(config ? config(this.serverless) : this.serverless.service.custom?.esbuild ?? {}); | ||
@@ -265,5 +266,5 @@ } | ||
watch() { | ||
(0, assert_1.default)(this.buildOptions, 'buildOptions is not defined'); | ||
const defaultPatterns = (0, helper_1.asArray)(this.buildOptions.watch.pattern).filter(helper_1.isString); | ||
const defaultIgnored = (0, helper_1.asArray)(this.buildOptions.watch.ignore).filter(helper_1.isString); | ||
(0, node_assert_1.default)(this.buildOptions, 'buildOptions is not defined'); | ||
const defaultPatterns = (0, helper_1.asArray)(this.buildOptions.watch.pattern).filter(effect_1.Predicate.isString); | ||
const defaultIgnored = (0, helper_1.asArray)(this.buildOptions.watch.ignore).filter(effect_1.Predicate.isString); | ||
const { patterns, ignored } = this.packagePatterns; | ||
@@ -286,3 +287,3 @@ const allPatterns = [...defaultPatterns, ...patterns]; | ||
fs_extra_1.default.mkdirpSync(this.buildDirPath); | ||
fs_extra_1.default.mkdirpSync(path_1.default.join(this.workDirPath, constants_1.SERVERLESS_FOLDER)); | ||
fs_extra_1.default.mkdirpSync(node_path_1.default.join(this.workDirPath, constants_1.SERVERLESS_FOLDER)); | ||
// exclude serverless-esbuild | ||
@@ -320,7 +321,7 @@ this.serverless.service.package = { | ||
const { service } = this.serverless; | ||
const patterns = (0, helper_1.asArray)(service.package.patterns).filter(helper_1.isString); | ||
const patterns = (0, helper_1.asArray)(service.package.patterns).filter(effect_1.Predicate.isString); | ||
if (patterns.length > 0 && | ||
(0, anymatch_1.default)(patterns.filter((pattern) => !pattern.startsWith('!')), filename)) { | ||
const destFileName = path_1.default.resolve(path_1.default.join(this.buildDirPath, filename)); | ||
updateFile(op, path_1.default.resolve(filename), destFileName); | ||
const destFileName = node_path_1.default.resolve(node_path_1.default.join(this.buildDirPath, filename)); | ||
updateFile(op, node_path_1.default.resolve(filename), destFileName); | ||
return; | ||
@@ -333,6 +334,6 @@ } | ||
if ((0, anymatch_1.default)((0, helper_1.asArray)(fn.package?.patterns) | ||
.filter(helper_1.isString) | ||
.filter(effect_1.Predicate.isString) | ||
.filter((pattern) => !pattern.startsWith('!')), filename)) { | ||
const destFileName = path_1.default.resolve(path_1.default.join(this.buildDirPath, `${constants_1.ONLY_PREFIX}${functionAlias}`, filename)); | ||
updateFile(op, path_1.default.resolve(filename), destFileName); | ||
const destFileName = node_path_1.default.resolve(node_path_1.default.join(this.buildDirPath, `${constants_1.ONLY_PREFIX}${functionAlias}`, filename)); | ||
updateFile(op, node_path_1.default.resolve(filename), destFileName); | ||
return; | ||
@@ -346,3 +347,3 @@ } | ||
const { service } = this.serverless; | ||
const packagePatterns = (0, helper_1.asArray)(service.package.patterns).filter(helper_1.isString); | ||
const packagePatterns = (0, helper_1.asArray)(service.package.patterns).filter(effect_1.Predicate.isString); | ||
// include any "extras" from the "patterns" section | ||
@@ -352,4 +353,4 @@ if (packagePatterns.length) { | ||
for (const filename of files) { | ||
const destFileName = path_1.default.resolve(path_1.default.join(this.buildDirPath, filename)); | ||
updateFile('add', path_1.default.resolve(filename), destFileName); | ||
const destFileName = node_path_1.default.resolve(node_path_1.default.join(this.buildDirPath, filename)); | ||
updateFile('add', node_path_1.default.resolve(filename), destFileName); | ||
} | ||
@@ -359,3 +360,3 @@ } | ||
for (const [functionAlias, fn] of Object.entries(this.functions)) { | ||
const patterns = (0, helper_1.asArray)(fn.package?.patterns).filter(helper_1.isString); | ||
const patterns = (0, helper_1.asArray)(fn.package?.patterns).filter(effect_1.Predicate.isString); | ||
if (!patterns.length) { | ||
@@ -366,4 +367,4 @@ continue; | ||
for (const filename of files) { | ||
const destFileName = path_1.default.resolve(path_1.default.join(this.buildDirPath, `${constants_1.ONLY_PREFIX}${functionAlias}`, filename)); | ||
updateFile('add', path_1.default.resolve(filename), destFileName); | ||
const destFileName = node_path_1.default.resolve(node_path_1.default.join(this.buildDirPath, `${constants_1.ONLY_PREFIX}${functionAlias}`, filename)); | ||
updateFile('add', node_path_1.default.resolve(filename), destFileName); | ||
} | ||
@@ -379,3 +380,3 @@ } | ||
const { service } = this.serverless; | ||
await fs_extra_1.default.copy(path_1.default.join(this.workDirPath, constants_1.SERVERLESS_FOLDER), path_1.default.join(this.serviceDirPath, constants_1.SERVERLESS_FOLDER)); | ||
await fs_extra_1.default.copy(node_path_1.default.join(this.workDirPath, constants_1.SERVERLESS_FOLDER), node_path_1.default.join(this.serviceDirPath, constants_1.SERVERLESS_FOLDER)); | ||
if (service.package.individually === true || this.options.function) { | ||
@@ -385,3 +386,3 @@ Object.values(this.functions).forEach((func) => { | ||
// eslint-disable-next-line no-param-reassign | ||
func.package.artifact = path_1.default.join(constants_1.SERVERLESS_FOLDER, path_1.default.basename(func.package.artifact)); | ||
func.package.artifact = node_path_1.default.join(constants_1.SERVERLESS_FOLDER, node_path_1.default.basename(func.package.artifact)); | ||
} | ||
@@ -391,3 +392,3 @@ }); | ||
} | ||
service.package.artifact = path_1.default.join(constants_1.SERVERLESS_FOLDER, path_1.default.basename(service.package.artifact)); | ||
service.package.artifact = node_path_1.default.join(constants_1.SERVERLESS_FOLDER, node_path_1.default.basename(service.package.artifact)); | ||
} | ||
@@ -406,3 +407,3 @@ async disposeContexts() { | ||
(0, helper_1.assertIsString)(this.workDirPath, 'workDirPath is not a string'); | ||
fs_extra_1.default.removeSync(path_1.default.join(this.workDirPath)); | ||
fs_extra_1.default.removeSync(node_path_1.default.join(this.workDirPath)); | ||
} | ||
@@ -409,0 +410,0 @@ } |
@@ -29,3 +29,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.packExternalModules = exports.nodeExternalsPluginUtilsPath = void 0; | ||
exports.nodeExternalsPluginUtilsPath = nodeExternalsPluginUtilsPath; | ||
exports.packExternalModules = packExternalModules; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -149,3 +150,2 @@ const path_1 = __importDefault(require("path")); | ||
} | ||
exports.nodeExternalsPluginUtilsPath = nodeExternalsPluginUtilsPath; | ||
/** | ||
@@ -288,3 +288,2 @@ * We need a performant algorithm to install the packages for each single | ||
} | ||
exports.packExternalModules = packExternalModules; | ||
//# sourceMappingURL=pack-externals.js.map |
@@ -6,3 +6,5 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.copyPreBuiltResources = exports.pack = exports.filterFilesForZipPackage = void 0; | ||
exports.filterFilesForZipPackage = void 0; | ||
exports.pack = pack; | ||
exports.copyPreBuiltResources = copyPreBuiltResources; | ||
const assert_1 = __importDefault(require("assert")); | ||
@@ -177,3 +179,2 @@ const path_1 = __importDefault(require("path")); | ||
} | ||
exports.pack = pack; | ||
async function copyPreBuiltResources() { | ||
@@ -210,3 +211,2 @@ this.log.verbose('Copying Prebuilt resources'); | ||
} | ||
exports.copyPreBuiltResources = copyPreBuiltResources; | ||
//# sourceMappingURL=pack.js.map |
@@ -27,6 +27,6 @@ "use strict"; | ||
exports.NPM = void 0; | ||
const effect_1 = require("effect"); | ||
const ramda_1 = require("ramda"); | ||
const path = __importStar(require("path")); | ||
const utils_1 = require("../utils"); | ||
const helper_1 = require("../helper"); | ||
/** | ||
@@ -65,6 +65,6 @@ * NPM packager. | ||
'-json', | ||
prodFlag, | ||
prodFlag, // Only prod dependencies | ||
'-long', | ||
depth ? `-depth=${depth}` : noDepthFlag, | ||
].filter(helper_1.isString); | ||
].filter(effect_1.Predicate.isString); | ||
const ignoredNpmErrors = [ | ||
@@ -71,0 +71,0 @@ { npmError: 'extraneous', log: false }, |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Pnpm = void 0; | ||
const effect_1 = require("effect"); | ||
const ramda_1 = require("ramda"); | ||
const helper_1 = require("../helper"); | ||
const utils_1 = require("../utils"); | ||
@@ -25,6 +25,6 @@ /** | ||
'ls', | ||
'--prod', | ||
'--prod', // Only prod dependencies | ||
'--json', | ||
depth ? `--depth=${depth}` : null, | ||
].filter(helper_1.isString); | ||
].filter(effect_1.Predicate.isString); | ||
// If we need to ignore some errors add them here | ||
@@ -31,0 +31,0 @@ const ignoredPnpmErrors = []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Yarn = void 0; | ||
const effect_1 = require("effect"); | ||
const ramda_1 = require("ramda"); | ||
const semver_1 = require("semver"); | ||
const utils_1 = require("../utils"); | ||
const helper_1 = require("../helper"); | ||
const getNameAndVersion = (name) => { | ||
@@ -46,3 +46,3 @@ const atIndex = name.lastIndexOf('@'); | ||
const command = /^win/.test(process.platform) ? 'yarn.cmd' : 'yarn'; | ||
const args = ['list', depth ? `--depth=${depth}` : null, '--json', '--production'].filter(helper_1.isString); | ||
const args = ['list', depth ? `--depth=${depth}` : null, '--json', '--production'].filter(effect_1.Predicate.isString); | ||
// If we need to ignore some errors add them here | ||
@@ -49,0 +49,0 @@ const ignoredYarnErrors = []; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preLocal = void 0; | ||
exports.preLocal = preLocal; | ||
const helper_1 = require("./helper"); | ||
@@ -14,3 +14,2 @@ function preLocal() { | ||
} | ||
exports.preLocal = preLocal; | ||
//# sourceMappingURL=pre-local.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.preOffline = void 0; | ||
exports.preOffline = preOffline; | ||
const path_1 = require("path"); | ||
@@ -15,3 +15,2 @@ const ramda_1 = require("ramda"); | ||
} | ||
exports.preOffline = preOffline; | ||
//# sourceMappingURL=pre-offline.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isPackagerId = void 0; | ||
exports.isPackagerId = isPackagerId; | ||
function isPackagerId(input) { | ||
return input === 'npm' || input === 'pnpm' || input === 'yarn'; | ||
} | ||
exports.isPackagerId = isPackagerId; | ||
//# sourceMappingURL=type-predicate.js.map |
@@ -49,2 +49,3 @@ import type { WatchOptions } from 'chokidar'; | ||
skipEsbuild: boolean; | ||
esbuildEntrypoint?: string; | ||
} | ||
@@ -51,0 +52,0 @@ export interface FunctionEntry { |
@@ -29,14 +29,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isEmpty = exports.trimExtension = exports.zip = exports.humanSize = exports.findProjectRoot = exports.findUp = exports.spawnProcess = exports.SpawnError = void 0; | ||
exports.isEmpty = exports.zip = exports.humanSize = exports.findProjectRoot = exports.findUp = exports.SpawnError = void 0; | ||
exports.spawnProcess = spawnProcess; | ||
exports.trimExtension = trimExtension; | ||
const platform_node_1 = require("@effect/platform-node"); | ||
const archiver_1 = __importDefault(require("archiver")); | ||
const bestzip_1 = require("bestzip"); | ||
const archiver_1 = __importDefault(require("archiver")); | ||
const effect_1 = require("effect"); | ||
const execa_1 = __importDefault(require("execa")); | ||
const function_1 = require("fp-ts/lib/function"); | ||
const IO = __importStar(require("fp-ts/lib/IO")); | ||
const IOO = __importStar(require("fp-ts/lib/IOOption")); | ||
const TE = __importStar(require("fp-ts/lib/TaskEither")); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const path_1 = __importDefault(require("path")); | ||
const os_1 = __importDefault(require("os")); | ||
const fp_fs_1 = require("./utils/fp-fs"); | ||
const effect_fs_1 = __importStar(require("./utils/effect-fs")); | ||
class SpawnError extends Error { | ||
@@ -64,16 +63,18 @@ constructor(message, stdout, stderr) { | ||
} | ||
exports.spawnProcess = spawnProcess; | ||
const rootOf = (p) => path_1.default.parse(path_1.default.resolve(p)).root; | ||
const isPathRoot = (p) => rootOf(p) === path_1.default.resolve(p); | ||
const findUpIO = (names, directory = process.cwd()) => (0, function_1.pipe)(path_1.default.resolve(directory), (dir) => (0, function_1.pipe)(IO.sequenceArray(names.map((name) => (0, fp_fs_1.safeFileExistsIO)(path_1.default.join(dir, name)))), IO.chain((exist) => { | ||
if (exist.some(Boolean)) | ||
return IOO.some(dir); | ||
if (isPathRoot(dir)) | ||
return IOO.none; | ||
return findUpIO(names, path_1.default.dirname(dir)); | ||
}))); | ||
const findUpEffect = (names, directory = process.cwd()) => { | ||
const dir = path_1.default.resolve(directory); | ||
return effect_1.Effect.all(names.map((name) => (0, effect_fs_1.safeFileExists)(path_1.default.join(dir, name)))).pipe(effect_1.Effect.flatMap((exist) => { | ||
if (exist.some(Boolean)) | ||
return effect_1.Option.some(dir); | ||
if (isPathRoot(dir)) | ||
return effect_1.Option.none(); | ||
return findUpEffect(names, path_1.default.dirname(dir)); | ||
})); | ||
}; | ||
/** | ||
* Find a file by walking up parent directories | ||
*/ | ||
const findUp = (name) => (0, function_1.pipe)(findUpIO([name]), IOO.toUndefined)(); | ||
const findUp = (name) => findUpEffect([name]).pipe(effect_1.Effect.orElseSucceed(() => undefined), effect_1.Effect.provide(effect_fs_1.FSyncLayer), effect_1.Effect.runSync); | ||
exports.findUp = findUp; | ||
@@ -83,3 +84,3 @@ /** | ||
*/ | ||
const findProjectRoot = (rootDir) => (0, function_1.pipe)(IOO.fromNullable(rootDir), IOO.fold(() => findUpIO(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json']), IOO.of), IOO.toUndefined)(); | ||
const findProjectRoot = (rootDir) => effect_1.Effect.fromNullable(rootDir).pipe(effect_1.Effect.orElse(() => findUpEffect(['yarn.lock', 'pnpm-lock.yaml', 'package-lock.json'])), effect_1.Effect.orElseSucceed(() => undefined), effect_1.Effect.provide(effect_fs_1.FSyncLayer), effect_1.Effect.runSync); | ||
exports.findProjectRoot = findProjectRoot; | ||
@@ -94,19 +95,14 @@ const humanSize = (size) => { | ||
// create a temporary directory to hold the final zip structure | ||
const tempDirName = `${path_1.default.basename(zipPath).slice(0, -4)}-${Date.now().toString()}`; | ||
const tempDirPath = path_1.default.join(os_1.default.tmpdir(), tempDirName); | ||
const copyFileTask = (file) => (0, fp_fs_1.copyTask)(file.rootPath, path_1.default.join(tempDirPath, file.localPath)); | ||
const copyFilesTask = TE.traverseArray(copyFileTask); | ||
const bestZipTask = (0, fp_fs_1.taskFromPromise)(() => (0, bestzip_1.bestzip)({ source: '*', destination: zipPath, cwd: tempDirPath })); | ||
const nodeZipTask = (0, fp_fs_1.taskFromPromise)(() => nodeZip(zipPath, filesPathList)); | ||
await (0, function_1.pipe)( | ||
// create the random temporary folder | ||
(0, fp_fs_1.mkdirpTask)(tempDirPath), | ||
const tempDirName = `${path_1.default.basename(zipPath, path_1.default.extname(zipPath))}-${Date.now().toString()}`; | ||
const copyFileEffect = (temp) => (file) => effect_fs_1.default.copy(file.rootPath, path_1.default.join(temp, file.localPath)); | ||
const bestZipEffect = (temp) => effect_1.Effect.tryPromise(() => (0, bestzip_1.bestzip)({ source: '*', destination: zipPath, cwd: temp })); | ||
const nodeZipEffect = effect_1.Effect.tryPromise(() => nodeZip(zipPath, filesPathList)); | ||
const archiveEffect = (0, effect_fs_1.makeTempPathScoped)(tempDirName).pipe( | ||
// copy all required files from origin path to (sometimes modified) target path | ||
TE.chain(() => copyFilesTask(filesPathList)), | ||
effect_1.Effect.tap((temp) => effect_1.Effect.all(filesPathList.map(copyFileEffect(temp)), { discard: true })), | ||
// prepare zip folder | ||
TE.chain(() => (0, fp_fs_1.mkdirpTask)(path_1.default.dirname(zipPath))), | ||
effect_1.Effect.tap(() => (0, effect_fs_1.makePath)(path_1.default.dirname(zipPath))), | ||
// zip the temporary directory | ||
TE.chain(() => (useNativeZip ? bestZipTask : nodeZipTask)), | ||
// delete the temporary folder | ||
TE.chain(() => (0, fp_fs_1.removeTask)(tempDirPath)), fp_fs_1.taskEitherToPromise); | ||
effect_1.Effect.andThen((temp) => (useNativeZip ? bestZipEffect(temp) : nodeZipEffect)), effect_1.Effect.scoped); | ||
await archiveEffect.pipe(effect_1.Effect.provide(platform_node_1.NodeFileSystem.layer), effect_1.Effect.runPromise); | ||
}; | ||
@@ -140,3 +136,2 @@ exports.zip = zip; | ||
} | ||
exports.trimExtension = trimExtension; | ||
const isEmpty = (obj) => { | ||
@@ -143,0 +138,0 @@ // eslint-disable-next-line no-unreachable-loop |
{ | ||
"name": "serverless-esbuild", | ||
"version": "1.53.0", | ||
"version": "1.54.0", | ||
"description": "Serverless plugin for zero-config JavaScript and TypeScript code bundling using extremely fast esbuild", | ||
@@ -56,2 +56,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@effect/platform": "^0.65.5", | ||
"@effect/platform-node": "^0.60.5", | ||
"acorn": "^8.8.1", | ||
@@ -63,4 +65,4 @@ "acorn-walk": "^8.2.0", | ||
"chokidar": "^3.5.3", | ||
"effect": "^3.8.3", | ||
"execa": "^5.1.1", | ||
"fp-ts": "^2.13.1", | ||
"fs-extra": "^11.1.0", | ||
@@ -75,4 +77,4 @@ "globby": "^11.0.4", | ||
"@commitlint/config-conventional": "^17.3.0", | ||
"@floydspace/eslint-config": "^1.36.5", | ||
"@floydspace/prettier-config": "^1.36.4", | ||
"@floydspace/eslint-config": "^1.37.0", | ||
"@floydspace/prettier-config": "^1.37.0", | ||
"@types/archiver": "^5.3.1", | ||
@@ -87,5 +89,5 @@ "@types/fs-extra": "^9.0.13", | ||
"all-contributors-cli": "^6.24.0", | ||
"esbuild": "^0.23.1", | ||
"esbuild": "^0.24.0", | ||
"esbuild-node-externals": "^1.14.0", | ||
"eslint": "^8.30.0", | ||
"eslint": "^8.56.0", | ||
"extract-zip": "^2.0.1", | ||
@@ -99,7 +101,7 @@ "husky": "^8.0.2", | ||
"semantic-release": "^19.0.5", | ||
"ts-jest": "^29.0.3", | ||
"typescript": "^4.9.4" | ||
"ts-jest": "^29.2.5", | ||
"typescript": "~5.5.4" | ||
}, | ||
"peerDependencies": { | ||
"esbuild": ">=0.8 <0.24", | ||
"esbuild": "0.8 - 0.24", | ||
"esbuild-node-externals": "^1.0.0" | ||
@@ -114,3 +116,7 @@ }, | ||
"node": ">=18.0.0" | ||
}, | ||
"overrides": { | ||
"esbuild": "$esbuild", | ||
"eslint": "$eslint" | ||
} | ||
} |
@@ -285,2 +285,12 @@ # 💨 serverless-esbuild | ||
### Specify a custom entrypoint for a function | ||
You can specify a custom entrypoint for ESBuild by specifying the `esbuildEntrypoint` field in your function definition. | ||
```typescript | ||
export const myLambdaFunction = { | ||
handler: '/opt/nodejs/node_modules/my_custom_extension/handler.handler', | ||
esbuildEntrypoint: './handler.main', | ||
}; | ||
``` | ||
### Serverless Offline | ||
@@ -287,0 +297,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
251890
405
17
2629
+ Added@effect/platform@^0.65.5
+ Addedeffect@^3.8.3
+ Added@effect/platform@0.65.5(transitive)
+ Added@effect/platform-node@0.60.5(transitive)
+ Added@effect/platform-node-shared@0.15.5(transitive)
+ Added@effect/schema@0.73.4(transitive)
+ Added@esbuild/aix-ppc64@0.24.2(transitive)
+ Added@esbuild/android-arm@0.24.2(transitive)
+ Added@esbuild/android-arm64@0.24.2(transitive)
+ Added@esbuild/android-x64@0.24.2(transitive)
+ Added@esbuild/darwin-arm64@0.24.2(transitive)
+ Added@esbuild/darwin-x64@0.24.2(transitive)
+ Added@esbuild/freebsd-arm64@0.24.2(transitive)
+ Added@esbuild/freebsd-x64@0.24.2(transitive)
+ Added@esbuild/linux-arm@0.24.2(transitive)
+ Added@esbuild/linux-arm64@0.24.2(transitive)
+ Added@esbuild/linux-ia32@0.24.2(transitive)
+ Added@esbuild/linux-loong64@0.24.2(transitive)
+ Added@esbuild/linux-mips64el@0.24.2(transitive)
+ Added@esbuild/linux-ppc64@0.24.2(transitive)
+ Added@esbuild/linux-riscv64@0.24.2(transitive)
+ Added@esbuild/linux-s390x@0.24.2(transitive)
+ Added@esbuild/linux-x64@0.24.2(transitive)
+ Added@esbuild/netbsd-arm64@0.24.2(transitive)
+ Added@esbuild/netbsd-x64@0.24.2(transitive)
+ Added@esbuild/openbsd-arm64@0.24.2(transitive)
+ Added@esbuild/openbsd-x64@0.24.2(transitive)
+ Added@esbuild/sunos-x64@0.24.2(transitive)
+ Added@esbuild/win32-arm64@0.24.2(transitive)
+ Added@esbuild/win32-ia32@0.24.2(transitive)
+ Added@esbuild/win32-x64@0.24.2(transitive)
+ Added@parcel/watcher@2.5.1(transitive)
+ Added@parcel/watcher-android-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-arm64@2.5.1(transitive)
+ Added@parcel/watcher-darwin-x64@2.5.1(transitive)
+ Added@parcel/watcher-freebsd-x64@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-arm64-musl@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-glibc@2.5.1(transitive)
+ Added@parcel/watcher-linux-x64-musl@2.5.1(transitive)
+ Added@parcel/watcher-win32-arm64@2.5.1(transitive)
+ Added@parcel/watcher-win32-ia32@2.5.1(transitive)
+ Added@parcel/watcher-win32-x64@2.5.1(transitive)
+ Added@standard-schema/spec@1.0.0(transitive)
+ Addeddetect-libc@1.0.3(transitive)
+ Addedeffect@3.13.8(transitive)
+ Addedesbuild@0.24.2(transitive)
+ Addedfast-check@3.23.2(transitive)
+ Addedfind-my-way-ts@0.1.5(transitive)
+ Addedmime@3.0.0(transitive)
+ Addedmultipasta@0.2.5(transitive)
+ Addednode-addon-api@7.1.1(transitive)
+ Addedpure-rand@6.1.0(transitive)
+ Addedundici@6.21.1(transitive)
+ Addedws@8.18.1(transitive)
- Removedfp-ts@^2.13.1
- Removed@esbuild/aix-ppc64@0.23.1(transitive)
- Removed@esbuild/android-arm@0.23.1(transitive)
- Removed@esbuild/android-arm64@0.23.1(transitive)
- Removed@esbuild/android-x64@0.23.1(transitive)
- Removed@esbuild/darwin-arm64@0.23.1(transitive)
- Removed@esbuild/darwin-x64@0.23.1(transitive)
- Removed@esbuild/freebsd-arm64@0.23.1(transitive)
- Removed@esbuild/freebsd-x64@0.23.1(transitive)
- Removed@esbuild/linux-arm@0.23.1(transitive)
- Removed@esbuild/linux-arm64@0.23.1(transitive)
- Removed@esbuild/linux-ia32@0.23.1(transitive)
- Removed@esbuild/linux-loong64@0.23.1(transitive)
- Removed@esbuild/linux-mips64el@0.23.1(transitive)
- Removed@esbuild/linux-ppc64@0.23.1(transitive)
- Removed@esbuild/linux-riscv64@0.23.1(transitive)
- Removed@esbuild/linux-s390x@0.23.1(transitive)
- Removed@esbuild/linux-x64@0.23.1(transitive)
- Removed@esbuild/netbsd-x64@0.23.1(transitive)
- Removed@esbuild/openbsd-arm64@0.23.1(transitive)
- Removed@esbuild/openbsd-x64@0.23.1(transitive)
- Removed@esbuild/sunos-x64@0.23.1(transitive)
- Removed@esbuild/win32-arm64@0.23.1(transitive)
- Removed@esbuild/win32-ia32@0.23.1(transitive)
- Removed@esbuild/win32-x64@0.23.1(transitive)
- Removedesbuild@0.23.1(transitive)
- Removedfp-ts@2.16.9(transitive)