Skip to content

Commit 044be69

Browse files
authored
refactor: remove zisi_unique_entry_file flag and code which used it as the flag no longer exists (#6349)
1 parent 5b7da6b commit 044be69

File tree

3 files changed

+6
-23
lines changed

3 files changed

+6
-23
lines changed

packages/zip-it-and-ship-it/src/feature_flags.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ export const defaultFlags = {
2121
// Output CJS file extension.
2222
zisi_output_cjs_extension: false,
2323

24-
// Create unique entry file instead of a file that is based on the function name.
25-
zisi_unique_entry_file: false,
26-
2724
// If multiple glob stars are in includedFiles, fail the build instead of warning.
2825
zisi_esbuild_fail_double_glob: false,
2926

packages/zip-it-and-ship-it/src/runtimes/node/utils/entry_file.ts

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,6 @@ const getEntryFileContents = (
6868
].join(';')
6969
}
7070

71-
if (featureFlags.zisi_unique_entry_file) {
72-
// we use dynamic import because we do not know if the user code is cjs or esm
73-
return [`const { handler } = await import('${importPath}')`, 'export { handler }'].join(';')
74-
}
75-
7671
if (moduleFormat === MODULE_FORMAT.COMMONJS) {
7772
return `module.exports = require('${importPath}')`
7873
}
@@ -92,18 +87,16 @@ export const isNamedLikeEntryFile = (
9287
file: string,
9388
{
9489
basePath,
95-
featureFlags,
9690
filename,
9791
runtimeAPIVersion,
9892
}: {
9993
basePath: string
100-
featureFlags: FeatureFlags
10194
filename: string
10295
runtimeAPIVersion: number
10396
},
10497
) =>
10598
POSSIBLE_LAMBDA_ENTRY_EXTENSIONS.some((extension) => {
106-
const entryFilename = getEntryFileName({ extension, featureFlags, filename, runtimeAPIVersion })
99+
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion })
107100
const entryFilePath = resolve(basePath, entryFilename)
108101

109102
return entryFilePath === file
@@ -115,14 +108,12 @@ export const conflictsWithEntryFile = (
115108
{
116109
basePath,
117110
extension,
118-
featureFlags,
119111
filename,
120112
mainFile,
121113
runtimeAPIVersion,
122114
}: {
123115
basePath: string
124116
extension: string
125-
featureFlags: FeatureFlags
126117
filename: string
127118
mainFile: string
128119
runtimeAPIVersion: number
@@ -143,13 +134,13 @@ export const conflictsWithEntryFile = (
143134

144135
// If we're generating a unique entry file, we know we don't have a conflict
145136
// at this point.
146-
if (featureFlags.zisi_unique_entry_file || runtimeAPIVersion === 2) {
137+
if (runtimeAPIVersion === 2) {
147138
return
148139
}
149140

150141
if (
151142
!hasConflict &&
152-
isNamedLikeEntryFile(srcFile, { basePath, featureFlags, filename, runtimeAPIVersion }) &&
143+
isNamedLikeEntryFile(srcFile, { basePath, filename, runtimeAPIVersion }) &&
153144
srcFile !== mainFile
154145
) {
155146
hasConflict = true
@@ -164,16 +155,14 @@ export const conflictsWithEntryFile = (
164155
// this it considers `<func-name>.(c|m)?js` as possible entry-points
165156
const getEntryFileName = ({
166157
extension,
167-
featureFlags,
168158
filename,
169159
runtimeAPIVersion,
170160
}: {
171161
extension: ModuleFileExtension
172-
featureFlags: FeatureFlags
173162
filename: string
174163
runtimeAPIVersion: number
175164
}) => {
176-
if (featureFlags.zisi_unique_entry_file || runtimeAPIVersion === 2) {
165+
if (runtimeAPIVersion === 2) {
177166
return `${ENTRY_FILE_NAME}.mjs`
178167
}
179168

@@ -233,7 +222,7 @@ export const getEntryFile = ({
233222
}): EntryFile => {
234223
const mainPath = normalizeFilePath({ commonPrefix, path: mainFile, userNamespace })
235224
const extension = getFileExtensionForFormat(moduleFormat, featureFlags, runtimeAPIVersion)
236-
const entryFilename = getEntryFileName({ extension, featureFlags, filename, runtimeAPIVersion })
225+
const entryFilename = getEntryFileName({ extension, filename, runtimeAPIVersion })
237226
const contents = getEntryFileContents(mainPath, moduleFormat, featureFlags, runtimeAPIVersion)
238227

239228
return {

packages/zip-it-and-ship-it/src/runtimes/node/utils/zip.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ const createDirectory = async function ({
9393
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
9494
basePath,
9595
extension,
96-
featureFlags,
9796
filename,
9897
mainFile,
9998
runtimeAPIVersion,
@@ -210,7 +209,6 @@ const createZipArchive = async function ({
210209
const hasEntryFileConflict = conflictsWithEntryFile(srcFiles, {
211210
basePath,
212211
extension,
213-
featureFlags,
214212
filename,
215213
mainFile,
216214
runtimeAPIVersion,
@@ -219,10 +217,9 @@ const createZipArchive = async function ({
219217
// We don't need an entry file if it would end up with the same path as the
220218
// function's main file. Unless we have a file conflict and need to move everything into a subfolder
221219
const needsEntryFile =
222-
featureFlags.zisi_unique_entry_file ||
223220
runtimeAPIVersion === 2 ||
224221
hasEntryFileConflict ||
225-
!isNamedLikeEntryFile(mainFile, { basePath, featureFlags, filename, runtimeAPIVersion })
222+
!isNamedLikeEntryFile(mainFile, { basePath, filename, runtimeAPIVersion })
226223

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

0 commit comments

Comments
 (0)