mirror of
https://github.com/lancedikson/bowser
synced 2026-09-22 12:05:23 +00:00
Keeps the published surface of bowser@2.14.1 intact while adding a real ESM build, and rewrites CI so it can actually run the new toolchain. Packaging - Restore the flat artifact layout. es5.js and bundled.js stay at the tarball root next to src/, so unpkg.com/bowser/es5.js and require('bowser/bundled') keep working. bowser.mjs is added alongside. - Build the UMD bundles from dedicated single-default-export entries in build/entries/. src/bowser.js gained named exports (parse, getParser) to fix #511, but a UMD bundle with named exports makes require('bowser') a namespace object instead of the class: typeof flips from 'function' to 'object' and BROWSER_MAP / ENGINE_MAP / OS_MAP / PLATFORMS_MAP disappear, since they are static getters rather than exports. - globalName back to lowercase 'bowser', matching the shipped es5.js. Renaming it to 'Bowser' would break every script-tag consumer. - Enumerate every legacy subpath in the exports map. Conditional exports are honoured from Node 12.16.0 onward, so a "."-only map turns paths that resolve today into ERR_PACKAGE_PATH_NOT_EXPORTED. Subpath patterns ("./src/*") need Node 12.20.0+ and the trailing-slash folder form was removed in Node 17, so explicit per-file keys are the only spelling that works across the whole supported range. Extension-less aliases included: the README documents require('bowser/bundled'). - main, browser and module keep their existing values. No engines field (npm warns EBADENGINE, pnpm fails under engine-strict) and no type field (it would reclassify es5.js as ESM). Build - Minify the UMD bundles with terser instead of rolldown's built-in oxc minifier. oxc prints every string literal as a template literal and rejects any compress.target below es2015, so it cannot emit ES5 and was silently undoing babel's lowering. terser is what webpack 4 used. - Wire up the copyright banner, which was declared but never passed to a config, and restore bundled.js as the polyfilled build via core-js/stable. - Add index.d.mts so the import condition has ESM types. Reusing the export = declarations for both conditions describes an ES module with CommonJS types. CI - Replace npm ci with pnpm across all workflows. This is what was failing: the lockfile was swapped for pnpm-lock.yaml but the workflows still ran npm ci, pinned to Node 12.16.3 and 16. Build now runs on Node 24, which tsdown requires. - Add a pack-smoke job that installs the packed tarball on Node 12.16.3, 14, 18, 20 and 24 and exercises every documented entry point, plus publint and attw on the tarball. This is what makes "non-breaking" a tested claim rather than an argument; it catches all of the above. - Restore test-list-of-ua.js to asserting src against the built es5.js. It had been collapsed to comparing Bowser.parse with itself.
138 lines
3.7 KiB
JSON
138 lines
3.7 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",
|
|
"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": "./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",
|
|
"./package.json": "./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",
|
|
"ava": "^3.0.0",
|
|
"babel-plugin-add-module-exports": "^1.0.4",
|
|
"babel-plugin-istanbul": "^8.0.0",
|
|
"core-js": "^3.49.0",
|
|
"coveralls": "^3.0.6",
|
|
"docdash": "^1.1.1",
|
|
"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": "^3.0.0",
|
|
"jsdoc": "^3.6.3",
|
|
"nyc": "^18.0.0",
|
|
"publint": "^0.3.22",
|
|
"regenerator-runtime": "^0.14.1",
|
|
"sinon": "^22.0.0",
|
|
"terser": "^5.49.0",
|
|
"testem": "^3.0.0",
|
|
"tsdown": "^0.22.14",
|
|
"typescript": "^5.9.3",
|
|
"yamljs": "^0.3.0"
|
|
},
|
|
"ava": {
|
|
"require": [
|
|
"@babel/register"
|
|
],
|
|
"files": [
|
|
"test/**/*.js",
|
|
"!test/package/**"
|
|
]
|
|
},
|
|
"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"
|
|
},
|
|
"license": "MIT",
|
|
"packageManager": "pnpm@11.18.0"
|
|
}
|