@@ -23,6 +23,7 @@ const TMP = tmpdir();
23
23
// `chmod()` is required for usage with `vercel-dev-runtime`
24
24
// since file mode is not preserved in Vercel CLI deployments.
25
25
fs . chmodSync ( join ( __dirname , 'build.sh' ) , 0o755 ) ;
26
+ fs . chmodSync ( join ( __dirname , 'import.sh' ) , 0o755 ) ;
26
27
fs . chmodSync ( join ( __dirname , 'bootstrap' ) , 0o755 ) ;
27
28
28
29
const bootstrapPromise = FileFsRef . fromFsPath ( {
@@ -31,6 +32,9 @@ const bootstrapPromise = FileFsRef.fromFsPath({
31
32
const runtimePromise = FileFsRef . fromFsPath ( {
32
33
fsPath : join ( __dirname , 'runtime.sh' ) ,
33
34
} ) ;
35
+ const importPromise = FileFsRef . fromFsPath ( {
36
+ fsPath : join ( __dirname , 'import.sh' ) ,
37
+ } ) ;
34
38
const curlPromise = fetch (
35
39
'https://github.com/dtschan/curl-static/releases/download/v7.63.0/curl'
36
40
) . then ( async ( res ) => {
@@ -100,6 +104,7 @@ export const build: BuildV3 = async ({
100
104
IMPORT_TRACE ,
101
105
WORK_PATH : workPath ,
102
106
ENTRYPOINT : entrypoint ,
107
+ BUILDER_DIST : __dirname ,
103
108
} ;
104
109
105
110
const buildDir = await getWriteableDirectory ( ) ;
@@ -123,6 +128,7 @@ export const build: BuildV3 = async ({
123
128
) ) ,
124
129
bootstrap : await bootstrapPromise ,
125
130
'.import-cache/runtime.sh' : await runtimePromise ,
131
+ '.import-cache/bin/import' : await importPromise ,
126
132
'.import-cache/bin/curl' : await curlPromise ,
127
133
'.import-cache/bin/jq' : await jqPromise ,
128
134
// For now only the entrypoint file is copied into the lambda
@@ -157,19 +163,24 @@ export const build: BuildV3 = async ({
157
163
// - if symlink, then include if it points to a traced files
158
164
// - if not symlink, then always include in output
159
165
const binDir = join ( importCacheDir , 'bin' ) ;
160
- const bins = await fs . readdir ( binDir ) ;
166
+ let bins : string [ ] = [ ] ;
167
+ try {
168
+ bins = await fs . readdir ( binDir ) ;
169
+ } catch ( err : any ) {
170
+ if ( err . code !== 'ENOENT' ) throw err ;
171
+ }
161
172
for ( const bin of bins ) {
162
173
const binPath = join ( binDir , bin ) ;
163
174
const target = await fs . readlink ( binPath ) . catch ( ( err ) => {
164
- if ( err . code !== " EINVAL" ) throw err ;
175
+ if ( err . code !== ' EINVAL' ) throw err ;
165
176
} ) ;
166
177
if ( target ) {
167
178
const rel = relative ( importCacheDir , join ( binDir , target ) ) ;
168
- if ( ! lambdaFiles [ join ( " .import-cache" , rel ) ] ) {
179
+ if ( ! lambdaFiles [ join ( ' .import-cache' , rel ) ] ) {
169
180
continue ;
170
181
}
171
182
}
172
- lambdaFiles [ join ( " .import-cache/bin" , bin ) ] =
183
+ lambdaFiles [ join ( ' .import-cache/bin' , bin ) ] =
173
184
await FileFsRef . fromFsPath ( {
174
185
fsPath : binPath ,
175
186
} ) ;
0 commit comments