-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(aws-lambda-nodejs): Support esbuild --inject #19133
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-lambda-nodejsfeature-requestA feature should be added or improved.A feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.
Description
Description
esbuild has --inject argument that allows injecting code into final output. Current workaround is to use banner, but that mangles link breaks.
Use Case
This is useful to e.g. inject aws-sdk dynamic require import when using ESM output:
const AWS = await (async () => {
const { createRequire } = (await import("node:module")).default;
const require = createRequire(import.meta.url);
return require("aws-sdk");
})();Instead, currently requires a banner workaround:
bundling: {
format: OutputFormat.ESM,
target: "esnext",
banner: `const AWS=await (async ()=>{const { createRequire }=(await import("node:module")).default;const require=createRequire(import.meta.url);return require("aws-sdk");})();`,
},Proposed Solution
Support --inject natively in BundlingOptions.
Other information
No response
Acknowledge
- I may be able to implement this feature request
- This feature might incur a breaking change
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-lambda-nodejsfeature-requestA feature should be added or improved.A feature should be added or improved.needs-triageThis issue or PR still needs to be triaged.This issue or PR still needs to be triaged.