File tree Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Expand file tree Collapse file tree 1 file changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -174,10 +174,24 @@ export class LayerPublisherStack extends Stack {
174174 . join ( ' ' ) } `
175175 ) ;
176176
177- // Phase 5: Copy files from tmp folder to cdk.out asset folder (the folder is created by CDK)
177+ // Phase 5: patch require keyword in ESM Tracer package due to AWS X-Ray SDK for Node.js not being ESM compatible
178+ const esmTracerPath = join (
179+ tmpBuildDir ,
180+ 'node_modules' ,
181+ '@aws-lambda-powertools/tracer' ,
182+ 'lib' ,
183+ 'esm' ,
184+ 'provider' ,
185+ 'ProviderService.js'
186+ ) ;
187+ execSync (
188+ `echo "import { createRequire } from 'module'; const require = createRequire(import.meta.url);$(cat ${ esmTracerPath } )" > ${ esmTracerPath } `
189+ ) ;
190+
191+ // Phase 6: Copy files from tmp folder to cdk.out asset folder (the folder is created by CDK)
178192 execSync ( `cp -R ${ tmpBuildPath } ${ sep } * ${ outputDir } ` ) ;
179193
180- // Phase 6 : (Optional) Restore changes to the project root made by the build
194+ // Phase 7 : (Optional) Restore changes to the project root made by the build
181195 buildFromLocal &&
182196 execSync ( 'git restore packages/*/package.json' , {
183197 cwd : projectRoot ,
You can’t perform that action at this time.
0 commit comments