-
Notifications
You must be signed in to change notification settings - Fork 43
refactor: Bundle cdn-location & geoip-location packages
#3332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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.
5b417b5 to
43d7654
Compare
> [!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.
This pull request modernizes the build and packaging process for both the
cdn-locationandgeoip-locationpackages. 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:
rollup.config.mtsfiles to bothcdn-locationandgeoip-locationpackages to bundle output as both ESM (exports.js) and CommonJS (exports.cjs), and to bundle TypeScript declaration files (exports.d.ts). [1] [2]package.jsonin both packages to specify new entry points formain,module, andtypes, and to limit the published files to the new bundle outputs. [1] [2]Development workflow enhancements:
prebuild,postbuild, andreset-selfscripts to automate cleaning up build artifacts and running Rollup after TypeScript compilation. [1] [2]rollup,rollup-plugin-dts,@rollup/plugin-node-resolve,tsx, andrimrafto support the new build process. [1] [2]TypeScript configuration updates:
tsconfig.jsonin 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.