Skip to content

Commit 55339ec

Browse files
committed
1 parent 809dd4e commit 55339ec

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

packages/wrapped-keys-lit-actions/esbuild.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,20 @@ const wrapIIFEInStringPlugin = {
2525
result.outputFiles.forEach((outputFile) => {
2626
let content = outputFile.text;
2727

28+
// IMPORTANT: if minify is disabled, we need to:
29+
// 1. remove var import_ethers = __require("ethers");
30+
// 2. remove import_ethers.
31+
content = content
32+
.replace(/var import_ethers = __require\("ethers"\);/g, '')
33+
.replace(/import_ethers\./g, '');
34+
35+
// IMPORTANT: if minify is enabled, we need to:
36+
// 1. remove var t=o(\"ethers\");
37+
// 2. replace t.ethers to ethers
38+
content = content
39+
.replace(/var\s+\w+=\w+\("ethers"\);/g, '')
40+
.replace(/[a-zA-Z]\.ethers/g, 'ethers');
41+
2842
// Use JSON.stringify to safely encode the content
2943
const wrappedContent = `/**
3044
* DO NOT EDIT THIS FILE. IT IS GENERATED ON BUILD. RUN \`yarn generate-lit-actions\` IN THE ROOT DIRECTORY TO UPDATE THIS FILE.

0 commit comments

Comments
 (0)