-
Notifications
You must be signed in to change notification settings - Fork 152
Expand file tree
/
Copy pathmetro.config.js
More file actions
35 lines (30 loc) · 1.62 KB
/
Copy pathmetro.config.js
File metadata and controls
35 lines (30 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
const { getDefaultConfig } = require('expo/metro-config');
const config = getDefaultConfig(__dirname);
// ─── Tree-shaking / minification ─────────────────────────────────────────────
// Enable minification in production so unused code paths are removed by the
// Metro bundler's inline-requires and dead-code-elimination passes.
config.transformer = {
...config.transformer,
// Inline requires defers module evaluation until first use — this effectively
// implements lazy loading for heavy modules (ethers, stellar-sdk, etc.)
// and removes them from the critical path entirely when not needed.
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: true,
},
}),
};
// ─── Resolver: platform-specific module aliases ───────────────────────────────
// Prefer the ES-module (tree-shakeable) entry point for libraries that ship
// both CJS and ESM builds.
config.resolver = {
...config.resolver,
// Prioritise .mjs then .js so bundler picks up ESM where available
sourceExts: ['mjs', 'js', 'jsx', 'ts', 'tsx', 'cjs', 'json'],
};
// ─── Bundle analyser ──────────────────────────────────────────────────────────
// To analyse bundle size locally, run:
// npx react-native-bundle-visualizer
// (metro-bundle-analyzer was removed — it was never published to npm)
module.exports = config;