Skip to content

refactor: Bundle browser-test-runner#3333

Merged
mondoreale merged 6 commits intobundlesfrom
bundle-browser-test-runner
Jan 7, 2026
Merged

refactor: Bundle browser-test-runner#3333
mondoreale merged 6 commits intobundlesfrom
bundle-browser-test-runner

Conversation

@mondoreale
Copy link
Copy Markdown
Contributor

This pull request refactors the build and packaging process for the browser-test-runner package, introducing Rollup for bundling, improving module resolution, and updating various scripts and dependencies. The changes make the package outputs more consistent, enhance compatibility (especially for Electron and Karma), and modernize the codebase with ES module syntax and improved path handling.

Changes

Build & packaging improvements:

  • Added a new rollup.config.mts configuration to bundle outputs for CommonJS, ES modules, Electron preload, and type declarations using Rollup.
  • Updated package.json to define main, module, and types entry points, specify more granular files for publishing, and add build scripts (prebuild, postbuild, reset-self).
  • Added new devDependencies for Rollup, plugins, and build tooling in package.json.
  • Updated tsconfig.json to use "module": "preserve" and "moduleResolution": "bundler" for better compatibility with modern bundlers.

Code modernization & compatibility:

  • Switched from CommonJS require to ES module import syntax in karma-setup.js for expect.
  • Improved path resolution in createKarmaConfig.ts to use fileURLToPath and import.meta.url for locating setup and preload files, ensuring compatibility with ESM and Electron environments. [1] [2]
  • Updated createWebpackConfig.ts to explicitly set timers: false in the fallback object for module resolution.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request refactors the browser-test-runner package to introduce Rollup-based bundling, modernize the module system to ESM, and improve path resolution for better compatibility with Electron and Karma test environments.

  • Introduced Rollup bundling to generate CommonJS, ES module, and Electron preload outputs
  • Migrated from CommonJS require to ES module import syntax
  • Updated path resolution to use fileURLToPath and import.meta.url for ESM compatibility

Reviewed changes

Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
packages/browser-test-runner/tsconfig.json Updated TypeScript compiler options to use module: "preserve" and moduleResolution: "bundler" for better bundler compatibility
packages/browser-test-runner/src/karma-setup.js Changed from CommonJS require to ES module import for the expect library
packages/browser-test-runner/src/createWebpackConfig.ts Explicitly set timers: false in webpack fallback configuration
packages/browser-test-runner/src/createKarmaConfig.ts Updated path resolution to use fileURLToPath and import.meta.url for locating setup and preload files in ESM context
packages/browser-test-runner/rollup.config.mts Added new Rollup configuration to bundle exports (CJS and ESM), preload file (CJS), karma-setup (ESM), and TypeScript declarations
packages/browser-test-runner/package.json Updated entry points to use bundled outputs, added build scripts, and added Rollup-related devDependencies
package-lock.json Updated lock file with new dependencies for Rollup, rimraf, tsx, and their transitive dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/browser-test-runner/package.json Outdated
Comment thread packages/browser-test-runner/rollup.config.mts
Comment thread packages/browser-test-runner/rollup.config.mts
Comment thread packages/browser-test-runner/package.json
Comment thread packages/browser-test-runner/rollup.config.mts
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +17
"dist/preload.cjs",
"dist/karma-setup.js",
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files field specifies dist/karma-setup.js and dist/preload.cjs which are generated by the rollup bundler, but it doesn't include the sourcemap files that are generated alongside them. According to the rollup.config.mts, all bundled outputs have sourcemap: true, which means .map files will be generated. These sourcemap files should either be included in the published package (recommended for debugging) or explicitly excluded from the files array. Consider adding dist/karma-setup.js.map and dist/preload.cjs.map to the files array, or add !**/*.map to explicitly exclude them if they shouldn't be published.

Suggested change
"dist/preload.cjs",
"dist/karma-setup.js",
"dist/preload.cjs",
"dist/preload.cjs.map",
"dist/karma-setup.js",
"dist/karma-setup.js.map",

Copilot uses AI. Check for mistakes.
Comment thread packages/browser-test-runner/rollup.config.mts
@mondoreale mondoreale merged commit d32481f into bundles Jan 7, 2026
3 checks passed
@mondoreale mondoreale deleted the bundle-browser-test-runner branch January 7, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants