1
0
mirror of https://github.com/lancedikson/bowser synced 2026-10-16 08:10:38 +00:00
Files
lancedikson_bowser/package.json
naorpeled 7b144d8247 fix: keep ESM consumers on ES5, enable tree-shaking, trim bundled.js
Found by a differential test of the packed candidate against the published
2.14.1 across Node 12-22, Bun, TypeScript 4.7-7.0, seven bundlers and a
real browser.

- bowser.mjs is now lowered to ES5 syntax (keeping `export`). Before the
  exports map, webpack, Rollup and esbuild resolved `import 'bowser'` to
  es5.js via the `browser` field; the ES2015 bowser.mjs broke esbuild
  `--target=es5` and shipped classes into webpack ES5 builds. The ESM build
  sets `minify: false` explicitly, because rolldown's default DCE-only pass
  re-prints the chunk after renderChunk and restores shorthand properties.
- `"sideEffects": ["./bundled.js"]` lets esbuild, Vite and webpack 4 drop an
  unused `import 'bowser'`; bundled.js stays listed so polyfill-only imports
  are never tree-shaken away.
- `./package` export restores extensionless `require('bowser/package')`,
  which resolved on 2.14.1.
- bundled.js imports `core-js/es` plus the timers, immediate and
  DOM-collection web polyfills instead of `core-js/stable`, dropping URL,
  URLSearchParams and queueMicrotask, which no released bundled.js ever
  shipped: 176.9 kB -> 156.1 kB (56.6 -> 49.3 kB gzip).

Tests: bowser.mjs must parse as ES5 apart from its export; bundled.js must
install the @babel/polyfill surface 2.14.1 shipped (passes on 2.14.1's
bundled.js, fails on unpolyfilled es5.js); package smoke test covers
`bowser/package` and `sideEffects`.
2026-09-27 01:04:05 +03:00

152 lines
4.0 KiB
JSON

{
"name": "bowser",
"description": "Lightweight browser detector",
"files": [
"src",
"es5.js",
"bundled.js",
"bowser.mjs",
"index.d.ts",
"index.d.mts"
],
"keywords": [
"browser",
"useragent",
"user-agent",
"parser",
"ua",
"detection",
"ender",
"sniff"
],
"homepage": "https://github.com/bowser-js/bowser",
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
"contributors": [
{
"name": "Denis Demchenko",
"url": "http://twitter.com/lancedikson"
},
{
"name": "Naor Peled",
"url": "https://github.com/naorpeled"
}
],
"main": "es5.js",
"browser": "es5.js",
"module": "src/bowser.js",
"types": "index.d.ts",
"sideEffects": [
"./bundled.js"
],
"exports": {
".": {
"import": {
"types": "./index.d.mts",
"default": "./bowser.mjs"
},
"require": {
"types": "./index.d.ts",
"default": "./es5.js"
},
"default": "./es5.js"
},
"./es5.js": "./es5.js",
"./es5": "./es5.js",
"./bundled.js": "./bundled.js",
"./bundled": "./bundled.js",
"./bowser.mjs": {
"types": "./index.d.mts",
"default": "./bowser.mjs"
},
"./src/bowser.js": "./src/bowser.js",
"./src/bowser": "./src/bowser.js",
"./src/constants.js": "./src/constants.js",
"./src/constants": "./src/constants.js",
"./src/parser.js": "./src/parser.js",
"./src/parser": "./src/parser.js",
"./src/parser-browsers.js": "./src/parser-browsers.js",
"./src/parser-browsers": "./src/parser-browsers.js",
"./src/parser-engines.js": "./src/parser-engines.js",
"./src/parser-engines": "./src/parser-engines.js",
"./src/parser-os.js": "./src/parser-os.js",
"./src/parser-os": "./src/parser-os.js",
"./src/parser-platforms.js": "./src/parser-platforms.js",
"./src/parser-platforms": "./src/parser-platforms.js",
"./src/utils.js": "./src/utils.js",
"./src/utils": "./src/utils.js",
"./LICENSE": "./LICENSE",
"./README.md": "./README.md",
"./index.d.ts": "./index.d.ts",
"./index.d.mts": "./index.d.mts",
"./package.json": "./package.json",
"./package": "./package.json"
},
"repository": {
"type": "git",
"url": "git+https://github.com/bowser-js/bowser.git"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.5",
"@babel/cli": "^7.29.7",
"@babel/core": "^7.29.7",
"@babel/preset-env": "^7.29.7",
"@babel/register": "^7.29.7",
"@eslint/js": "^10.0.1",
"@rolldown/plugin-babel": "0.2.3",
"acorn": "^8.18.0",
"ava": "^3.0.0",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^8.0.0",
"core-js": "^3.49.0",
"coveralls-next": "^6.0.2",
"docdash": "^2.0.2",
"eslint": "^10.8.0",
"eslint-config-airbnb-extended": "^3.1.0",
"eslint-plugin-ava": "^17.0.1",
"eslint-plugin-import": "^2.32.0",
"gh-pages": "^6.3.0",
"jsdoc": "^4.0.5",
"nyc": "^18.0.0",
"publint": "^0.3.22",
"regenerator-runtime": "^0.14.1",
"sinon": "^22.0.0",
"terser": "^5.49.0",
"testem": "^3.20.2",
"tsdown": "^0.22.14",
"typescript": "^5.9.3",
"yamljs": "^0.3.0"
},
"ava": {
"require": [
"@babel/register"
],
"files": [
"test/**/*.js",
"!test/package/**",
"!test/types/**"
]
},
"bugs": {
"url": "https://github.com/bowser-js/bowser/issues"
},
"directories": {
"test": "test"
},
"scripts": {
"build": "tsdown",
"generate-and-deploy-docs": "pnpm generate-docs && gh-pages --dist docs --dest docs",
"watch": "tsdown --watch",
"lint:check": "eslint ./src",
"lint:fix": "eslint --fix ./src",
"testem": "testem",
"test": "nyc --reporter=html --reporter=text ava",
"test:watch": "ava --watch",
"test:package": "node test/package/smoke.cjs",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"generate-docs": "jsdoc -c jsdoc.json",
"test:types": "node test/types/check.mjs"
},
"license": "MIT",
"packageManager": "pnpm@11.18.0"
}