Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Latest commit

 

History

History
21 lines (14 loc) · 1.2 KB

MinimizingBundleSize.md

File metadata and controls

21 lines (14 loc) · 1.2 KB

Minimizing Bundle Size

For convenience, One App Router exposes its full API on the top-level @americanexpress/one-app-router import. However, this causes the entire One App Router library and its dependencies to be included in client bundles that include code that imports from the top-level CommonJS bundle.

Instead, the bindings exported from @americanexpress/one-app-router are also available in @americanexpress/one-app-router/lib. When using CommonJS modules, you can import directly from @americanexpress/one-app-router/lib to avoid pulling in unused modules.

Assuming you are transpiling ES2015 modules into CommonJS modules, instead of:

import { Link, Route, Router } from '@americanexpress/one-app-router'

use:

import Link from '@americanexpress/one-app-router/lib/Link'
import Route from '@americanexpress/one-app-router/lib/Route'
import Router from '@americanexpress/one-app-router/lib/Router'

The public API available in this manner is defined as the set of imports available from the top-level @americanexpress/one-app-router module. Anything not available through the top-level @americanexpress/one-app-router module is a private API, and is subject to change without notice.