Improve Code Packaging an Delivery
pahund opened this issue · 2 comments
pahund commented
Currently (version 2.x.x), there are two ways to include React Prebid in a project:
- Using
index-esnext.js
– this is the untranspiled code using ES modules, needs to be run through Babel before it can be used - Using
index.js
– this is the transpiled version that can be used directly in the browser
The problem with this approach: It is hard to debug the minified code (see issue #18). To solve this, we should provide the transpiled and unminified code per default. Users who want to use react-prebid
through a CDN should be able to download the transpiled and minified bundle from UNPKG.
Requirements
- All JavaScript bundles that are intended to be imported by client applications are be placed in a
dist
folder, which is not under source control and created on the fly by the webpack build - The webpack build creates the following files in the
dist
folder:-
index.js
– transpiled, unminified Common JS bundle, to be imported with arequire
statement -
index.js.map
– source map forindex.js
-
react-prebid.esm.js
– untranspiled, unminified source code, bundled into one file, to be imported as ES module with animport
statement -
react-prebid.esm.js.map
– source map forreact-prebid.esm.js
-
react-prebid.umd.js
– transpiled, unminified UMD bundle, to be incuded in web pages through a script tag, loaded from a CDN -
react-prebid.umd.js.map
– source map forreact-prebid.umd
-
react-prebid.umd.min.js
– transpiled, minified UMD bundle, to be incuded in web pages through a script tag, loaded from a CDN -
react-prebid.umd.min.js.map
– source map forreact-prebid.min.umd
-
- The
package.json
file points to the various bundles:"main": "dist/index.js"
"module": "dist/react-prebid.esm.js"
"unpkg": "dist/redux-toolkit.umd.min.js"
- The documentation explains how to import React Prebid
- as Common JS module
- as an ES module
- as a UMD bundle through the UNPKG CDN
- Description of release 3.0.0 on the releases page includes a migration guide from 2.x.x
mattcolman commented
LGTM!
pahund commented
Do you want to take care of this?