mirror of
https://github.com/selfxyz/self.git
synced 2026-04-05 03:00:53 -04:00
* Add tree-shakeable exports * Migrate imports for tree-shakeable paths * Document ESM extension requirement * udpates * install new lock * yarn nice * build deps * save working index export no wildcard approach * save wip * fix building * add tree shaking doc and examples * sort package json files * update package.json * fix analyzing web * make sure that web is built * wip tree shaking * building works again. save wip logic * use granular imports * wip test * save wip * Remove hardcoded .d.ts files and setup automatic TypeScript declaration generation - Remove redundant constants.d.ts, types.d.ts, utils.d.ts files - Add build:types script to automatically generate TypeScript declarations - Update tsup config to disable DTS generation (handled separately) - Update .gitignore to prevent future commits of generated .d.ts files - Fixes import resolution errors in app by ensuring declarations are always generated * Add .gitignore rules for generated TypeScript declarations * ignore dts files * Remove redundant index.js re-export files - Remove constants.js, types.js, utils.js as they're redundant with tsup build - These were just re-exports pointing to dist files that tsup generates - package.json exports already point directly to built files - Update .gitignore to prevent future commits of these generated files - tsup handles all the building, no manual re-export files needed * save current wip fixes * add tsup config for web building * common prettier and fix imports * prettier * fix tests * implement level 3 tree shaking * improve splitting * optimize vite web building and prettier * remove comments * sort export params * feedback and fix pipelines * fix circuit-names path * fix test * fix building * sort * fix building * allow cursor to edit scripts * fix loadDocumentCatalog undefined * fix build settings * fix build settings * additional metro tree shaking * improved discovery script for xcode building * pr feedback and fix camelCasing * simplify shim setup * fix xcode building and add command to test building * remove comment * simplify
196 lines
5.6 KiB
JavaScript
196 lines
5.6 KiB
JavaScript
const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config');
|
|
const path = require('node:path');
|
|
const defaultConfig = getDefaultConfig(__dirname);
|
|
const { assetExts, sourceExts } = defaultConfig.resolver;
|
|
|
|
const monorepoRoot = path.resolve(__dirname, '../');
|
|
const commonPath = path.join(__dirname, '/../common');
|
|
const trueMonorepoNodeModules = path.resolve(__dirname, '../node_modules');
|
|
const extraNodeModules = {
|
|
stream: require.resolve('stream-browserify'),
|
|
buffer: require.resolve('buffer'),
|
|
util: require.resolve('util'),
|
|
assert: require.resolve('assert'),
|
|
'@babel/runtime': path.join(trueMonorepoNodeModules, '@babel/runtime'),
|
|
'@selfxyz/common': path.resolve(commonPath, 'dist'),
|
|
// Main exports
|
|
'@selfxyz/common/utils': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/index.js',
|
|
),
|
|
'@selfxyz/common/types': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/types/index.js',
|
|
),
|
|
'@selfxyz/common/constants': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/index.js',
|
|
),
|
|
// Constants subpaths
|
|
'@selfxyz/common/constants/core': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/constants.js',
|
|
),
|
|
'@selfxyz/common/constants/countries': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/countries.js',
|
|
),
|
|
'@selfxyz/common/constants/vkey': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/vkey.js',
|
|
),
|
|
'@selfxyz/common/constants/skiPem': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/skiPem.js',
|
|
),
|
|
'@selfxyz/common/constants/mockCerts': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/mockCertificates.js',
|
|
),
|
|
'@selfxyz/common/constants/hashes': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/constants/sampleDataHashes.js',
|
|
),
|
|
// Utils subpaths
|
|
'@selfxyz/common/utils/hash': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/hash.js',
|
|
),
|
|
'@selfxyz/common/utils/bytes': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/bytes.js',
|
|
),
|
|
'@selfxyz/common/utils/trees': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/trees.js',
|
|
),
|
|
'@selfxyz/common/utils/scope': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/scope.js',
|
|
),
|
|
'@selfxyz/common/utils/appType': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/appType.js',
|
|
),
|
|
'@selfxyz/common/utils/date': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/date.js',
|
|
),
|
|
'@selfxyz/common/utils/arrays': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/arrays.js',
|
|
),
|
|
'@selfxyz/common/utils/passports': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/passports/index.js',
|
|
),
|
|
'@selfxyz/common/utils/passportFormat': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/passports/format.js',
|
|
),
|
|
'@selfxyz/common/utils/passportMock': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/passports/mock.js',
|
|
),
|
|
'@selfxyz/common/utils/passportDg1': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/passports/dg1.js',
|
|
),
|
|
'@selfxyz/common/utils/certificates': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/certificate_parsing/index.js',
|
|
),
|
|
'@selfxyz/common/utils/elliptic': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/certificate_parsing/elliptic.js',
|
|
),
|
|
'@selfxyz/common/utils/curves': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/certificate_parsing/curves.js',
|
|
),
|
|
'@selfxyz/common/utils/oids': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/certificate_parsing/oids.js',
|
|
),
|
|
'@selfxyz/common/utils/circuits': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/circuits/index.js',
|
|
),
|
|
'@selfxyz/common/utils/circuitNames': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/circuits/circuitsName.js',
|
|
),
|
|
'@selfxyz/common/utils/circuitFormat': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/circuits/formatOutputs.js',
|
|
),
|
|
'@selfxyz/common/utils/uuid': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/circuits/uuid.js',
|
|
),
|
|
'@selfxyz/common/utils/contracts': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/contracts/index.js',
|
|
),
|
|
'@selfxyz/common/utils/sanctions': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/contracts/forbiddenCountries.js',
|
|
),
|
|
'@selfxyz/common/utils/csca': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/utils/csca.js',
|
|
),
|
|
// Types subpaths
|
|
'@selfxyz/common/types/passport': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/types/passport.js',
|
|
),
|
|
'@selfxyz/common/types/app': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/types/app.js',
|
|
),
|
|
'@selfxyz/common/types/certificates': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/types/certificates.js',
|
|
),
|
|
'@selfxyz/common/types/circuits': path.resolve(
|
|
commonPath,
|
|
'dist/esm/src/types/circuits.js',
|
|
),
|
|
};
|
|
const watchFolders = [
|
|
path.resolve(commonPath),
|
|
trueMonorepoNodeModules,
|
|
path.join(__dirname, 'src'),
|
|
];
|
|
|
|
/**
|
|
* Metro configuration
|
|
* https://facebook.github.io/metro/docs/configuration
|
|
*
|
|
* @type {import('metro-config').MetroConfig}
|
|
*/
|
|
const config = {
|
|
transformer: {
|
|
babelTransformerPath: require.resolve(
|
|
'react-native-svg-transformer/react-native',
|
|
),
|
|
disableImportExportTransform: true,
|
|
inlineRequires: true,
|
|
},
|
|
resolver: {
|
|
extraNodeModules,
|
|
nodeModulesPaths: [
|
|
path.resolve(__dirname, 'node_modules'), // App's own node_modules
|
|
path.resolve(monorepoRoot, 'node_modules'), // Monorepo root node_modules
|
|
trueMonorepoNodeModules,
|
|
// Add paths to other package workspaces if needed
|
|
],
|
|
assetExts: assetExts.filter(ext => ext !== 'svg'),
|
|
sourceExts: [...sourceExts, 'svg'],
|
|
},
|
|
watchFolders,
|
|
};
|
|
|
|
module.exports = mergeConfig(defaultConfig, config);
|