Skip to content

Commit 5a29c95

Browse files
committed
Make isRspack strict and align tests
1 parent 29ad680 commit 5a29c95

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

client/__tests__/webpack/bundlerUtils.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,12 @@ describe('bundlerUtils', () => {
8080
expect(utils.isRspack()).toBe(true);
8181
});
8282

83-
it('returns false when assets_bundler is webpack', () => {
83+
it('throws when assets_bundler is webpack', () => {
8484
mockConfig.assets_bundler = 'webpack';
8585
jest.doMock('shakapacker', () => ({ config: mockConfig }));
8686
const utils = require('../../../config/webpack/bundlerUtils');
8787

88-
expect(utils.isRspack()).toBe(false);
88+
expect(() => utils.isRspack()).toThrow('configured for Rspack only');
8989
});
9090
});
9191

config/webpack/bundlerUtils.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ const getBundler = () => {
3737
return _cachedBundler;
3838
};
3939

40+
/**
41+
* Validates rspack-only mode and returns true.
42+
*
43+
* @returns {boolean} Always true after validation
44+
*/
45+
const isRspack = () => {
46+
ensureRspack();
47+
return true;
48+
};
49+
4050
/**
4151
* Gets the CSS extraction plugin for Rspack.
4252
*
@@ -46,5 +56,6 @@ const getCssExtractPlugin = () => getBundler().CssExtractRspackPlugin;
4656

4757
module.exports = {
4858
getBundler,
59+
isRspack,
4960
getCssExtractPlugin,
5061
};

0 commit comments

Comments
 (0)