Files
self/app/docs/examples/tree-shaking/level2-optimal-example.ts
Justin Hernandez 431f556542 chore: centralize license header checks (#952)
* chore: centralize license header scripts

* chore: run license header checks from root

* add header to other files

* add header to bundle

* add migration script and update check license headers

* convert license to mobile sdk

* migrate license headers

* remove headers from common; convert remaining

* fix headers

* add license header checks
2025-08-25 11:30:23 -07:00

35 lines
1.1 KiB
TypeScript

// SPDX-FileCopyrightText: 2025 Social Connect Labs, Inc.
// SPDX-License-Identifier: BUSL-1.1
// NOTE: Converts to Apache-2.0 on 2029-06-11 per LICENSE.
// Level 2 Granular Import Example - Optimal Tree Shaking
// This demonstrates the new file-based imports for maximum optimization
// Import only core constants (no country data, vkey, etc.)
import {
API_URL,
PASSPORT_ATTESTATION_ID,
} from '@selfxyz/common/constants/core';
// Import only passport types (no app types, certificate types, etc.)
import type { PassportData } from '@selfxyz/common/types/passport';
// Import only hash utilities (no bytes, trees, circuits, etc.)
import { hash } from '@selfxyz/common/utils/hash';
export function optimalLevel2Example(data: PassportData) {
// This will result in the smallest possible bundle
// Only the specific functions and constants we use are included
console.log('Using API:', API_URL);
console.log('Attestation ID:', PASSPORT_ATTESTATION_ID);
const hashedData = hash(JSON.stringify(data));
console.log('Hashed passport data:', hashedData);
return {
api: API_URL,
attestationId: PASSPORT_ATTESTATION_ID,
hash: hashedData,
};
}