Skip to content

Commit 28e4f0a

Browse files
committed
feat: disable bundle code modification
1 parent 2385d94 commit 28e4f0a

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

lit-actions-ts-bundling/esbuild.config.js

+15-13
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,21 @@ const wrapIIFEInStringPlugin = {
5959
result.outputFiles.forEach((outputFile) => {
6060
let content = outputFile.text;
6161

62-
// IMPORTANT: if minify is disabled, we need to:
63-
// 1. remove var import_ethers = __require("ethers");
64-
// 2. remove import_ethers.
65-
content = content
66-
.replace(/var import_ethers = __require\("ethers"\);/g, "")
67-
.replace(/import_ethers\./g, "");
68-
69-
// IMPORTANT: if minify is enabled, we need to:
70-
// 1. remove var t=o(\"ethers\");
71-
// 2. replace t.ethers to ethers
72-
content = content
73-
.replace(/var\s+\w+=\w+\("ethers"\);/g, '')
74-
.replace(/[a-zA-Z]\.ethers/g, "ethers");
62+
// Leaving this in for now, but not needed if we find a better
63+
// solution for the global ethers object.
64+
// // IMPORTANT: if minify is disabled, we need to:
65+
// // 1. remove var import_ethers = __require("ethers");
66+
// // 2. remove import_ethers.
67+
// content = content
68+
// .replace(/var import_ethers = __require\("ethers"\);/g, "")
69+
// .replace(/import_ethers\./g, "");
70+
71+
// // IMPORTANT: if minify is enabled, we need to:
72+
// // 1. remove var t=o(\"ethers\");
73+
// // 2. replace t.ethers to ethers
74+
// content = content
75+
// .replace(/var\s+\w+=\w+\("ethers"\);/g, '')
76+
// .replace(/[a-zA-Z]\.ethers/g, "ethers");
7577

7678
// Use JSON.stringify to safely encode the content
7779
const wrappedContent = `/**

lit-actions-ts-bundling/global.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ethers as Ethers } from 'ethers';
2+
13
declare global {
24
export declare namespace Lit {
35
export namespace Actions {
@@ -380,6 +382,9 @@ declare global {
380382
const customAuthResource: string | `"\\(true,${string})\\"`;
381383
}
382384
}
385+
386+
export type ethers = Ethers;
387+
export const ethers: typeof Ethers;
383388
}
384389

385390
export { };

lit-actions-ts-bundling/src/lit-actions/hello-world.ts

-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,3 @@
1-
/**
2-
* The global ethers library (5.7.0) is available on Lit Action (Unbundled)
3-
*
4-
* inject ./buffer.shim.js
5-
*/
6-
import { ethers } from "ethers";
7-
81
(async () => {
92

103
const res = await Lit.Actions.runOnce({

0 commit comments

Comments
 (0)