1
+ /* eslint-disable max-lines */
1
2
import os from 'os'
2
3
import process from 'process'
3
4
@@ -145,38 +146,50 @@ export const relocateBinaries = async (baseDir: string): Promise<void> => {
145
146
return
146
147
}
147
148
148
- let lmdbPath = findModuleFromBase ( {
149
+ // In v2.4.0 lmdb switched to scoped names for the platform binary packages (e.g: @lmdb/lmdb-linux-x64)
150
+ const scopedLmdbPath = findModuleFromBase ( {
149
151
paths : [ gatsbyPath , baseDir ] ,
150
- candidates : [ ' lmdb-store' ] ,
152
+ candidates : [ `@ lmdb/lmdb- ${ LAMBDA_PLATFORM } ` ] ,
151
153
} )
152
154
153
- if ( ! lmdbPath ) {
154
- const modulePath = findModuleFromBase ( {
155
+ let lmdbPath
156
+ if ( ! scopedLmdbPath ) {
157
+ lmdbPath = findModuleFromBase ( {
155
158
paths : [ gatsbyPath , baseDir ] ,
156
- candidates : [ 'lmdb' ] ,
159
+ candidates : [ 'lmdb-store ' ] ,
157
160
} )
158
- if ( modulePath ) {
159
- // The lmdb package resolves to a subdirectory of the module, and we need the root
160
- lmdbPath = dirname ( modulePath )
161
- } else {
162
- console . log ( `Could not find lmdb module in ${ gatsbyPath } ` )
163
- return
161
+
162
+ if ( ! lmdbPath ) {
163
+ const modulePath = findModuleFromBase ( {
164
+ paths : [ gatsbyPath , baseDir ] ,
165
+ candidates : [ 'lmdb' ] ,
166
+ } )
167
+ if ( modulePath ) {
168
+ // The lmdb package resolves to a subdirectory of the module, and we need the root
169
+ lmdbPath = dirname ( modulePath )
170
+ } else {
171
+ console . log ( `Could not find lmdb module in ${ gatsbyPath } ` )
172
+ return
173
+ }
164
174
}
165
175
}
166
176
167
177
console . log (
168
178
`Copying native binaries for ${ LAMBDA_PLATFORM } abi${ DEFAULT_LAMBDA_ABI } ` ,
169
179
)
170
- const lmdbPrebuilds = resolve ( lmdbPath , 'prebuilds' , LAMBDA_PLATFORM )
171
-
172
- const binaryTarget = resolve (
173
- baseDir ,
174
- '.cache' ,
175
- 'query-engine' ,
176
- 'assets' ,
177
- 'prebuilds' ,
178
- LAMBDA_PLATFORM ,
179
- )
180
+
181
+ const lmdbPrebuilds =
182
+ scopedLmdbPath || resolve ( lmdbPath , 'prebuilds' , LAMBDA_PLATFORM )
183
+ const binaryTarget = scopedLmdbPath
184
+ ? resolve ( baseDir , '.cache' , 'query-engine' , 'assets' , LAMBDA_PLATFORM )
185
+ : resolve (
186
+ baseDir ,
187
+ '.cache' ,
188
+ 'query-engine' ,
189
+ 'assets' ,
190
+ 'prebuilds' ,
191
+ LAMBDA_PLATFORM ,
192
+ )
180
193
await ensureDir ( binaryTarget )
181
194
182
195
for ( const binary of RELOCATABLE_BINARIES ) {
@@ -190,3 +203,4 @@ export const relocateBinaries = async (baseDir: string): Promise<void> => {
190
203
}
191
204
}
192
205
}
206
+ /* eslint-enable max-lines */
0 commit comments