Skip to content
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

chore: correct some cases #3830

Merged
merged 3 commits into from
Oct 26, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
timeout-minutes: 15
strategy:
matrix:
# run ut in MacOS, as SWC cases will fail in Ubuntu CI
# run ut in macOS, as SWC cases will fail in Ubuntu CI
os: [macos-14, windows-latest]

steps:
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/assets/assets-retry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ test('@rsbuild/plugin-assets-retry should work when blocking async chunk`', asyn
logger.level = 'log';
});

test('@rsbuild/plugin-assets-retry should work when blocking async css chunk`', async ({
test('@rsbuild/plugin-assets-retry should work when blocking async CSS chunk`', async ({
page,
}) => {
logger.level = 'verbose';
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/config/rspack-config-validate/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { expect } from '@playwright/test';
import { pluginReact } from '@rsbuild/plugin-react';
import stripAnsi from 'strip-ansi';

rspackOnlyTest('should validate rspack config by default', async () => {
rspackOnlyTest('should validate Rspack config by default', async () => {
try {
await build({
cwd: __dirname,
Expand Down Expand Up @@ -44,7 +44,7 @@ rspackOnlyTest('should warn when passing unrecognized keys', async () => {
restore();
});

rspackOnlyTest('should allow to override rspack config validate', async () => {
rspackOnlyTest('should allow to override Rspack config validate', async () => {
const { RSPACK_CONFIG_VALIDATE } = process.env;
process.env.RSPACK_CONFIG_VALIDATE = 'loose';

Expand Down
12 changes: 6 additions & 6 deletions e2e/cases/css/ignore-css/removeCss.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { build } from '@e2e/helper';
import { expect, test } from '@playwright/test';

test('should ignore css content when build node target', async () => {
test('should ignore CSS content when build node target', async () => {
const rsbuild = await build({
cwd: __dirname,
rsbuildConfig: {
Expand All @@ -15,14 +15,14 @@ test('should ignore css content when build node target', async () => {
const content =
files[Object.keys(files).find((file) => file.endsWith('.js'))!];

// preserve css modules mapping
// preserve CSS Modules mapping
expect(content.includes('"title-class":')).toBeTruthy();
// remove css content
// remove CSS content
expect(content.includes('.title-class')).toBeFalsy();
expect(content.includes('.header-class')).toBeFalsy();
});

test('should ignore css content when build web-worker target', async () => {
test('should ignore CSS content when build web-worker target', async () => {
const rsbuild = await build({
cwd: __dirname,
rsbuildConfig: {
Expand All @@ -36,9 +36,9 @@ test('should ignore css content when build web-worker target', async () => {
const content =
files[Object.keys(files).find((file) => file.endsWith('.js'))!];

// preserve css modules mapping
// preserve CSS Modules mapping
expect(content.includes('"title-class":')).toBeTruthy();
// remove css content
// remove CSS content
expect(content.includes('.title-class')).toBeFalsy();
expect(content.includes('.header-class')).toBeFalsy();
});
2 changes: 1 addition & 1 deletion e2e/cases/css/multi-css/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import path from 'node:path';
import { build, rspackOnlyTest } from '@e2e/helper';
import { expect } from '@playwright/test';

rspackOnlyTest('should emit multiple css files correctly', async () => {
rspackOnlyTest('should emit multiple CSS files correctly', async () => {
const rsbuild = await build({
cwd: __dirname,
rsbuildConfig: {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/css/style-loader-lightningcss/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ rspackOnlyTest(
// injectStyles worked
const files = await rsbuild.unwrapOutputJSON();

// should inline minified css
// should inline minified CSS
const indexJsFile = Object.keys(files).find(
(file) => file.includes('index.') && file.endsWith('.js'),
)!;
Expand Down
8 changes: 4 additions & 4 deletions e2e/cases/css/style-loader/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rspackOnlyTest(
const cssFiles = Object.keys(files).filter((file) => file.endsWith('.css'));
expect(cssFiles.length).toBe(0);

// should inline minified css
// should inline minified CSS
const indexJsFile = Object.keys(files).find(
(file) => file.includes('index.') && file.endsWith('.js'),
)!;
Expand All @@ -45,7 +45,7 @@ rspackOnlyTest(
);

rspackOnlyTest(
'hmr should work well when injectStyles is true',
'HMR should work well when injectStyles is true',
async ({ page }) => {
// HMR cases will fail in Windows
if (process.platform === 'win32') {
Expand Down Expand Up @@ -88,10 +88,10 @@ rspackOnlyTest(
fs.readFileSync(filePath, 'utf-8').replace('20px', '40px'),
);

// css hmr works well
// CSS HMR works well
await expect(title).toHaveCSS('font-size', '40px');

// #test-keep should unchanged when css hmr
// #test-keep should unchanged when CSS HMR
await expect(locatorKeep.innerHTML()).resolves.toBe(keepNum);

await rsbuild.close();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/output/charset/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ test('should allow to set output.charset to ascii', async ({ page }) => {
([name]) => name.endsWith('.js') && name.includes('static/js/index'),
)!;

// in rspack is: \\u4f60\\u597D world!
// in Rspack is: \\u4f60\\u597D world!
expect(
content.toLocaleLowerCase().includes('\\u4f60\\u597d world!'),
).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/preact/prefresh-disabled/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import { dev, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';

rspackOnlyTest('hmr should work properly', async ({ page }) => {
rspackOnlyTest('HMR should work properly', async ({ page }) => {
// HMR cases will fail in Windows
if (process.platform === 'win32') {
test.skip();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/preact/prefresh/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import { dev, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';

rspackOnlyTest('hmr should work properly', async ({ page }) => {
rspackOnlyTest('HMR should work properly', async ({ page }) => {
// HMR cases will fail in Windows
if (process.platform === 'win32') {
test.skip();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/server/environments-hmr/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ rspackOnlyTest(

await expect(locatorKeep.innerHTML()).resolves.toBe(keepNum);

// index hmr correctly
// index HMR correctly
const appPath = join(cwd, 'test-temp-src/App.tsx');

await fs.promises.writeFile(
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/solid/hmr/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'node:path';
import { dev, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';

rspackOnlyTest('hmr should work properly', async ({ page }) => {
rspackOnlyTest('HMR should work properly', async ({ page }) => {
// HMR cases will fail in Windows
if (process.platform === 'win32') {
test.skip();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/solid/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ rspackOnlyTest(
},
);

// test cases for css preprocessors
// test cases for CSS preprocessors
for (const name of ['less', 'scss', 'stylus']) {
rspackOnlyTest(
`should build solid component with ${name}`,
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/svelte/hmr/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { dev, rspackOnlyTest } from '@e2e/helper';
import { expect, test } from '@playwright/test';
import { pluginSvelte } from '@rsbuild/plugin-svelte';

rspackOnlyTest('hmr should work properly', async ({ page }) => {
rspackOnlyTest('HMR should work properly', async ({ page }) => {
// HMR cases will fail in Windows
if (process.platform === 'win32') {
test.skip();
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/svelte/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ rspackOnlyTest(
},
);

// test cases for css preprocessors
// test cases for CSS preprocessors
for (const name of ['less', 'scss', 'stylus']) {
rspackOnlyTest(
`should build svelte component with ${name}`,
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/svg/svg-assets/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ test('SVGR basic usage', async ({ page }) => {
page,
});

// test svg asset
// test SVG asset
await expect(
page.evaluate(
`document.getElementById('test-img').src.includes('static/svg/mobile')`,
),
).resolves.toBeTruthy();

// test svg asset in css
// test SVG asset in CSS
await expect(
page.evaluate(
`getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('static/svg/mobile')`,
Expand Down
6 changes: 3 additions & 3 deletions e2e/cases/svg/svgr-default-export-url/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ test('should import default from SVG with SVGR correctly', async ({ page }) => {
page.evaluate(`document.getElementById('component').tagName === 'svg'`),
).resolves.toBeTruthy();

// test svg asset
// test SVG asset
await expect(
page.evaluate(`document.getElementById('large-img').src`),
).resolves.toMatch(/http:/);

// test svg asset
// test SVG asset
await expect(
page.evaluate(
`document.getElementById('small-img').src.startsWith('data:image/svg')`,
),
).resolves.toBeTruthy();

// test svg asset in css
// test SVG asset in CSS
await expect(
page.evaluate(
`getComputedStyle(document.getElementById('test-css-small')).backgroundImage.includes('url("data:image/svg')`,
Expand Down
6 changes: 3 additions & 3 deletions e2e/cases/svg/svgr-external-react/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { build } from '@e2e/helper';
import { expect, test } from '@playwright/test';

// It's an old bug when use svgr in css and external react.
// It's an old bug when use svgr in CSS and external react.
test('use SVGR and externals react', async ({ page }) => {
const rsbuild = await build({
cwd: __dirname,
Expand All @@ -13,14 +13,14 @@ test('use SVGR and externals react', async ({ page }) => {
page.evaluate(`document.getElementById('test-svg').tagName === 'svg'`),
).resolves.toBeTruthy();

// test svg asset
// test SVG asset
await expect(
page.evaluate(
`document.getElementById('test-img').src.startsWith('data:image/svg')`,
),
).resolves.toBeTruthy();

// test svg asset in css
// test SVG asset in CSS
await expect(
page.evaluate(
`getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('url("data:image/svg')`,
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/svg/svgr-query-custom/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('should import default from SVG with custom query correctly', async ({
page.evaluate(`document.getElementById('component').tagName === 'svg'`),
).resolves.toBeTruthy();

// test svg asset
// test SVG asset
await expect(
page.evaluate(`document.getElementById('url').src`),
).resolves.toMatch(/http:/);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test('should import default from SVG with react query and dynamic import correct
page.evaluate(`document.getElementById('component').tagName === 'svg'`),
).resolves.toBeTruthy();

// test svg asset
// test SVG asset
await expect(
page.evaluate(`document.getElementById('url').src`),
).resolves.toMatch(/http:/);
Expand Down
2 changes: 1 addition & 1 deletion e2e/cases/svg/svgr-query-react/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test('should import default from SVG with react query correctly', async ({
page.evaluate(`document.getElementById('component').tagName === 'svg'`),
).resolves.toBeTruthy();

// test svg asset
// test SVG asset
await expect(
page.evaluate(`document.getElementById('url').src`),
).resolves.toMatch(/http:/);
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/svg/svgr-query-url/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ test('should import svg with SVGR plugin and query URL correctly', async ({
page,
});

// test svg asset
// test SVG asset
await expect(
page.evaluate(
`document.getElementById('test-img').src.includes('static/svg/mobile')`,
),
).resolves.toBeTruthy();

// test svg asset in css
// test SVG asset in CSS
await expect(
page.evaluate(
`getComputedStyle(document.getElementById('test-css')).backgroundImage.includes('static/svg/mobile')`,
Expand Down
2 changes: 1 addition & 1 deletion e2e/scripts/shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export async function dev({

rsbuild.addPlugins([
{
// fix hmr problem temporary (only appears in rsbuild repo, because css-loader is not in node_modules/ )
// fix HMR problem temporary (only appears in rsbuild repo, because css-loader is not in node_modules/ )
// https://github.com/web-infra-dev/rspack/issues/5723
name: 'fix-react-refresh-in-rsbuild',
setup(api) {
Expand Down
8 changes: 4 additions & 4 deletions packages/compat/plugin-webpack-swc/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
/**
* In this plugin, we do:
* - Remove Babel loader if exists
* - Add our own swc loader
* - Add our own swc-loader
* - Remove JS minifier
* - Add swc minifier plugin
* - Add SWC minifier plugin
*/
export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({
name: 'rsbuild-webpack:swc',
Expand Down Expand Up @@ -63,7 +63,7 @@ export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({
i > 0 ? CHAIN_ID.RULE.JS + i.toString() : CHAIN_ID.RULE.JS;
const rule = chain.module.rule(ruleId);

// Insert swc loader and plugin
// Insert SWC loader and plugin
rule
.test(test || /\.(?:js|jsx|mjs|cjs|ts|tsx|mts|cts)$/)
.use(CHAIN_ID.USE.SWC)
Expand Down Expand Up @@ -152,7 +152,7 @@ export const pluginSwc = (options: PluginSwcOptions = {}): RsbuildPlugin => ({
},
});

/// default swc configuration
/// default SWC configuration
export function getDefaultSwcConfig(): TransformConfig {
const cwd = process.cwd();
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/compat/plugin-webpack-swc/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export async function finalizeConfig(
const objConfig = isUsingFnOptions ? {} : userConfig;
const defaultConfig = getDefaultSwcConfig();

// apply swc default config
// apply SWC default config
let swcConfig: ObjPluginSwcOptions = _.merge(
{},
defaultConfig,
Expand Down
Loading
Loading