@@ -4,9 +4,11 @@ import { Config, getConfigForFunction, FunctionWithoutConfig } from '../config.j
4
4
import { defaultFlags , FeatureFlags } from '../feature_flags.js'
5
5
import { FunctionSource } from '../function.js'
6
6
import type { RuntimeCache } from '../utils/cache.js'
7
+ import { FunctionBundlingUserError } from '../utils/error.js'
7
8
8
9
import goRuntime from './go/index.js'
9
10
import jsRuntime from './node/index.js'
11
+ import { ENTRY_FILE_NAME } from './node/utils/entry_file.js'
10
12
import type { Runtime } from './runtime.js'
11
13
import rustRuntime from './rust/index.js'
12
14
@@ -47,15 +49,27 @@ const findFunctionsInRuntime = async function ({
47
49
const key = dedupe ? 'name' : 'srcPath'
48
50
49
51
// Augmenting the function objects with additional information.
50
- const augmentedFunctions : FunctionTupleWithoutConfig [ ] = functions . map ( ( func ) => [
51
- func [ key ] ,
52
- {
53
- ...func ,
54
- extension : extname ( func . mainFile ) ,
55
- filename : basename ( func . srcPath ) ,
56
- runtime,
57
- } ,
58
- ] )
52
+ const augmentedFunctions : FunctionTupleWithoutConfig [ ] = functions . map ( ( func ) => {
53
+ if ( featureFlags . zisi_disallow_new_entry_name && func . name === ENTRY_FILE_NAME ) {
54
+ throw new FunctionBundlingUserError (
55
+ `'${ ENTRY_FILE_NAME } ' is a reserved word and cannot be used as a function name.` ,
56
+ {
57
+ functionName : func . name ,
58
+ runtime : runtime . name ,
59
+ } ,
60
+ )
61
+ }
62
+
63
+ return [
64
+ func [ key ] ,
65
+ {
66
+ ...func ,
67
+ extension : extname ( func . mainFile ) ,
68
+ filename : basename ( func . srcPath ) ,
69
+ runtime,
70
+ } ,
71
+ ]
72
+ } )
59
73
const usedPaths = new Set ( augmentedFunctions . map ( ( [ path ] ) => path ) )
60
74
const remainingPaths = paths . filter ( ( path ) => ! usedPaths . has ( path ) )
61
75
1 commit comments
github-actions[bot] commentedon Jan 31, 2023
⏱ Benchmark results