1
0
mirror of https://github.com/lancedikson/bowser synced 2026-09-23 12:34:58 +00:00

fix: keep every published file reachable, and test all four build artifacts

Two follow-ups to the dual packaging change (#628), found while running a
consumer-facing regression sweep against published 2.14.1.

An exports map is a closed list. Before #628 bowser had no exports map, so
every published file was reachable by subpath; afterwards LICENSE, README.md
and index.d.ts resolved to ERR_PACKAGE_PATH_NOT_EXPORTED. Nothing in the
documented API regressed, but `/// <reference types="bowser/index.d.ts" />`
and tooling that resolves the license by specifier both did. Add the four
non-code files to the map so the published surface matches 2.14.1 exactly,
and assert it in the package smoke test (25 -> 29 checks).

The acceptance suite asserted src/bowser.js and es5.js against the UA corpus
but not bundled.js or bowser.mjs. bowser.mjs is what the `import` condition
resolves to, so it is the file every modern ESM and bundler consumer runs,
and a build regression confined to it would have kept CI green. Assert all
four artifacts against the spec instead.

Verified by injecting a Chrome-parsing regression into bowser.mjs and into
bundled.js separately (each turns the suite red, labelled by artifact), and
by running the new smoke assertions against a pre-fix tarball (exit 1) and
this one (exit 0) on Node 12.16, 14, 18, 20 and 22.
This commit is contained in:
naorpeled
2026-08-30 21:37:09 +03:00
parent 1d7923497f
commit d5a861e8ad
3 changed files with 56 additions and 6 deletions

View File

@@ -93,6 +93,19 @@ check('require.resolve("bowser/package.json") works', function () {
assert.ok(fs.existsSync(require.resolve('bowser/package.json')));
});
// Before the exports map existed, *every* published file was reachable by
// subpath. An exports map is a closed list, so anything published but not
// enumerated silently becomes ERR_PACKAGE_PATH_NOT_EXPORTED. These four are
// not code, but they did resolve on every previous version — license and
// attribution tooling and `/// <reference types="bowser/index.d.ts" />`
// consumers can all depend on them.
['bowser/LICENSE', 'bowser/README.md', 'bowser/index.d.ts', 'bowser/index.d.mts']
.forEach(function (id) {
check('resolves "' + id + '"', function () {
assert.ok(fs.existsSync(require.resolve(id)));
});
});
// --- The published manifest ------------------------------------------------
check('main/browser/module/types fields are unchanged', function () {