Webpack to rollup - #1397
Conversation
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
|
Size Change: -15 MB (-76.5%) 🏆 Total Size: 4.61 MB 📦 View Changed
|
There was a problem hiding this comment.
Pull request overview
Replaces the webpack + babel build pipeline with Rollup, restructures build outputs into lib/esm, lib/cjs, and consolidated lib/types, and updates tests/configs to reference the new layout.
Changes:
- Add
rollup.config.mjsto build both preserved-module library outputs and UMD bundles (including axios variant handling). - Update
package.jsonexports/scripts and Vitest coverage configs to align with the new output directories. - Remove webpack/babel build configuration and update test imports/type references for the new
lib/esm+lib/typesstructure.
Reviewed changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
rollup.config.mjs |
New Rollup build for library (ESM/CJS) + UMD dist bundles, with axios and polyfill handling. |
package.json |
Updates entrypoints/exports, build scripts, and devDependencies for the Rollup toolchain. |
config/vitest.config.ts |
Adjust coverage inclusion to lib/esm/**/*.js. |
config/vitest.config.e2e.ts |
Adjust coverage inclusion to lib/esm/**/*.js. |
config/vitest.config.browser.ts |
Adjust coverage inclusion to lib/esm/**/*.js. |
config/vitest.config.axios.ts |
Adjust axios coverage inclusion to lib/axios/esm/**/*.js. |
config/tsconfig.json |
Emit declarations into lib/types once, using Node16 module settings. |
eslint.config.js |
Ignore rollup.config.mjs for linting. |
test/test-utils/stellar-sdk-import.ts |
Update typed imports to lib/types and runtime test loading to lib/esm / lib/axios/esm. |
test/unit/server/soroban/get_classic_entries.test.ts |
Update import path to lib/esm. |
test/unit/call_builders.test.ts |
Update import path to lib/esm. |
test/e2e/src/constructor-args.test.ts |
Update import paths to lib/esm. |
README.md |
Removes the sodium-native note. |
config/webpack.config.browser.js |
Removed (webpack browser build deleted). |
babel.config.js |
Removed (babel build deleted). |
config/babel-plugin-alias-http-client.js |
Removed (replaced by Rollup plugin logic). |
config/build.config.js |
Removed (no longer needed). |
config/set-output-dir.js |
Removed (tsconfig tmp output step removed). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "postbuild:lib:axios": "node config/write-module-type.js lib/axios/cjs commonjs", | ||
| "clean": "rm -rf lib/ dist/ coverage/ .nyc_output/ jsdoc/ test/e2e/.soroban", | ||
| "docs": "yarn build:docs && jsdoc -c ./config/.jsdoc.json", | ||
| "docs": "jsdoc -c ./config/.jsdoc.json", |
There was a problem hiding this comment.
The docs script no longer builds lib/, but config/.jsdoc.json is configured to document sources under lib/ (and excludes lib/axios). Running yarn docs after a clean install (or yarn clean) will produce incomplete docs or fail; consider restoring a build step (e.g., yarn build:lib / yarn build:prod) before invoking jsdoc.
| "docs": "jsdoc -c ./config/.jsdoc.json", | |
| "docs": "yarn build:lib && jsdoc -c ./config/.jsdoc.json", |
| "module": "./lib/esm/index.js", | ||
| "types": "./lib/types/index.d.ts", | ||
| "files": [ | ||
| "/types", |
There was a problem hiding this comment.
files still includes /types, but the package’s types entry now points to ./lib/types/index.d.ts and there is no top-level types/ directory. This makes the publish whitelist misleading and may omit/duplicate the intended type artifacts; consider removing /types (or replacing it with the correct path under lib/types).
| "/types", |
| // source, we load stellar-base at config time, enumerate its runtime exports, | ||
| // and serve a virtual module with explicit `export { ... }` re-exports | ||
| // whenever `@stellar/stellar-base` is imported. | ||
| // This can be removed once stellar-base is merged into this repo |
There was a problem hiding this comment.
Should we mark this as TODO: to make sure we don't forget to remove it?
There was a problem hiding this comment.
It is addressed in the base migration pr
What
Replaces the webpack + babel build toolchain with rollup. The SDK now ships both library and browser-UMD builds through a single rollup.config.mjs, produces a flatter output layout, and generates type declarations exactly once.
Library output moves to lib/esm/ (ESM) and lib/cjs/ (CJS), with the axios variant mirroring at lib/axios/esm/ and lib/axios/cjs/. Type declarations are consolidated into lib/types/ — one shared copy for both transport variants, since their public API is identical and only the http-client implementation differs. The exports map is updated accordingly; every subpath (including the new ./http-client/axios) resolves cleanly under Node16 module resolution. The dist/ UMD bundles (stellar-sdk.js, stellar-sdk-axios.js, plus .min.js counterparts) keep the same filenames so CDN consumers see no change.
The _build script now runs rollup -c, USE_AXIOS=true rollup -c, and a single tsc types pass. The old _babel, _babel:esm, _babel:cjs, build:ts, build:browser*, and temp-tsconfig steps are gone, along with babel.config.js,config/webpack.config.browser.js, config/babel-plugin-alias-http-client.js, config/set-output-dir.js, and
config/build.config.js. Babel, webpack, terser-webpack-plugin, node-polyfill-webpack-plugin, eslint-webpack-plugin, and null-loader are removed from devDependencies in favor of the rollup plugin set plus browserify-zlib (needed because axios's HTTP adapter reads zlib.constants.Z_SYNC_FLUSH at module init, and rollup-plugin-polyfill-node's zlib shim omits .constants).