# Migrating BotD v1 to v2 This guide shows how to migrate your code from BotD version 1 to version 2. ## CDN ```diff ``` ### NPM or Yarn Update the package version: ```bash npm install @fingerprintjs/fingerprintjs # or yarn add @fingerprintjs/fingerprintjs ``` ## JavaScript output and browser support ### Updated compilation target The distributed bundles are now compiled to ES2018 instead of ES5. Modern build tools already handle this target, but any pipeline that assumed ES5 output (for example, older minifiers or ES5-only runtime environments) may require updates to accept or transpile ES2018 syntax. ### Supported browsers The minimum browser versions officially supported by BotD are listed in the [browser support list](../browser_support.md). Confirm that the browsers you rely on meet or exceed these versions before deploying v2 ### Transpiling to ES5 when required If you must keep ES5-compatible artifacts—for example, when embedding BotD into legacy applications—you now need to run that transpilation yourself. A typical setup using Babel might look like: ```jsonc // babel.config.json { "presets": [ [ "@babel/preset-env", { "targets": { "ie": "11" }, "useBuiltIns": "usage", "corejs": "3.38" } ] ] } ``` Or, if you compile with TypeScript, adjust your `tsconfig.json`: ```jsonc { "compilerOptions": { "target": "ES5", "downlevelIteration": true } } ``` Make sure that your bundler (Webpack, Rollup, Vite, etc.) picks up these settings so that the BotD package is transpiled along with your application code. For Webpack with `babel-loader`, explicitly include the library so it is processed despite the default `node_modules` exclusion: ```ts // webpack.config.js module.exports = { // ... module: { rules: [ { test: /\.m?js$/, exclude: /node_modules\/(?!@fingerprintjs\/botd)/, // this will transpile BotD use: { loader: 'babel-loader', options: { presets: [ [ '@babel/preset-env', { targets: { ie: '11' }, useBuiltIns: 'usage', corejs: '3.38' } ] ] } } } ] } } ``` If you use TypeScript, ensure that the bundler reads your `tsconfig.json` (for example via `ts-loader` or `babel-loader` with `@babel/preset-typescript`) so that the downlevel settings apply to both your code and BotD.