@@ -102,23 +102,35 @@ To test these examples with your local Rollbar.js build:
102102
103103## Package Entry Points
104104
105- Rollbar.js provides different entry points for different environments:
106-
107- - ** Main package** : ` require('rollbar') ` or ` import Rollbar from 'rollbar' `
108- - Node.js: ` src/server/rollbar.js `
109- - Browser (with bundler): ` dist/rollbar.umd.min.js `
110-
111- - ** Direct imports - Source files** (ES modules):
112- - ` rollbar/src/server/rollbar.js ` - Server-side source
113- - ` rollbar/src/browser/rollbar.js ` - Browser-side source
114- - ` rollbar/src/react-native/rollbar.js ` - React Native source
115-
116- - ** Direct imports - Distribution files** (pre-built bundles):
117- - ` rollbar/dist/rollbar.umd.js ` - Universal (CommonJS/AMD/global)
118- - ` rollbar/dist/rollbar.umd.min.js ` - Universal minified
119- - ` rollbar/dist/rollbar.js ` - Vanilla (script tag only)
120- - ` rollbar/dist/rollbar.min.js ` - Vanilla minified
121- - ` rollbar/dist/rollbar.snippet.js ` - Async snippet loader
122- - ` rollbar/dist/rollbar.named-amd.js ` - AMD/RequireJS
123-
124- - ** CDN** : ` https://cdn.rollbar.com/rollbarjs/refs/tags/vVERSION/rollbar.min.js `
105+ Rollbar.js uses conditional exports to provide the right module format for each environment:
106+
107+ ### Automatic Resolution (Recommended)
108+
109+ When you use ` require('rollbar') ` or ` import Rollbar from 'rollbar' ` , you automatically get:
110+
111+ - ** Node.js** :
112+ - ` import ` → ES module (` src/server/rollbar.js ` )
113+ - ` require() ` → CommonJS wrapper (` src/server/rollbar.cjs ` )
114+ - ** Browsers/Bundlers** :
115+ - ` import ` → ES module (` src/browser/rollbar.js ` )
116+ - ` require() ` → UMD bundle (` dist/rollbar.umd.min.js ` )
117+ - ** TypeScript** : Type definitions from ` index.d.ts `
118+
119+ ### Direct Imports - Source Files (ES modules)
120+
121+ - ` rollbar/src/server/rollbar.js ` - Server-side source
122+ - ` rollbar/src/browser/rollbar.js ` - Browser-side source
123+ - ` rollbar/src/react-native/rollbar.js ` - React Native source
124+
125+ ### Direct Imports - Distribution Files (Pre-built bundles)
126+
127+ - ` rollbar/dist/rollbar.umd.js ` - Universal (CommonJS/AMD/global)
128+ - ` rollbar/dist/rollbar.umd.min.js ` - Universal minified
129+ - ` rollbar/dist/rollbar.js ` - Vanilla (script tag only)
130+ - ` rollbar/dist/rollbar.min.js ` - Vanilla minified
131+ - ` rollbar/dist/rollbar.snippet.js ` - Async snippet loader
132+ - ` rollbar/dist/rollbar.named-amd.js ` - AMD/RequireJS
133+
134+ ### CDN
135+
136+ - ` https://cdn.rollbar.com/rollbarjs/refs/tags/vVERSION/rollbar.min.js `
0 commit comments