File tree Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Expand file tree Collapse file tree 4 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -61,5 +61,8 @@ RUN find /nodejs/node_modules -name "*.cjs.map" -delete
6161RUN find /nodejs/node_modules -name "*.ts.map" -delete
6262RUN find /nodejs/node_modules -name "*.md" -delete
6363
64+ # Warm up compile cache
65+ RUN node -e "require('/nodejs/node_modules/datadog-lambda-js/runtime/module_importer').initTracer()"
66+
6467FROM scratch
6568COPY --from=builder /nodejs /
Original file line number Diff line number Diff line change 4343 "hot-shots" : " 8.5.0" ,
4444 "promise-retry" : " ^2.0.1" ,
4545 "serialize-error" : " ^8.1.0" ,
46- "shimmer" : " 1.2.1"
46+ "shimmer" : " 1.2.1" ,
47+ "v8-compile-cache" : " ^2.4.0"
4748 },
4849 "jest" : {
4950 "verbose" : true ,
Original file line number Diff line number Diff line change 11
22const { logDebug, updateDDTags } = require ( "../utils" ) ;
33
4+ function compileCache ( ) {
5+ const { FileSystemBlobStore, NativeCompileCache } = require ( 'v8-compile-cache' ) . __TEST__
6+
7+ const cacheDir = __dirname
8+ const prefix = 'module_importer'
9+ const blobStore = new FileSystemBlobStore ( cacheDir , prefix )
10+
11+ const nativeCompileCache = new NativeCompileCache ( )
12+ nativeCompileCache . setCacheStore ( blobStore )
13+ nativeCompileCache . install ( )
14+
15+ process . once ( 'exit' , ( ) => {
16+ if ( blobStore . isDirty ( ) ) {
17+ blobStore . save ( )
18+ }
19+ nativeCompileCache . uninstall ( )
20+ } )
21+ }
22+
423// Currently no way to prevent typescript from auto-transpiling import into require,
524// so we expose a wrapper in js
625exports . import = function ( path ) {
726 return import ( path ) ;
827}
928
1029exports . initTracer = function ( ) {
30+ compileCache ( )
31+
1132 // Looks for the function local version of dd-trace first, before using
1233 // the version provided by the layer
1334 const path = require . resolve ( "dd-trace" , { paths : [ "/var/task/node_modules" , ...module . paths ] } ) ;
Original file line number Diff line number Diff line change @@ -4075,6 +4075,11 @@ uuid@^9.0.1:
40754075 resolved "https://registry.yarnpkg.com/uuid/-/uuid-9.0.1.tgz#e188d4c8853cc722220392c424cd637f32293f30"
40764076 integrity sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA==
40774077
4078+ v8-compile-cache@^2.4.0 :
4079+ version "2.4.0"
4080+ resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.4.0.tgz#cdada8bec61e15865f05d097c5f4fd30e94dc128"
4081+ integrity sha512-ocyWc3bAHBB/guyqJQVI5o4BZkPhznPYUG2ea80Gond/BgNWpap8TOmLSeeQG7bnh2KMISxskdADG59j7zruhw==
4082+
40784083v8-to-istanbul@^8.1.0 :
40794084 version "8.1.1"
40804085 resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz#77b752fd3975e31bbcef938f85e9bd1c7a8d60ed"
You can’t perform that action at this time.
0 commit comments