-
Notifications
You must be signed in to change notification settings - Fork 380
Update to Shakapacker 9.1.0 and migrate to Rspack #680
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a951f4c
Update to Shakapacker 9.1.0 and migrate to Rspack
justin808 879d171
Add missing i18n translation files
justin808 087ec70
Fix Ruby version mismatch for CI
justin808 5d85f15
Fix SSR by using classic React runtime in SWC
justin808 3fe61f0
Fix CSS modules config for server bundle
justin808 fbc5781
Add .bs.js extension to resolve extensions for ReScript
justin808 76921b8
Add patch for rescript-json-combinators to generate .bs.js files
justin808 012b0b7
Fix yarn.lock and patch file for rescript-json-combinators
justin808 1685fb4
Fix CSS modules to use default exports for ReScript compatibility
justin808 28014b2
Move CSS modules fix into function to ensure it applies on each call
justin808 3da3dfc
Fix server bundle to properly filter Rspack CSS extract loader
justin808 71b934a
Remove generated i18n files that should be gitignored
justin808 752919b
Consolidate Rspack config into webpack directory with conditionals
justin808 4c761bb
Add bundler auto-detection to all webpack config files
justin808 431a8ee
Add comprehensive documentation and address code review feedback
justin808 2e03f56
Add performance benchmarks to README
justin808 5f92988
Correct performance benchmarks to show actual bundler times
justin808 0ab9eac
Refactor bundler detection and improve documentation
justin808 a32ebff
Add test coverage and improve documentation
justin808 84311cc
Fix CI failure and add bundler validation improvements
justin808 660aab3
Fix YAML alias parsing in RSpec bundler tests
justin808 2bdc624
Remove heavyweight RSpec bundler integration test
justin808 2af9d6f
Fix ESLint violations in bundlerUtils test
justin808 4d9d19e
Fix CSS plugin filtering and add cache immutability docs
justin808 13449f0
Migrate to modern ReScript .res.js suffix and remove patch
justin808 b7171e5
Add ror_components wrapper for ReScript component
justin808 8bae4aa
Remove generated .res.js files from git and add to .gitignore
justin808 ab8bd51
Add .bs.js to .gitignore for completeness
justin808 921844d
Remove patches/README.md
justin808 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* eslint-disable max-classes-per-file */ | ||
/* eslint-disable global-require */ | ||
/** | ||
* Unit tests for bundlerUtils.js | ||
* Tests bundler auto-detection and helper functions | ||
* | ||
* Note: These tests verify the bundler selection logic without actually | ||
* loading Rspack (which requires Node.js globals not available in jsdom). | ||
* We use require() inside tests to ensure proper mocking order. | ||
*/ | ||
|
||
// Mock the bundler packages to avoid loading them | ||
jest.mock('webpack', () => ({ | ||
ProvidePlugin: class MockProvidePlugin {}, | ||
optimize: { LimitChunkCountPlugin: class MockLimitChunkCount {} }, | ||
})); | ||
|
||
jest.mock('@rspack/core', () => ({ | ||
ProvidePlugin: class MockRspackProvidePlugin {}, | ||
CssExtractRspackPlugin: class MockCssExtractRspackPlugin {}, | ||
optimize: { LimitChunkCountPlugin: class MockRspackLimitChunkCount {} }, | ||
})); | ||
|
||
jest.mock('mini-css-extract-plugin', () => class MiniCssExtractPlugin {}); | ||
|
||
describe('bundlerUtils', () => { | ||
let mockConfig; | ||
|
||
beforeEach(() => { | ||
// Reset module cache | ||
jest.resetModules(); | ||
|
||
// Create fresh mock config | ||
mockConfig = { assets_bundler: 'webpack' }; | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
describe('getBundler()', () => { | ||
it('returns webpack when assets_bundler is webpack', () => { | ||
mockConfig.assets_bundler = 'webpack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const bundler = utils.getBundler(); | ||
|
||
expect(bundler).toBeDefined(); | ||
expect(bundler.ProvidePlugin).toBeDefined(); | ||
expect(bundler.ProvidePlugin.name).toBe('MockProvidePlugin'); | ||
}); | ||
|
||
it('returns rspack when assets_bundler is rspack', () => { | ||
mockConfig.assets_bundler = 'rspack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const bundler = utils.getBundler(); | ||
|
||
expect(bundler).toBeDefined(); | ||
// Rspack has CssExtractRspackPlugin | ||
expect(bundler.CssExtractRspackPlugin).toBeDefined(); | ||
expect(bundler.CssExtractRspackPlugin.name).toBe('MockCssExtractRspackPlugin'); | ||
}); | ||
}); | ||
|
||
describe('isRspack()', () => { | ||
it('returns false when assets_bundler is webpack', () => { | ||
mockConfig.assets_bundler = 'webpack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
expect(utils.isRspack()).toBe(false); | ||
}); | ||
|
||
it('returns true when assets_bundler is rspack', () => { | ||
mockConfig.assets_bundler = 'rspack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
expect(utils.isRspack()).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('getCssExtractPlugin()', () => { | ||
it('returns mini-css-extract-plugin when using webpack', () => { | ||
mockConfig.assets_bundler = 'webpack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const plugin = utils.getCssExtractPlugin(); | ||
|
||
expect(plugin).toBeDefined(); | ||
expect(plugin.name).toBe('MiniCssExtractPlugin'); | ||
}); | ||
|
||
it('returns CssExtractRspackPlugin when using rspack', () => { | ||
mockConfig.assets_bundler = 'rspack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const plugin = utils.getCssExtractPlugin(); | ||
|
||
expect(plugin).toBeDefined(); | ||
// Rspack plugin class name | ||
expect(plugin.name).toBe('MockCssExtractRspackPlugin'); | ||
}); | ||
}); | ||
|
||
describe('Edge cases and error handling', () => { | ||
it('defaults to webpack when assets_bundler is undefined', () => { | ||
mockConfig.assets_bundler = undefined; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const bundler = utils.getBundler(); | ||
|
||
expect(bundler).toBeDefined(); | ||
expect(bundler.ProvidePlugin.name).toBe('MockProvidePlugin'); | ||
}); | ||
|
||
it('throws error for invalid bundler type', () => { | ||
mockConfig.assets_bundler = 'invalid-bundler'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
expect(() => utils.getBundler()).toThrow('Invalid assets_bundler: "invalid-bundler"'); | ||
expect(() => utils.getBundler()).toThrow('Must be one of: webpack, rspack'); | ||
}); | ||
|
||
it('returns cached bundler on subsequent calls', () => { | ||
mockConfig.assets_bundler = 'webpack'; | ||
jest.doMock('shakapacker', () => ({ config: mockConfig })); | ||
const utils = require('../../../config/webpack/bundlerUtils'); | ||
|
||
const bundler1 = utils.getBundler(); | ||
const bundler2 = utils.getBundler(); | ||
|
||
// Should return same instance (memoized) | ||
expect(bundler1).toBe(bundler2); | ||
}); | ||
}); | ||
}); |
6 changes: 6 additions & 0 deletions
6
client/app/bundles/comments/rescript/ReScriptShow/ror_components/RescriptShow.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Wrapper for ReScript component to work with react_on_rails auto-registration | ||
// react_on_rails looks for components in ror_components/ subdirectories | ||
|
||
import RescriptShow from '../../ReScriptShow.res.js'; | ||
|
||
export default RescriptShow; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Fix the Table of Contents anchor
Renaming the heading to “Webpack and Rspack” means the TOC link
[Webpack](#webpack)
no longer resolves. Please update the TOC entry to match the new slug (#webpack-and-rspack
) to avoid a broken navigation link.🤖 Prompt for AI Agents