Describe the bug
wdio-ui5-service@3.0.10 cannot be loaded via require() in a CommonJS project. The package's root package.json declares "type": "module", but the CommonJS build shipped in dist/cjs/ has no dist/cjs/package.json marker. Node therefore parses the CommonJS output (dist/cjs/index.js) as an ES module and throws on first load:
ReferenceError: exports is not defined in ES module scope
Because both main and the require export condition point at dist/cjs/index.js, any CommonJS consumer — including a standard wdio.conf.js that does const { default } = require("wdio-ui5-service") — crashes at load time, before any test runs.
To Reproduce
Minimal, isolated reproduction (no UI5 app or wdio config required):
mkdir wdi5-repro && cd wdi5-repro
npm init -y
npm install wdio-ui5-service@3.0.10
node -e "require('wdio-ui5-service')"
- See error
Expected behavior
require("wdio-ui5-service") resolves and returns the service export (as it does once a dist/cjs/package.json containing {"type":"commonjs"} is present). ESM import already works — only the CommonJS entry is broken.
Logs/Console Output
$> node -e "require('wdio-ui5-service')"
.../node_modules/wdio-ui5-service/dist/cjs/index.js:19
Object.defineProperty(exports, "__esModule", { value: true });
^
ReferenceError: exports is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension
and '.../node_modules/wdio-ui5-service/package.json' contains "type": "module".
To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at .../node_modules/wdio-ui5-service/dist/cjs/index.js:19:23
at ModuleJobSync.runSync (node:internal/modules/esm/module_job:541:37)
at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:366:47)
Screenshots
n/a — crashes at module load, before a browser starts.
Runtime Env (please complete the following information):
wdi5/wdio-ui5-service-version: 3.0.10
UI5 version: n/a — fails before any UI5 is loaded (occurs on a bare npm install, no app)
wdio-version (output of wdio --version): 9.29.1
node-version (output of node --version): v24.15.0
- OS: Windows 11 (also reproducible on any OS — packaging-only)
- Browser + Version: n/a — fails before browser launch
Additional context
Root cause: the require export condition and main both resolve to dist/cjs/index.js, but with "type": "module" at the package root and no dist/cjs/package.json, Node treats that CommonJS output as ESM.
Suggested fix: emit dist/cjs/package.json = {"type":"commonjs"} (and, for symmetry, dist/esm/package.json = {"type":"module"}) as part of the build. Verified locally that adding a post-build step after the _build:cjs / _build:esm tsc runs makes require() succeed while keeping import working. Happy to open a PR.
Reproducible on both a bare install and in a real CommonJS wdio.conf.js project. Not browser- or --headless-dependent, and independent of the wdio version — the failure is purely at package load.
Describe the bug
wdio-ui5-service@3.0.10cannot be loaded viarequire()in a CommonJS project. The package's rootpackage.jsondeclares"type": "module", but the CommonJS build shipped indist/cjs/has nodist/cjs/package.jsonmarker. Node therefore parses the CommonJS output (dist/cjs/index.js) as an ES module and throws on first load:Because both
mainand therequireexport condition point atdist/cjs/index.js, any CommonJS consumer — including a standardwdio.conf.jsthat doesconst { default } = require("wdio-ui5-service")— crashes at load time, before any test runs.To Reproduce
Minimal, isolated reproduction (no UI5 app or wdio config required):
mkdir wdi5-repro && cd wdi5-repronpm init -ynpm install wdio-ui5-service@3.0.10node -e "require('wdio-ui5-service')"Expected behavior
require("wdio-ui5-service")resolves and returns the service export (as it does once adist/cjs/package.jsoncontaining{"type":"commonjs"}is present). ESMimportalready works — only the CommonJS entry is broken.Logs/Console Output
Screenshots
n/a — crashes at module load, before a browser starts.
Runtime Env (please complete the following information):
wdi5/wdio-ui5-service-version: 3.0.10UI5version: n/a — fails before any UI5 is loaded (occurs on a barenpm install, no app)wdio-version (output ofwdio --version): 9.29.1node-version (output ofnode --version): v24.15.0Additional context
Root cause: the
requireexport condition andmainboth resolve todist/cjs/index.js, but with"type": "module"at the package root and nodist/cjs/package.json, Node treats that CommonJS output as ESM.Suggested fix: emit
dist/cjs/package.json={"type":"commonjs"}(and, for symmetry,dist/esm/package.json={"type":"module"}) as part of the build. Verified locally that adding a post-build step after the_build:cjs/_build:esmtsc runs makesrequire()succeed while keepingimportworking. Happy to open a PR.Reproducible on both a bare install and in a real CommonJS
wdio.conf.jsproject. Not browser- or--headless-dependent, and independent of the wdio version — the failure is purely at package load.