Skip to content

Add Node package API documentation#900

Merged
justin808 merged 3 commits intomainfrom
codex/issue-845-node-package-api-docs
Mar 8, 2026
Merged

Add Node package API documentation#900
justin808 merged 3 commits intomainfrom
codex/issue-845-node-package-api-docs

Conversation

@justin808
Copy link
Copy Markdown
Member

@justin808 justin808 commented Feb 15, 2026

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.

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.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 15, 2026

Walkthrough

Documentation 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

Cohort / File(s) Summary
Documentation Reference
README.md
Added link to new Node Package API Guide in Configuration/Code section.
API Documentation
docs/node_package_api.md
New file documenting Node package exports for Webpack and Rspack bundlers, configuration object structure, built-in third-party support, and types reference.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Hop, hop, hooray! The API's now clear,
No more guessing what exports live here,
From Webpack to Rspack, all bundlers in sight,
The docs shine so bright, what a delightful write! ✨📚

🚥 Pre-merge checks | ✅ 5 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Merge Conflict Detection ⚠️ Warning ❌ Merge conflicts detected (10 files):

⚔️ CHANGELOG.md (content)
⚔️ README.md (content)
⚔️ lib/shakapacker/dev_server_runner.rb (content)
⚔️ lib/shakapacker/runner.rb (content)
⚔️ package/rules/file.ts (content)
⚔️ spec/shakapacker/dev_server_runner_spec.rb (content)
⚔️ spec/shakapacker/rspack_runner_spec.rb (content)
⚔️ spec/shakapacker/runner_build_config_spec.rb (content)
⚔️ spec/shakapacker/webpack_runner_spec.rb (content)
⚔️ test/package/rules/file.test.js (content)

These conflicts must be resolved before merging into main.
Resolve conflicts locally and push changes to this branch.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Node package API documentation. It directly matches the primary objective of the PR.
Linked Issues check ✅ Passed The PR successfully addresses all coding objectives from issue #845: documenting Node package exports, configuration object, third-party support, and installer presets, with a README link added for discoverability.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #845 requirements: documentation additions for the Node package API, configuration object, and third-party support without unrelated modifications.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/issue-845-node-package-api-docs
⚔️ Resolve merge conflicts (beta)
  • Auto-commit resolved conflicts to branch codex/issue-845-node-package-api-docs
  • Create stacked PR with resolved conflicts
  • Post resolved changes as copyable diffs in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 15, 2026

Greptile Summary

Added comprehensive Node package API documentation and linked it from the README. The new guide documents webpack and rspack export surfaces, the config object shape, and built-in third-party support.

  • Created docs/node_package_api.md with detailed tables of webpack and rspack exports
  • All documented exports verified against actual code in package/index.ts and package/rspack/index.ts
  • Added link to new guide in README Configuration section
  • All referenced files (package/types.ts, lib/install/package.json, docs/configuration.md) exist and are correctly linked
  • Both files properly end with trailing newlines per project requirements

One minor formatting suggestion for the README to maintain consistency.

Confidence Score: 5/5

  • This PR is safe to merge - it only adds documentation
  • Score reflects documentation-only changes with accurate technical content verified against actual codebase, proper trailing newlines, and correctly linked references
  • No files require special attention

Important Files Changed

Filename Overview
docs/node_package_api.md New comprehensive Node package API documentation covering webpack and rspack exports
README.md Added link to new Node Package API guide, minor formatting issue with consecutive bold lines

Last reviewed commit: dd79cee

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread README.md
@justin808 justin808 force-pushed the codex/issue-845-node-package-api-docs branch from dd79cee to d2d2087 Compare February 15, 2026 22:17
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
@justin808
Copy link
Copy Markdown
Member Author

@claude review this PR.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 16, 2026

Claude finished @justin808's task in 1m 0s —— View job


PR Review

Todo List

  • Read the new documentation file
  • Read the README changes
  • Verify documentation accuracy against actual source code
  • Provide comprehensive review feedback

Summary

This 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

  1. Accurate export documentation: All exports in both tables match the actual code in package/index.ts and package/rspack/index.ts
  2. Clear structure: The documentation is well-organized with separate sections for webpack and rspack exports
  3. Helpful references: Links to package/types.ts, docs/configuration.md, and lib/install/package.json are all valid
  4. Proper trailing newlines: Both files end with trailing newlines as required by the project linting rules
  5. Good coverage: Documents the config object shape, built-in third-party support, and where to find more details

📝 Minor Suggestion

The 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 Details

I verified the following:

  • Webpack exports (package/index.ts:57-78): All 11 documented exports are present and correctly described
  • Rspack exports (package/rspack/index.ts:56-73): All 11 documented exports are present and correctly described
  • Config object reference (package/types.ts:13-45): The Config interface exists and contains all mentioned fields
  • Referenced files: All linked files exist:
    • package/types.ts
    • lib/install/package.json
    • docs/configuration.md

Recommendation

Approve with minor formatting suggestion. The documentation is accurate and valuable. The formatting suggestion is optional and doesn't affect functionality.


Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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'.

Comment thread docs/node_package_api.md
Comment on lines +1 to +71
# 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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

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"
fi

To 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'.

@justin808 justin808 added codex Created by Codex next-release Targeting next release p2 Medium: enhancements, docs, quality improvements documentation defer Valid but deferred; not in current release scope and removed p2 Medium: enhancements, docs, quality improvements next-release Targeting next release labels Feb 27, 2026
@justin808 justin808 merged commit 7a08a6d into main Mar 8, 2026
2 checks passed
@justin808 justin808 deleted the codex/issue-845-node-package-api-docs branch March 8, 2026 07:27
justin808 added a commit that referenced this pull request Mar 8, 2026
## 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>
justin808 added a commit that referenced this pull request Mar 8, 2026
justin808 added a commit that referenced this pull request Mar 8, 2026
## 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codex Created by Codex defer Valid but deferred; not in current release scope documentation p2 Medium: enhancements, docs, quality improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Node Package public API & Configuration Object needs to be documented

1 participant