Skip to content

Conversation

@mondoreale
Copy link
Contributor

This pull request modernizes the build and packaging process for both the cdn-location and geoip-location packages. It introduces Rollup-based bundling for both JavaScript and TypeScript declaration files, updates output structure, and improves build scripts. These changes help ensure better compatibility with both ESM and CommonJS consumers, streamline build artifacts, and enhance development workflows.

Build system and bundling improvements:

  • Added new rollup.config.mts files to both cdn-location and geoip-location packages to bundle output as both ESM (exports.js) and CommonJS (exports.cjs), and to bundle TypeScript declaration files (exports.d.ts). [1] [2]
  • Updated package.json in both packages to specify new entry points for main, module, and types, and to limit the published files to the new bundle outputs. [1] [2]

Development workflow enhancements:

  • Added prebuild, postbuild, and reset-self scripts to automate cleaning up build artifacts and running Rollup after TypeScript compilation. [1] [2]
  • Added new devDependencies: rollup, rollup-plugin-dts, @rollup/plugin-node-resolve, tsx, and rimraf to support the new build process. [1] [2]

TypeScript configuration updates:

  • Updated tsconfig.json in both packages to use "module": "preserve" and "moduleResolution": "bundler" for compatibility with the new bundling approach.

These changes collectively modernize the packaging workflow, improve compatibility, and make the build process more robust and maintainable.

Copy link
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 PR modernizes the build and packaging infrastructure for the cdn-location and geoip-location packages by introducing Rollup-based bundling. The changes create dual-format outputs (ESM and CommonJS) with bundled TypeScript declarations, improving compatibility and streamlining the build process.

Key changes include:

  • Added Rollup configurations to bundle both JavaScript (ESM/CJS) and TypeScript declaration files
  • Updated package.json files with new entry points, build scripts, and bundling dependencies
  • Modified TypeScript configurations to use module preservation and bundler resolution strategies

Reviewed changes

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

Show a summary per file
File Description
packages/geoip-location/tsconfig.json Updated TypeScript compiler options to support bundler-based module resolution
packages/geoip-location/rollup.config.mts Added Rollup configuration for bundling ESM, CJS, and TypeScript declarations
packages/geoip-location/package.json Updated entry points, files array, build scripts, and added bundling dependencies (contains critical path mismatch issue)
packages/cdn-location/tsconfig.json Updated TypeScript compiler options to support bundler-based module resolution
packages/cdn-location/rollup.config.mts Added Rollup configuration for bundling ESM, CJS, and TypeScript declarations
packages/cdn-location/package.json Updated entry points, files array, build scripts, and added bundling dependencies
package-lock.json Added dependency entries for Rollup, rimraf, and related packages with Node.js 20+ engine requirements

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

This also prevents the thing from overriding the source.
@mondoreale mondoreale force-pushed the bundle-cdn-and-geoip-location branch from 5b417b5 to 43d7654 Compare January 6, 2026 22:58
@mondoreale mondoreale marked this pull request as draft January 7, 2026 12:07
mondoreale added a commit that referenced this pull request Jan 7, 2026
> [!NOTE]
> Looks like #3332 is too much at once - lotta failing tests and what
not. I will deal with each of them packages separately.

This pull request updates the build and packaging setup for the
`@streamr/cdn-location` package. The main improvements are the
introduction of a Rollup build process to generate both CommonJS and ES
module outputs, refined output file structure, and enhancements to the
development workflow.

## Changes

**Build system and packaging improvements:**

* Added a new `rollup.config.mts` file to configure Rollup to bundle the
package into both ES module (`exports.js`) and CommonJS (`exports.cjs`)
formats, as well as to generate type declarations (`exports.d.ts`). This
setup also marks dependencies as external to avoid bundling them.
* Updated `package.json` to point to the new output files, specify both
`main` (CommonJS) and `module` (ESM) entry points, and restrict the
published files to only the relevant outputs.
* Added Rollup and related plugins (`@rollup/plugin-node-resolve`,
`rollup-plugin-dts`, `tsx`) as dev dependencies, and introduced a
`postbuild` script to run Rollup after TypeScript compilation. Also
added a `prebuild` script to clean up build info files.
* Updated `tsconfig.json` to use `"module": "preserve"` and
`"moduleResolution": "bundler"` for better compatibility with the new
bundling process.

**Monorepo integration:**

* Included `@streamr/cdn-location` in the monorepo bootstrap process in
the root `Dockerfile.node`, ensuring it is built alongside other
packages.
@mondoreale
Copy link
Contributor Author

Closing in favour of #3335 and #3336.

@mondoreale mondoreale closed this Jan 7, 2026
@mondoreale mondoreale deleted the bundle-cdn-and-geoip-location branch January 7, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants