Conversation
WalkthroughDocumentation for the Node Package public API surface has been added, including a new comprehensive guide file that outlines Webpack and Rspack export entrypoints, configuration objects, built-in third-party support, and relevant types. A reference to this documentation has been added to the README. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryAdded comprehensive Node package API documentation and linked it from the README. The new guide documents webpack and rspack export surfaces, the
One minor formatting suggestion for the README to maintain consistency. Confidence Score: 5/5
Important Files Changed
Last reviewed commit: dd79cee |
dd79cee to
d2d2087
Compare
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
@claude review this PR. |
|
Claude finished @justin808's task in 1m 0s —— View job PR ReviewTodo List
SummaryThis PR adds excellent documentation for the Node package API. The documentation is accurate, well-structured, and comprehensive. I verified all exports against the actual source code and found them to be correct. Findings✅ Strengths
📝 Minor SuggestionThe greptile bot already identified a minor formatting improvement for the README: README.md:320 - Consider adding a blank line before the new section for better markdown formatting and consistency with the rest of the README: **📖 For a comprehensive guide to all configuration options, see the [Configuration Guide](./docs/configuration.md)**
+
**📦 For Node package exports and config object docs, see the [Node Package API Guide](./docs/node_package_api.md)**This would create more visual separation between the two documentation links. ✅ Verification DetailsI verified the following:
RecommendationApprove with minor formatting suggestion. The documentation is accurate and valuable. The formatting suggestion is optional and doesn't affect functionality. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@docs/node_package_api.md`:
- Around line 1-71: The file "Node Package API" (docs/node_package_api.md) is
missing a trailing newline; open the document (look for the top-level header "#
Node Package API") and ensure the file ends with a single newline character by
adding one after the final line of the content so the last byte is '\n'.
| # Node Package API | ||
|
|
||
| Shakapacker ships a Node package that exposes configuration and helper utilities | ||
| for both webpack and rspack. | ||
|
|
||
| ## Import Paths | ||
|
|
||
| ```js | ||
| // Webpack entrypoint | ||
| const shakapacker = require("shakapacker") | ||
|
|
||
| // Rspack entrypoint | ||
| const rspack = require("shakapacker/rspack") | ||
| ``` | ||
|
|
||
| ## Webpack Exports (`shakapacker`) | ||
|
|
||
| | Export | Type | Description | | ||
| |--------|------|-------------| | ||
| | `config` | object | Parsed `config/shakapacker.yml` plus computed fields | | ||
| | `devServer` | object | Dev server configuration | | ||
| | `generateWebpackConfig(extraConfig?)` | function | Generates final webpack config and merges optional overrides | | ||
| | `baseConfig` | object | Base config object from `package/environments/base` | | ||
| | `env` | object | Environment metadata (`railsEnv`, `nodeEnv`, booleans) | | ||
| | `rules` | array | Loader rules for current bundler | | ||
| | `moduleExists(name)` | function | Returns whether module can be resolved | | ||
| | `canProcess(rule, fn)` | function | Runs callback only if loader dependency is available | | ||
| | `inliningCss` | boolean | Whether CSS should be inlined in current dev-server mode | | ||
| | `merge`, `mergeWithCustomize`, `mergeWithRules`, `unique` | functions | Re-exported from `webpack-merge` | | ||
|
|
||
| ## Rspack Exports (`shakapacker/rspack`) | ||
|
|
||
| | Export | Type | Description | | ||
| |--------|------|-------------| | ||
| | `config` | object | Parsed `config/shakapacker.yml` plus computed fields | | ||
| | `devServer` | object | Dev server configuration | | ||
| | `generateRspackConfig(extraConfig?)` | function | Generates final rspack config and merges optional overrides | | ||
| | `baseConfig` | object | Base config object | | ||
| | `env` | object | Environment metadata (`railsEnv`, `nodeEnv`, booleans) | | ||
| | `rules` | array | Rspack loader rules | | ||
| | `moduleExists(name)` | function | Returns whether module can be resolved | | ||
| | `canProcess(rule, fn)` | function | Runs callback only if loader dependency is available | | ||
| | `inliningCss` | boolean | Whether CSS should be inlined in current dev-server mode | | ||
| | `merge`, `mergeWithCustomize`, `mergeWithRules`, `unique` | functions | Re-exported from `webpack-merge` | | ||
|
|
||
| ## `config` Object | ||
|
|
||
| `config` includes: | ||
|
|
||
| - Raw values from `config/shakapacker.yml` (`source_path`, `public_output_path`, `javascript_transpiler`, etc.) | ||
| - Computed absolute paths (`outputPath`, `publicPath`, `manifestPath`, `publicPathWithoutCDN`) | ||
| - Optional sections like `dev_server` and `integrity` | ||
|
|
||
| For the full key list and types, see: | ||
|
|
||
| - [`package/types.ts`](../package/types.ts) | ||
| - [Configuration Guide](./configuration.md) | ||
|
|
||
| ## Built-in Third-Party Support | ||
|
|
||
| Installer defaults include support for: | ||
|
|
||
| - Bundlers: webpack, rspack | ||
| - JavaScript transpilers: SWC (default), Babel, esbuild | ||
| - Common style/tooling loaders: css, sass, less, stylus, file/raw rules | ||
| - Common optimization/plugins for webpack/rspack production builds | ||
|
|
||
| Dependency presets used by the installer are defined in: | ||
|
|
||
| - [`lib/install/package.json`](../lib/install/package.json) | ||
|
|
There was a problem hiding this comment.
Ensure the file ends with a trailing newline.
As per coding guidelines, all files should end with a trailing newline character. Please add a newline after the last line of content.
📝 How to verify and fix
You can verify this in your editor or by running:
#!/bin/bash
# Check if file ends with newline
if [ -n "$(tail -c 1 docs/node_package_api.md)" ]; then
echo "Missing trailing newline"
else
echo "Has trailing newline"
fiTo fix, ensure your editor is configured to add a final newline, or run:
#!/bin/bash
# Add trailing newline if missing
[ -n "$(tail -c 1 docs/node_package_api.md)" ] && echo >> docs/node_package_api.md🤖 Prompt for AI Agents
In `@docs/node_package_api.md` around lines 1 - 71, The file "Node Package API"
(docs/node_package_api.md) is missing a trailing newline; open the document
(look for the top-level header "# Node Package API") and ensure the file ends
with a single newline character by adding one after the final line of the
content so the last byte is '\n'.
## Summary - add a dedicated Node package API guide (`docs/node_package_api.md`) - document webpack and rspack export surfaces (`shakapacker` and `shakapacker/rspack`) - document `config` object shape and where to find full typed references - document built-in third-party support areas and where installer dependency presets live - link this guide from the README configuration section Closes #845. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit ## Documentation * Added comprehensive Node Package API documentation detailing API exports, configuration objects, import entrypoints for bundlers, and built-in third-party support resources for developers. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
## Summary - Added [Unreleased] changelog entries for two merged PRs missing from CHANGELOG.md: - **PR #963**: Fixed `Env#current` crashing when Rails is not loaded (bug fix by @ihabadham) - **PR #900**: Added Node package API documentation (by @justin808) - Skipped non-user-visible PRs: #958, #957, #959 ## Test plan - [x] `yarn lint` passes - [x] Changelog formatting matches existing conventions 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only change confined to `CHANGELOG.md`, with no runtime or build behavior impact. > > **Overview** > Updates `CHANGELOG.md` under **[Unreleased]** to document two previously-merged changes: a fix preventing `Env#current` from crashing when Rails isn’t loaded, and new documentation for the Node package JavaScript API (`docs/node_package_api.md`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 81bf2b8. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: Claude Opus 4.6 <[email protected]>
Summary
docs/node_package_api.md)shakapackerandshakapacker/rspack)configobject shape and where to find full typed referencesCloses #845.
Summary by CodeRabbit
Documentation