mirror of
https://github.com/lancedikson/bowser
synced 2026-10-06 19:05:41 +00:00
Dual packaging, without breaking existing consumers (#628)
Co-authored-by: Yasumasa Ashida <ys.ashida@gmail.com>
This commit is contained in:
16
build/entries/bundled.js
Normal file
16
build/entries/bundled.js
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* UMD entry point for `bundled.js` — same as `es5.js`, but with the polyfills
|
||||
* needed by the browser targets baked in.
|
||||
*
|
||||
* `core-js/stable` + `regenerator-runtime/runtime` is the core-js@3 equivalent
|
||||
* of the deprecated `@babel/polyfill` that this bundle used to be built from.
|
||||
* `@babel/preset-env`'s `useBuiltIns: 'entry'` rewrites the `core-js/stable`
|
||||
* import below into just the polyfills the configured targets actually need.
|
||||
*
|
||||
* See `./es5.js` for why this only re-exports the default.
|
||||
*/
|
||||
import 'core-js/stable';
|
||||
import 'regenerator-runtime/runtime';
|
||||
import Bowser from '../../src/bowser.js';
|
||||
|
||||
export default Bowser;
|
||||
15
build/entries/es5.js
Normal file
15
build/entries/es5.js
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* UMD entry point for `es5.js`.
|
||||
*
|
||||
* `src/bowser.js` also has named exports (`parse`, `getParser`) so that ESM
|
||||
* consumers can `import { getParser } from 'bowser'`. A UMD bundle with named
|
||||
* exports would expose `module.exports = { default, parse, getParser }`, which
|
||||
* would break every existing `require('bowser')` and `window.bowser` consumer.
|
||||
*
|
||||
* Re-exporting only the default here keeps the UMD output at
|
||||
* `module.exports = Bowser` / `window.bowser = Bowser`. The class carries
|
||||
* `parse` and `getParser` as static methods, so nothing is lost.
|
||||
*/
|
||||
import Bowser from '../../src/bowser.js';
|
||||
|
||||
export default Bowser;
|
||||
Reference in New Issue
Block a user