Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/mean-turtles-appear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lit-protocol/contracts': patch
---

Consumers now get lazy-loaded CommonJS contract exports with "sideEffects": false, enabling bundlers to drop unused network artifacts and shrink application bundles.
5 changes: 0 additions & 5 deletions packages/contracts/dist/dev/develop.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -15431,11 +15431,6 @@ module.exports = {
"name": "CallerNotOwner",
"type": "error"
},
{
"inputs": [],
"name": "MustBeLessThan100",
"type": "error"
},
{
"inputs": [],
"name": "MustBeNonzero",
Expand Down
5 changes: 0 additions & 5 deletions packages/contracts/dist/dev/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -15429,11 +15429,6 @@ export const develop = {
"name": "CallerNotOwner",
"type": "error"
},
{
"inputs": [],
"name": "MustBeLessThan100",
"type": "error"
},
{
"inputs": [],
"name": "MustBeNonzero",
Expand Down
5 changes: 0 additions & 5 deletions packages/contracts/dist/dev/develop.json
Original file line number Diff line number Diff line change
Expand Up @@ -15429,11 +15429,6 @@
"name": "CallerNotOwner",
"type": "error"
},
{
"inputs": [],
"name": "MustBeLessThan100",
"type": "error"
},
{
"inputs": [],
"name": "MustBeNonzero",
Expand Down
5 changes: 0 additions & 5 deletions packages/contracts/dist/dev/develop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15429,11 +15429,6 @@ export const develop = {
"name": "CallerNotOwner",
"type": "error"
},
{
"inputs": [],
"name": "MustBeLessThan100",
"type": "error"
},
{
"inputs": [],
"name": "MustBeNonzero",
Expand Down
52 changes: 22 additions & 30 deletions packages/contracts/dist/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,27 @@
* This file is auto-generated. DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING.
*/

const datil = require("./prod/datil.cjs");
const datilDev = require("./prod/datil-dev.cjs");
const datilTest = require("./prod/datil-test.cjs");
const nagaDev = require("./prod/naga-dev.cjs");
const nagaTest = require("./prod/naga-test.cjs");
const nagaStaging = require("./prod/naga-staging.cjs");
const develop = require("./dev/develop.cjs");
// Define lazy getters so requiring the CJS root does not eagerly load all ABIs
function __defineLazy(target, key, getter) {
Object.defineProperty(target, key, { enumerable: true, configurable: true, get: getter });
}

const datilSignatures = require("./signatures/datil.cjs").signatures;
const datilDevSignatures = require("./signatures/datil-dev.cjs").signatures;
const datilTestSignatures = require("./signatures/datil-test.cjs").signatures;
const nagaDevSignatures = require("./signatures/naga-dev.cjs").signatures;
const nagaTestSignatures = require("./signatures/naga-test.cjs").signatures;
const nagaStagingSignatures = require("./signatures/naga-staging.cjs").signatures;
const developSignatures = require("./signatures/develop.cjs").signatures;
const __exports = {};

module.exports = {
datil,
datilDev,
datilTest,
nagaDev,
nagaTest,
nagaStaging,
develop,
datilSignatures,
datilDevSignatures,
datilTestSignatures,
nagaDevSignatures,
nagaTestSignatures,
nagaStagingSignatures,
developSignatures,
};
__defineLazy(__exports, "datil", () => require("./prod/datil.cjs"));
__defineLazy(__exports, "datilDev", () => require("./prod/datil-dev.cjs"));
__defineLazy(__exports, "datilTest", () => require("./prod/datil-test.cjs"));
__defineLazy(__exports, "nagaDev", () => require("./prod/naga-dev.cjs"));
__defineLazy(__exports, "nagaTest", () => require("./prod/naga-test.cjs"));
__defineLazy(__exports, "nagaStaging", () => require("./prod/naga-staging.cjs"));
__defineLazy(__exports, "develop", () => require("./dev/develop.cjs"));

__defineLazy(__exports, "datilSignatures", () => require("./signatures/datil.cjs").signatures);
__defineLazy(__exports, "datilDevSignatures", () => require("./signatures/datil-dev.cjs").signatures);
__defineLazy(__exports, "datilTestSignatures", () => require("./signatures/datil-test.cjs").signatures);
__defineLazy(__exports, "nagaDevSignatures", () => require("./signatures/naga-dev.cjs").signatures);
__defineLazy(__exports, "nagaTestSignatures", () => require("./signatures/naga-test.cjs").signatures);
__defineLazy(__exports, "nagaStagingSignatures", () => require("./signatures/naga-staging.cjs").signatures);
__defineLazy(__exports, "developSignatures", () => require("./signatures/develop.cjs").signatures);

module.exports = __exports;
1 change: 1 addition & 0 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
]
}
},
"sideEffects": false,
"publishConfig": {
"access": "public",
"directory": "../../dist/packages/contracts"
Expand Down
15 changes: 10 additions & 5 deletions packages/contracts/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,13 @@ ${signatureExports
* This file is auto-generated. DO NOT EDIT UNLESS YOU KNOW WHAT YOU'RE DOING.
*/

// Define lazy getters so requiring the CJS root does not eagerly load all ABIs
function __defineLazy(target, key, getter) {
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function parameters lack type annotations. In a TypeScript file, parameters should be typed for better type safety and IDE support.

Suggested change
function __defineLazy(target, key, getter) {
function __defineLazy(target: object, key: string | symbol, getter: () => any): void {

Copilot uses AI. Check for mistakes.
Object.defineProperty(target, key, { enumerable: true, configurable: true, get: getter });
}

const __exports = {};
Copy link

Copilot AI Oct 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __exports object lacks type annotation. Consider typing it as Record<string, any> or a more specific interface to maintain type safety.

Suggested change
const __exports = {};
const __exports: Record<string, any> = {};

Copilot uses AI. Check for mistakes.

${exports
.map((line) => {
if (line.startsWith('//')) return line;
Expand All @@ -377,7 +384,7 @@ ${exports
.replace(';', '')
.replace(/["']/g, '')
.replace('.ts', '');
return `const ${varName} = require("${importPath}.cjs");`;
return `__defineLazy(__exports, "${varName}", () => require("${importPath}.cjs"));`;
})
.join('\n')}

Expand All @@ -391,13 +398,11 @@ ${signatureExports
.replace(';', '')
.replace(/["']/g, '')
.replace('.ts', '');
return `const ${varName} = require("${importPath}.cjs").signatures;`;
return `__defineLazy(__exports, "${varName}", () => require("${importPath}.cjs").signatures);`;
})
.join('\n')}

module.exports = {
${moduleNames.map((name) => ` ${name},`).join('\n')}
};
module.exports = __exports;
`;

fs.writeFileSync('./dist/index.d.ts', tsContent);
Expand Down
Loading