Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/cases/preact/prefresh-context/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export default B;
);

await page.waitForFunction(() => {
const aText = document.querySelector('#A')!.textContent;
const bText = document.querySelector('#B')!.textContent;
const aText = document.querySelector('#A')?.textContent;
const bText = document.querySelector('#B')?.textContent;

return (
// the state (count) of A should be kept
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/preact/prefresh-disabled/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default B;
);

await page.waitForFunction(() => {
const aText = document.querySelector('#A')!.textContent;
const bText = document.querySelector('#B')!.textContent;
const aText = document.querySelector('#A')?.textContent;
const bText = document.querySelector('#B')?.textContent;

return (
// the state (count) of A should not be kept
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/preact/prefresh/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default B;
);

await page.waitForFunction(() => {
const aText = document.querySelector('#A')!.textContent;
const bText = document.querySelector('#B')!.textContent;
const aText = document.querySelector('#A')?.textContent;
const bText = document.querySelector('#B')?.textContent;

return (
// the state (count) of A should be kept
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/solid/hmr/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ export default B;
);

await page.waitForFunction(() => {
const aText = document.querySelector('#A')!.textContent;
const bText = document.querySelector('#B')!.textContent;
const aText = document.querySelector('#A')?.textContent;
const bText = document.querySelector('#B')?.textContent;

return (
// the state (count) of A should be kept
Expand Down
6 changes: 3 additions & 3 deletions e2e/scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,11 +261,11 @@ export async function build({
([file]) => file.includes('index') && file.endsWith('.js'),
) || [];

assert(name);
assert(name && content);

return {
content: content!,
size: content!.length / 1024,
content: content,
size: content.length / 1024,
};
};

Expand Down
6 changes: 3 additions & 3 deletions packages/compat/plugin-webpack-swc/tests/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,8 @@ describe('plugin-webpack-swc', () => {
const config = (
await applyPluginConfig(
(config) => {
config.env!.coreJs = '2';
config.env ||= {};
config.env.coreJs = '2';
return config;
},
UTILS,
Expand Down Expand Up @@ -420,8 +421,7 @@ describe('plugin-webpack-swc', () => {
},
});
const config = await rsbuild.unwrapConfig();

expect(config.module!.rules).toMatchSnapshot();
expect(config.module.rules).toMatchSnapshot();
});

it('should allow to disable transformLodash', async () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/compat/webpack/tests/initConfigs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ describe('modifyRsbuildConfig', () => {
});

api.modifyWebpackChain(() => {
config.server!.port = 8899;
config.server ||= {};
config.server.port = 8899;
});
},
},
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/client/overlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class ErrorOverlay extends HTMLElement {
const root = this.attachShadow({ mode: 'open' });
root.innerHTML = html;

root.querySelector('.close')!.addEventListener('click', this.close);
root.querySelector('.close')?.addEventListener('click', this.close);
// close overlay when click outside
this.addEventListener('click', this.close);
root.querySelector('.container')!.addEventListener('click', (e) => {
root.querySelector('.container')?.addEventListener('click', (e) => {
if (e.target) {
const { file } = (e.target as HTMLLinkElement).dataset;
if (file) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/pluginManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export async function initPlugins({
continue;
}
const { instance, environment } = plugin;
await instance.setup(getPluginAPI!(environment));
await instance.setup(getPluginAPI(environment));
}

logger.debug('init plugins done');
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/fileSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async function printFileSizes(
});

const exclude = options.exclude ?? excludeAsset;
const filteredAssets = origin.assets!.filter((asset) => {
const filteredAssets = (origin.assets || []).filter((asset) => {
const assetInfo: PrintFileSizeAsset = {
name: asset.name,
size: asset.size,
Expand Down
6 changes: 4 additions & 2 deletions packages/core/src/plugins/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ const generateManifest =
assets.add(relatedLICENSE);
}

for (const auxiliaryFile of file.chunk!.auxiliaryFiles) {
assets.add(auxiliaryFile);
if (file.chunk) {
for (const auxiliaryFile of file.chunk.auxiliaryFiles) {
assets.add(auxiliaryFile);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/core/tests/mergeConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ describe('mergeRsbuildConfig', () => {
},
});

expect(mergedConfig.tools!.rspack.plugins[0] instanceof A).toBeTruthy();
expect(mergedConfig.tools?.rspack.plugins[0] instanceof A).toBeTruthy();
});

test('should merge overrideBrowserslist in environments as expected', async () => {
Expand Down
13 changes: 8 additions & 5 deletions packages/create-rsbuild/template-vanilla-ts/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import './index.css';

document.querySelector('#root')!.innerHTML = `
<div class="content">
<h1>Vanilla Rsbuild</h1>
<p>Start building amazing things with Rsbuild.</p>
</div>
const rootEl = document.querySelector('#root');
if (rootEl) {
rootEl.innerHTML = `
<div class="content">
<h1>Vanilla Rsbuild</h1>
<p>Start building amazing things with Rsbuild.</p>
</div>
`;
}
3 changes: 2 additions & 1 deletion website/docs/en/config/html/tags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ export default {
// Modify 'a.js' tag
const target = tags.find((tag) => tag.attrs?.src === 'a.js');
if (target) {
target.attrs!.defer = true;
target.attrs ||= {};
target.attrs.defer = true;
}
},
(tags) => {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/en/config/index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Config overview

This page lists all the configurations for Rsbuild. See ["Configure Rsbuild"](/guide/basic/configure-rsbuild) for detail.
This page lists all the configurations for Rsbuild. See ["Configure Rsbuild"](/guide/basic/configure-rsbuild) for details.

import Overview from '@components/Overview';

Expand Down
3 changes: 2 additions & 1 deletion website/docs/zh/config/html/tags.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@ export default {
// 修改 'a.js' 标签
const target = tags.find((tag) => tag.attrs?.src === 'a.js');
if (target) {
target.attrs!.defer = true;
target.attrs ||= {};
target.attrs.defer = true;
}
},
(tags) => {
Expand Down
Loading