Skip to content

refactor: remove zisi_unique_entry_file flag and code which used it as the flag no longer exists #6349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions packages/zip-it-and-ship-it/src/feature_flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ export const defaultFlags = {
// Output CJS file extension.
zisi_output_cjs_extension: false,

// Create unique entry file instead of a file that is based on the function name.
zisi_unique_entry_file: false,

// If multiple glob stars are in includedFiles, fail the build instead of warning.
zisi_esbuild_fail_double_glob: false,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ const getEntryFileContents = (
].join(';')
}

if (featureFlags.zisi_unique_entry_file) {
// we use dynamic import because we do not know if the user code is cjs or esm
return [`const { handler } = await import('${importPath}')`, 'export { handler }'].join(';')
}

if (moduleFormat === MODULE_FORMAT.COMMONJS) {
return `module.exports = require('${importPath}')`
}
Expand All @@ -92,18 +87,16 @@ export const isNamedLikeEntryFile = (
file: string,
{
basePath,
featureFlags,
filename,
runtimeAPIVersion,
}: {
basePath: string
featureFlags: FeatureFlags
filename: string
runtimeAPIVersion: number
},
) =>
POSSIBLE_LAMBDA_ENTRY_EXTENSIONS.some((extension) => {
const entryFilename = getEntryFileName({ extension, featureFlags, filename, runtimeAPIVersion })
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion })
const entryFilePath = resolve(basePath, entryFilename)

return entryFilePath === file
Expand All @@ -115,14 +108,12 @@ export const conflictsWithEntryFile = (
{
basePath,
extension,
featureFlags,
filename,
mainFile,
runtimeAPIVersion,
}: {
basePath: string
extension: string
featureFlags: FeatureFlags
filename: string
mainFile: string
runtimeAPIVersion: number
Expand All @@ -143,13 +134,13 @@ export const conflictsWithEntryFile = (

// If we're generating a unique entry file, we know we don't have a conflict
// at this point.
if (featureFlags.zisi_unique_entry_file || runtimeAPIVersion === 2) {
if (runtimeAPIVersion === 2) {
return
}

if (
!hasConflict &&
isNamedLikeEntryFile(srcFile, { basePath, featureFlags, filename, runtimeAPIVersion }) &&
isNamedLikeEntryFile(srcFile, { basePath, filename, runtimeAPIVersion }) &&
srcFile !== mainFile
) {
hasConflict = true
Expand All @@ -164,16 +155,14 @@ export const conflictsWithEntryFile = (
// this it considers `<func-name>.(c|m)?js` as possible entry-points
const getEntryFileName = ({
extension,
featureFlags,
filename,
runtimeAPIVersion,
}: {
extension: ModuleFileExtension
featureFlags: FeatureFlags
filename: string
runtimeAPIVersion: number
}) => {
if (featureFlags.zisi_unique_entry_file || runtimeAPIVersion === 2) {
if (runtimeAPIVersion === 2) {
return `${ENTRY_FILE_NAME}.mjs`
}

Expand Down Expand Up @@ -233,7 +222,7 @@ export const getEntryFile = ({
}): EntryFile => {
const mainPath = normalizeFilePath({ commonPrefix, path: mainFile, userNamespace })
const extension = getFileExtensionForFormat(moduleFormat, featureFlags, runtimeAPIVersion)
const entryFilename = getEntryFileName({ extension, featureFlags, filename, runtimeAPIVersion })
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion })
const contents = getEntryFileContents(mainPath, moduleFormat, featureFlags, runtimeAPIVersion)

return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ const createDirectory = async function ({
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
basePath,
extension,
featureFlags,
filename,
mainFile,
runtimeAPIVersion,
Expand Down Expand Up @@ -210,7 +209,6 @@ const createZipArchive = async function ({
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
basePath,
extension,
featureFlags,
filename,
mainFile,
runtimeAPIVersion,
Expand All @@ -219,10 +217,9 @@ const createZipArchive = async function ({
// We don't need an entry file if it would end up with the same path as the
// function's main file. Unless we have a file conflict and need to move everything into a subfolder
const needsEntryFile =
featureFlags.zisi_unique_entry_file ||
runtimeAPIVersion === 2 ||
hasEntryFileConflict ||
!isNamedLikeEntryFile(mainFile, { basePath, featureFlags, filename, runtimeAPIVersion })
!isNamedLikeEntryFile(mainFile, { basePath, filename, runtimeAPIVersion })

// If there is a naming conflict, we move all user files (everything other
// than the entry file) to its own sub-directory.
Expand Down
Loading