2011-04-27 15:17:11 -07:00
|
|
|
{
|
2014-01-27 14:01:27 -08:00
|
|
|
"name": "bowser",
|
2017-04-04 23:17:27 +03:00
|
|
|
"description": "Lightweight browser detector",
|
2026-02-09 00:03:04 +02:00
|
|
|
"files": [
|
2026-08-30 00:10:11 +03:00
|
|
|
"src",
|
2026-02-09 00:03:04 +02:00
|
|
|
"es5.js",
|
|
|
|
|
"bundled.js",
|
2026-08-30 00:10:11 +03:00
|
|
|
"bowser.mjs",
|
|
|
|
|
"index.d.ts",
|
|
|
|
|
"index.d.mts"
|
2026-02-09 00:03:04 +02:00
|
|
|
],
|
2014-01-27 14:01:27 -08:00
|
|
|
"keywords": [
|
|
|
|
|
"browser",
|
2017-04-04 23:17:27 +03:00
|
|
|
"useragent",
|
|
|
|
|
"user-agent",
|
|
|
|
|
"parser",
|
|
|
|
|
"ua",
|
|
|
|
|
"detection",
|
|
|
|
|
"ender",
|
|
|
|
|
"sniff"
|
2014-01-27 14:01:27 -08:00
|
|
|
],
|
2025-11-30 18:58:23 +02:00
|
|
|
"homepage": "https://github.com/bowser-js/bowser",
|
2014-01-27 14:01:27 -08:00
|
|
|
"author": "Dustin Diaz <dustin@dustindiaz.com> (http://dustindiaz.com)",
|
2018-06-27 23:04:25 +03:00
|
|
|
"contributors": [
|
|
|
|
|
{
|
|
|
|
|
"name": "Denis Demchenko",
|
|
|
|
|
"url": "http://twitter.com/lancedikson"
|
2025-11-23 00:08:32 +02:00
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
"name": "Naor Peled",
|
|
|
|
|
"url": "https://github.com/naorpeled"
|
2018-06-27 23:04:25 +03:00
|
|
|
}
|
|
|
|
|
],
|
2018-08-02 21:36:41 +03:00
|
|
|
"main": "es5.js",
|
2019-09-10 19:02:13 +03:00
|
|
|
"browser": "es5.js",
|
2019-09-05 18:17:01 -03:00
|
|
|
"module": "src/bowser.js",
|
2019-07-30 11:18:59 +10:00
|
|
|
"types": "index.d.ts",
|
2026-08-30 00:10:11 +03:00
|
|
|
"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",
|
2026-08-30 21:40:10 +03:00
|
|
|
"./LICENSE": "./LICENSE",
|
|
|
|
|
"./README.md": "./README.md",
|
|
|
|
|
"./index.d.ts": "./index.d.ts",
|
|
|
|
|
"./index.d.mts": "./index.d.mts",
|
2026-08-30 00:10:11 +03:00
|
|
|
"./package.json": "./package.json"
|
|
|
|
|
},
|
2014-01-27 14:01:27 -08:00
|
|
|
"repository": {
|
|
|
|
|
"type": "git",
|
2025-11-30 18:58:23 +02:00
|
|
|
"url": "git+https://github.com/bowser-js/bowser.git"
|
2014-01-27 14:01:27 -08:00
|
|
|
},
|
|
|
|
|
"devDependencies": {
|
2026-08-30 00:10:11 +03:00
|
|
|
"@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",
|
fix: restore ES5 output for bundled.js, and assert it
`bundled.js` stopped being ES5 when the webpack build was replaced by tsdown
in #628. It parses at ecmaVersion 2015 but not 5:
var t=(t,e)=>()=>(e||(t((e={exports:{}}).exports,e),t=null),e.exports)
That is rolldown's `__commonJS` interop helper. `@rolldown/plugin-babel` only
transforms input modules, and rolldown appends the helper afterwards; terser
with `ecma: 5` avoids introducing newer syntax but does not transpile, so the
arrow functions reached the published file. `es5.js` has no CommonJS
dependencies and never gets the helper, which is why only `bundled.js` broke.
The effect is total rather than partial: in an ES5 engine the whole script is
a SyntaxError, so `bundled.js` — the bundle that exists specifically to serve
those engines, polyfills included — does not load at all there.
Lower the emitted chunk with a babel renderChunk pass that runs after bundling
and before terser, so rolldown's own helpers are covered too. Costs 2.8 kB
(+1.6%) on bundled.js; es5.js is unchanged at 34 kB.
The existing guard was a grep for backticks, which this syntax slips straight
past. Replace it with an acorn parse at ecmaVersion 5 over both legacy
bundles, plus a tokeniser check for real template literals (backticks inside
core-js string literals are fine, and 2.14.1 shipped three of them).
Verified by reverting the build fix: `bundled.js parses as ES5` fails, and
passes again once restored. Also confirmed bundled.js loads and parses the
live navigator.userAgent in a real browser.
2026-08-30 21:45:38 +03:00
|
|
|
"acorn": "^8.18.0",
|
2020-01-19 15:21:06 +00:00
|
|
|
"ava": "^3.0.0",
|
2026-08-30 00:10:11 +03:00
|
|
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
|
|
|
"babel-plugin-istanbul": "^8.0.0",
|
|
|
|
|
"core-js": "^3.49.0",
|
2026-08-30 21:05:22 +03:00
|
|
|
"coveralls-next": "^6.0.2",
|
|
|
|
|
"docdash": "^2.0.2",
|
2026-08-30 00:10:11 +03:00
|
|
|
"eslint": "^10.8.0",
|
|
|
|
|
"eslint-config-airbnb-extended": "^3.1.0",
|
|
|
|
|
"eslint-plugin-ava": "^17.0.1",
|
|
|
|
|
"eslint-plugin-import": "^2.32.0",
|
2026-08-30 21:05:22 +03:00
|
|
|
"gh-pages": "^6.3.0",
|
|
|
|
|
"jsdoc": "^4.0.5",
|
2026-08-30 00:10:11 +03:00
|
|
|
"nyc": "^18.0.0",
|
|
|
|
|
"publint": "^0.3.22",
|
|
|
|
|
"regenerator-runtime": "^0.14.1",
|
|
|
|
|
"sinon": "^22.0.0",
|
|
|
|
|
"terser": "^5.49.0",
|
2026-08-30 21:05:22 +03:00
|
|
|
"testem": "^3.20.2",
|
2026-08-30 00:10:11 +03:00
|
|
|
"tsdown": "^0.22.14",
|
|
|
|
|
"typescript": "^5.9.3",
|
2017-08-20 18:21:17 +03:00
|
|
|
"yamljs": "^0.3.0"
|
2017-04-09 17:13:00 +03:00
|
|
|
},
|
|
|
|
|
"ava": {
|
|
|
|
|
"require": [
|
2019-01-19 12:07:15 +02:00
|
|
|
"@babel/register"
|
2026-08-30 00:10:11 +03:00
|
|
|
],
|
|
|
|
|
"files": [
|
|
|
|
|
"test/**/*.js",
|
test: guard ES5 runtime APIs and type-check consumers in CI
Follow-up to the ES5 syntax fix, closing the gaps that investigation left.
An ES5-only runtime sandbox. The acorn check catches syntax, but syntax is
only half the contract: preset-env lowers syntax and never polyfills library
calls, so one `Array.prototype.includes` in the parser source compiles
cleanly, passes every test on modern Node, and throws on the browsers es5.js
exists for. The new test runs both legacy bundles in a vm context with the
post-ES5.1 globals, statics and prototype methods deleted, and asserts
bundled.js additionally installs the polyfills its README entry promises.
Includes a test that the sandbox really strips, so it cannot quietly pass
against a modern global.
A consumer type-check across every module resolution mode, run in CI against
the packed tarball. attw already checks that types *resolve* per condition;
it compiles nothing, so it cannot catch a declaration that resolves correctly
and then misdescribes the runtime. Negative cases are asserted too — the maps
must stay non-importable as named exports, which is the line index.d.mts
draws deliberately and only a failing compile can hold.
Also documents two findings that were investigated and deliberately left
alone: the bundled.js size increase is the core-js 2 -> 3 upgrade rather than
waste, and `useBuiltIns: 'usage'` would shrink it by breaking the documented
"all needed polyfills" contract; and the src/*.js ESM-in-CJS wart (publint
warnings, Yarn PnP, Node < 20.19) is longstanding and identical on 2.14.1,
with the nested-package.json fix blocked on @babel/register.
Verified by breaking each guard in turn: an ES6 API call injected into es5.js
fails the sandbox test, and an index.d.mts with its `parse` export removed
fails all three ESM resolution modes while the CJS modes correctly still pass.
2026-08-30 21:57:22 +03:00
|
|
|
"!test/package/**",
|
|
|
|
|
"!test/types/**"
|
2019-01-19 12:07:15 +02:00
|
|
|
]
|
2015-05-03 13:14:06 +02:00
|
|
|
},
|
|
|
|
|
"bugs": {
|
2025-11-30 18:58:23 +02:00
|
|
|
"url": "https://github.com/bowser-js/bowser/issues"
|
2015-05-03 13:14:06 +02:00
|
|
|
},
|
|
|
|
|
"directories": {
|
|
|
|
|
"test": "test"
|
|
|
|
|
},
|
|
|
|
|
"scripts": {
|
2026-08-30 00:10:11 +03:00
|
|
|
"build": "tsdown",
|
|
|
|
|
"generate-and-deploy-docs": "pnpm generate-docs && gh-pages --dist docs --dest docs",
|
|
|
|
|
"watch": "tsdown --watch",
|
2023-11-13 11:11:28 +02:00
|
|
|
"lint:check": "eslint ./src",
|
|
|
|
|
"lint:fix": "eslint --fix ./src",
|
2017-08-20 18:37:01 +03:00
|
|
|
"testem": "testem",
|
2018-09-09 14:01:45 +03:00
|
|
|
"test": "nyc --reporter=html --reporter=text ava",
|
2018-12-27 17:49:58 +01:00
|
|
|
"test:watch": "ava --watch",
|
2026-08-30 00:10:11 +03:00
|
|
|
"test:package": "node test/package/smoke.cjs",
|
2018-07-05 22:44:43 +03:00
|
|
|
"coverage": "nyc report --reporter=text-lcov | coveralls",
|
test: guard ES5 runtime APIs and type-check consumers in CI
Follow-up to the ES5 syntax fix, closing the gaps that investigation left.
An ES5-only runtime sandbox. The acorn check catches syntax, but syntax is
only half the contract: preset-env lowers syntax and never polyfills library
calls, so one `Array.prototype.includes` in the parser source compiles
cleanly, passes every test on modern Node, and throws on the browsers es5.js
exists for. The new test runs both legacy bundles in a vm context with the
post-ES5.1 globals, statics and prototype methods deleted, and asserts
bundled.js additionally installs the polyfills its README entry promises.
Includes a test that the sandbox really strips, so it cannot quietly pass
against a modern global.
A consumer type-check across every module resolution mode, run in CI against
the packed tarball. attw already checks that types *resolve* per condition;
it compiles nothing, so it cannot catch a declaration that resolves correctly
and then misdescribes the runtime. Negative cases are asserted too — the maps
must stay non-importable as named exports, which is the line index.d.mts
draws deliberately and only a failing compile can hold.
Also documents two findings that were investigated and deliberately left
alone: the bundled.js size increase is the core-js 2 -> 3 upgrade rather than
waste, and `useBuiltIns: 'usage'` would shrink it by breaking the documented
"all needed polyfills" contract; and the src/*.js ESM-in-CJS wart (publint
warnings, Yarn PnP, Node < 20.19) is longstanding and identical on 2.14.1,
with the nested-package.json fix blocked on @babel/register.
Verified by breaking each guard in turn: an ES6 API call injected into es5.js
fails the sandbox test, and an index.d.mts with its `parse` export removed
fails all three ESM resolution modes while the CJS modes correctly still pass.
2026-08-30 21:57:22 +03:00
|
|
|
"generate-docs": "jsdoc -c jsdoc.json",
|
|
|
|
|
"test:types": "node test/types/check.mjs"
|
2015-05-03 13:14:06 +02:00
|
|
|
},
|
2026-08-30 00:10:11 +03:00
|
|
|
"license": "MIT",
|
|
|
|
|
"packageManager": "pnpm@11.18.0"
|
2011-04-27 15:17:11 -07:00
|
|
|
}
|