ESM build, test environment polyfills, and dependency bumps (v4.4.26)
This release aligns the package with an ESM-first build output, simplifies test and TypeScript configurations, and updates several Fjell dependencies and dev tools. The primary goals were: produce ES2022 ESM artifacts and declaration files, provide Node-friendly test globals (fetch/FormData/Blob/File) for vitest, and tidy package metadata and build/test scripts. The changes affect packaging/exports, test setup, TypeScript emission settings, vitest configuration, and dependency pins.
New features
-
ESM exports mapping
- package.json now exposes an ESM-style
moduleentry and anexportsmapping that points to./dist/index.jsand./dist/index.d.tsfor types. This replaces previousmain,browser, andtypefields and clarifies ESM consumption.
- package.json now exposes an ESM-style
-
Test environment polyfills for Node
- tests/setup.ts now polyfills fetch and FormData using
undiciandnode:buffer(Blob, File). The test bootstrap enablesvitest-fetch-mockto mock fetch requests in tests.
- tests/setup.ts now polyfills fetch and FormData using
Improvements
-
Packaging and build output
- TypeScript is configured to emit compiled artefacts into
dist/(outDir), generate declaration files (declaration: true), and produce source maps (sourceMap: true). Target and module are set toes2022to produce modern ESM output. - The repository now uses an explicit
moduleexport plusexportsmapping to make ESM entrypoints and type declarations explicit to consumers.
- TypeScript is configured to emit compiled artefacts into
-
Dependency updates and pinning
- Fjell runtime dependencies were bumped to newer patch versions in package.json:
@fjell/core,@fjell/http-api,@fjell/logging, and@fjell/registrymoved to newer patch/minor targets (examples in commits: ^4.4.35, ^4.4.35, ^4.4.43, ^4.4.31). These changes bring the package in line with other Fjell packages and the current release train. - Development dependencies were reorganized:
jsdomand@types/nodewere removed (no longer required for the Node-based test setup);undiciandvitest-fetch-mockwere added to support fetch polyfills and fetch mocking in Node tests. - Runtime dependency
deepmergeremains declared.
- Fjell runtime dependencies were bumped to newer patch versions in package.json:
-
Simplified TypeScript configuration
- Removed several previously set compiler options such as
rootDir,esModuleInterop, and explicitmoduleResolutionsettings to simplify the compilerOptions block. includecontinues to target./src/**/*.tswhileexcludewas expanded to ignorenode_modules,./examples/**/*,./tests/**/*, and./dist/**/*so that emitted artifacts and test sources are not compiled into library output.
- Removed several previously set compiler options such as
-
Vitest configuration simplification
- vitest.config.ts now declares triple-slash reference types for vitest, enables
globals: true, and uses a consistentdefineConfigexport. Several explicit options were removed (environment, setupFiles, include, testTimeout, verbose coverage provider settings) to rely on simpler defaults and the new Node-friendly test setup.
- vitest.config.ts now declares triple-slash reference types for vitest, enables
-
Tests and logging mock removal
- The previous large global mock of
@fjell/loggingwas removed from tests/setup.ts. Tests now rely on real logging modules (with the runtime dependency bumps) or test-local mocks.
- The previous large global mock of
Bug fixes / correctness
-
Ensure package.json ends with newline and clean up formatting
- package.json and other package metadata files were tidied for consistent file endings and ordering.
-
Test runtime correctness in Node
- By polyfilling global fetch/FormData/Blob/File and enabling
vitest-fetch-mock, tests that previously required a JSDOM environment or manual mocking should run reliably under a Node test environment.
- By polyfilling global fetch/FormData/Blob/File and enabling
Developer experience and testing
-
Node-native test globals
- Tests can run under Node without JSDOM using
undicito provide fetch andnode:bufferfor Blob/File. This avoids keepingjsdomas a devDependency and reduces reliance on browser-like test environments for server-oriented code.
- Tests can run under Node without JSDOM using
-
Fetch mocking
vitest-fetch-mockis enabled in tests/setup.ts;fetchMocker.enableMocks()is called during test bootstrap so tests can stub network interactions consistently.
-
Simplified vitest defaults
- Removing explicit
environmentandsetupFilesfrom vitest config reflects the move to Node globals and consolidated setup in tests/setup.ts.globals: trueis enabled so tests can use vitest globals without import.
- Removing explicit
Files and components affected
-
package.json
- Replaced
main/browser/typewithmoduleand anexportsmapping pointing to./dist/index.jsplustypesentry at./dist/index.d.ts. - Updated Fjell dependencies to newer patch/minor ranges and reorganized devDependencies (removed
jsdom,@types/node; addedundici,vitest-fetch-mock). - Scripts preserved and tidied; newlines and ordering normalized.
- Replaced
-
tests/setup.ts
- Added Node polyfills:
import { fetch, FormData } from 'undici'andimport { Blob, File } from 'node:buffer'. - Removed the previous global mock for
@fjell/logging. - Added
createFetchMockfromvitest-fetch-mockand enabled mocks with the Vitestviinstance.
- Added Node polyfills:
-
tsconfig.json
- Enabled
sourceMap,outDir: dist,declaration: true, and settarget/moduletoes2022. - Removed some legacy or more-specific compiler flags and expanded
excludeentries so build focuses onsrcoutput only.
- Enabled
-
vitest.config.ts
- Added triple-slash reference types
/// <reference types="vitest" />and usedglobals: true. - Removed many explicit coverage and environment options to defer to simpler configuration and test setup.
- Added triple-slash reference types
Breaking changes / things to watch for
-
ESM-only entrypoints
- The project now targets ESM (
es2022) and exposes amoduleentry with anexportsmap. Consumers using CommonJSrequire()against this package may need to update imports to ESM (import) or use compatible interop tooling. The previousmain/CommonJS entry andbrowserfield were removed.
- The project now targets ESM (
-
DevDependency changes affecting local test setup
jsdomand@types/nodewere removed from devDependencies. If local development workflows relied on JSDOM-specific globals or TypeScript Node typings provided only by@types/node, developers may need to install those dependencies locally or adapt to the Node-based test setup now provided.
-
Removed global logging mock from tests
- Tests that depended on the prior global stub for
@fjell/loggingmust provide local mocks or rely on the now-updated logging dependency behavior.
- Tests that depended on the prior global stub for
Migration notes
-
Running tests locally
- No extra vitest
setupFilesare required: tests/setup.ts registers Node globals and enables fetch mocking. Ensureundiciandvitest-fetch-mockare installed (they are declared in devDependencies after this change).
- No extra vitest
-
Build and publish
- TypeScript now emits JS and declaration files into
dist/. Consumers should import from the package as an ESM module. CI and publish steps that previously relied onmain/CommonJS behavior should be validated against the newexportslayout.
- TypeScript now emits JS and declaration files into
Related commit summary
- Bumped package version to 4.4.26 and began next dev cycle entries in package.json.
- Reworked package.json fields to use ESM
module+exports, updated Fjell dependencies, and reorganized devDependencies. - Added Node fetch/FormData/Blob/File polyfills and enabled vitest fetch mocking in tests/setup.ts; removed the large
@fjell/loggingglobal mock. - Simplified tsconfig.json to emit artifacts to
distand set modern ES target/module options; expanded excludes to avoid compiling tests/examples/dist. - Simplified vitest.config.ts, enabled globals, and added triple-slash vitest type references.
If you rely on CommonJS consumers, JSDOM-based tests, or the prior global logging test stub, review test and consumer code and adapt imports or install missing devDependencies as needed. For further detail, inspect the changed files: package.json, tsconfig.json, vitest.config.ts, and tests/setup.ts.