Compatibility
The adsum-client-api is written in ES2015+ and support Browser, NodeJs and React-Native environments.
Builds
Browser
ES5
build/adsum-client-api.browser.js
The browser build is generated using babel-preset-env transpiled to ES5.
If you need to extends the support, please read the section Extending support
All dependencies are included, if you are wondering about optimizing it please read webpack section.
ES2015+
build/es/adsum-client-api.module.browser.js
This build is similar to the ES5 one except it is using ES2015+ module syntax and all dependencies are imported, meaning not included in the build.
This is the file defined in the browser field on the package.json.
This means that it will be used by your webpack or rollup by default if your are targeting web.
Using it with webpack/rollup will require you to transpile them.
NodeJs
ES5
build/adsum-client-api.node.js
The NodeJs build is generated using babel-preset-env transpiled to ES5.
ES2015+
build/es/adsum-client-api.module.node.js
This build is similar to the ES5 one except it is using ES2015+ module syntax.
This is the file defined in the module field on the package.json.
This means that it will be used by your webpack or rollup by default if your are targeting node.
Using it with webpack/rollup will require you to transpile them.
React Native
build/es/adsum-client-api.module.native.js
This is the file defined in the react-native field on the package.json.
Webpack
The recommended way to include the library is using Webpack in order to take all advantages of Tree Shaking and minimized ES2015+ transpiled code (transpiled code is slower to execute).
There is some environment specific implementation, so you need to make sure the proper target is configured to either
node
orweb
depending of the environment your targeting.
Just for you to know order to specify the platform specific code, we use the Resolve mainFields
Using this configuration will use ES2015+ build which may cause it to not work on your targeted
If you need to transpile to ES5, you need to use babel loader to transpile ALL dependencies to ensure compatibility of all your dependencies.
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
}
]
}
You will also need to include babel-polyfill