Skip to content

Commit

Permalink
Merge branch 'main' into lightning_css_minify_0621
Browse files Browse the repository at this point in the history
  • Loading branch information
chenjiahan committed Jun 27, 2024
2 parents 7a87d5c + ea87273 commit 964fc04
Show file tree
Hide file tree
Showing 377 changed files with 4,630 additions and 2,821 deletions.
10 changes: 9 additions & 1 deletion .github/renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@
"packagePatterns": ["modern-js"],
"groupSlug": "modern-js"
},
{
"groupName": "eslint",
"packagePatterns": ["eslint"],
"groupSlug": "eslint"
},
{
"groupName": "types",
"packagePatterns": ["^@types/"],
Expand All @@ -50,7 +55,6 @@
"ignoreDeps": [
// manually update some packages
"pnpm",
"core-js",
"esbuild",
"typescript",
// related to the SWC version built into Rspack
Expand All @@ -64,6 +68,10 @@
"gzip-size",
"globby",
"open",
"strip-ansi",
"ansi-escapes",
"cli-truncate",
"patch-console",
// buffer v6 has compatibility issues as node polyfill
"buffer",
// align Node.js version minimum requirements
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/release-nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ name: Release Nightly

on:
workflow_dispatch:
# Nightly release disabled
# schedule:
# 00:00 AM Beijing Time.
# - cron: "0 16 * * *"

permissions:
# To publish packages with provenance
id-token: write

jobs:
Expand Down
6 changes: 5 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"recommendations": ["biomejs.biome"]
"recommendations": [
"biomejs.biome",
"esbenp.prettier-vscode",
"unifiedjs.vscode-mdx"
]
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@
"files.exclude": {
"**/.DS_Store": true
},
"mdx.validate.validateFileLinks": "ignore"
"mdx.validate.validateFileLinks": "ignore",
"editor.defaultFormatter": "esbenp.prettier-vscode",
"typescript.tsdk": "node_modules/typescript/lib"
}
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Thanks for that you are interested in contributing to Rsbuild. Before starting y
[Fork](https://help.github.com/articles/fork-a-repo/) this repository to your
own GitHub account and then [clone](https://help.github.com/articles/cloning-a-repository/) it to your local.

## Branches

- `main` -> Rsbuild v1.x
- `v0.x` -> Rsbuild v0.x

### Install Node.js

We recommend using Node.js 20. You can check your currently used Node.js version with the following command:
Expand Down
10 changes: 3 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<a href="https://discord.gg/XsaKEEk4mW">
<img src="https://img.shields.io/badge/chat-discord-blue?style=flat-square&logo=discord&colorA=564341&colorB=EDED91" alt="discord channel" />
</a>
<a href="https://npmjs.com/package/@rsbuild/shared?activeTab=readme">
<img src="https://img.shields.io/npm/v/@rsbuild/shared?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
<a href="https://npmjs.com/package/@rsbuild/core?activeTab=readme">
<img src="https://img.shields.io/npm/v/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
</a>
<a href="https://npmcharts.com/compare/@rsbuild/core?minimal=true">
<img src="https://img.shields.io/npm/dm/@rsbuild/core.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" />
Expand All @@ -18,7 +18,7 @@
<img src="https://img.shields.io/node/v/@rsbuild/core.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="node version">
</a>
<a href="https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/@rsbuild/shared?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
</a>
</p>

Expand Down Expand Up @@ -78,10 +78,6 @@ The following diagram illustrates the relationship between Rsbuild and other too

![Rspack Ecosystem](https://github.com/web-infra-dev/rsbuild/assets/7237365/1ec93ad6-b8b1-475b-963f-cba1e7d79dec)

## 📍 Roadmap

We plan to release Rsbuild v1.0 before July 2024 (based in Rspack v1.0), see [Rsbuild v1.0 Release Plan](https://github.com/web-infra-dev/rsbuild/discussions/1678).

## 📚 Getting Started

To get started with Rsbuild, see the [Quick Start](https://rsbuild.dev/guide/start/quick-start).
Expand Down
10 changes: 3 additions & 7 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
<a href="https://discord.gg/XsaKEEk4mW">
<img src="https://img.shields.io/badge/chat-discord-blue?style=flat-square&logo=discord&colorA=564341&colorB=EDED91" alt="discord channel" />
</a>
<a href="https://npmjs.com/package/@rsbuild/shared?activeTab=readme">
<img src="https://img.shields.io/npm/v/@rsbuild/shared?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
<a href="https://npmjs.com/package/@rsbuild/core?activeTab=readme">
<img src="https://img.shields.io/npm/v/@rsbuild/core?style=flat-square&colorA=564341&colorB=EDED91" alt="npm version" />
</a>
<a href="https://npmcharts.com/compare/@rsbuild/core?minimal=true">
<img src="https://img.shields.io/npm/dm/@rsbuild/core.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="downloads" />
Expand All @@ -18,7 +18,7 @@
<img src="https://img.shields.io/node/v/@rsbuild/core.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="node version">
</a>
<a href="https://github.com/web-infra-dev/rsbuild/blob/main/LICENSE">
<img src="https://img.shields.io/npm/l/@rsbuild/shared?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
<img src="https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square&colorA=564341&colorB=EDED91" alt="license" />
</a>
</p>

Expand Down Expand Up @@ -78,10 +78,6 @@ Rsbuild 具备以下特性:

![Rspack Ecosystem](https://github.com/web-infra-dev/rsbuild/assets/7237365/1ec93ad6-b8b1-475b-963f-cba1e7d79dec)

## 📍 路线图

我们计划在 2024 年 7 月之前发布 Rsbuild v1.0(基于 Rspack v1.0),参见 [Rsbuild v1.0 Release Plan](https://github.com/web-infra-dev/rsbuild/discussions/1678)

## 📚 快速上手

你可以参考 [快速上手](https://rsbuild.dev/zh/guide/start/quick-start) 来开始体验 Rsbuild。
Expand Down
9 changes: 9 additions & 0 deletions e2e/cases/babel/decorator/rsbuild.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { defineConfig } from '@rsbuild/core';

export default defineConfig({
source: {
decorators: {
version: 'legacy',
},
},
});
3 changes: 2 additions & 1 deletion e2e/cases/babel/preset-node/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ rspackOnlyTest(
runServer: true,
});

const { foo } = await import('./dist/server/index.js');
// @ts-ignore .js file
const { foo } = await import('./dist/index.js');
expect(foo).toEqual(1);
},
);
37 changes: 37 additions & 0 deletions e2e/cases/environments/outputs/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { build } from '@e2e/helper';
import { expect, test } from '@playwright/test';

test('should apply multiple dist path correctly', async () => {
const rsbuild = await build({
cwd: __dirname,
rsbuildConfig: {
environments: {
web: {
output: {
filenameHash: false,
},
},
web1: {
output: {
filenameHash: false,
distPath: {
root: 'dist/web1',
},
},
},
},
},
});

const files = await rsbuild.unwrapOutputJSON();
const filenames = Object.keys(files);

expect(
filenames.some((filename) => filename.includes('dist/static/js/index.js')),
).toBeTruthy();
expect(
filenames.some((filename) =>
filename.includes('dist/web1/static/js/index.js'),
),
).toBeTruthy();
});
1 change: 1 addition & 0 deletions e2e/cases/environments/outputs/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log('hello!');
2 changes: 1 addition & 1 deletion e2e/cases/javascript-api/custom-logger/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ rspackOnlyTest('should allow to customize logger', async () => {
});

expect(
logs.find((item) => item.includes('[READY] Client compiled in')),
logs.find((item) => item.includes('[READY] Compiled in')),
).toBeTruthy();

restore();
Expand Down
14 changes: 6 additions & 8 deletions e2e/cases/node-addons/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ test('should compile Node addons correctly', async () => {
file.endsWith('test.darwin.node'),
);

expect(addonFile?.includes('server/test.darwin.node')).toBeTruthy();
expect(addonFile?.includes('/test.darwin.node')).toBeTruthy();

expect(
fs.existsSync(join(__dirname, 'dist', 'server', 'test.darwin.node')),
fs.existsSync(join(__dirname, 'dist', 'test.darwin.node')),
).toBeTruthy();

// the `test.darwin.node` is only compatible with darwin
if (process.platform === 'darwin') {
const content = await import('./dist/server/index.js');
const content = await import('./dist/index.js');
expect(typeof (content.default as any).readLength).toEqual('function');
}
});
Expand Down Expand Up @@ -61,14 +61,12 @@ test('should compile Node addons in the node_modules correctly', async () => {
file.endsWith('other.node'),
);

expect(addonFile?.includes('server/other.node')).toBeTruthy();
expect(addonFile?.includes('/other.node')).toBeTruthy();

expect(
fs.existsSync(join(__dirname, 'dist', 'server', 'other.node')),
).toBeTruthy();
expect(fs.existsSync(join(__dirname, 'dist', 'other.node'))).toBeTruthy();

if (process.platform === 'darwin') {
const content = await import('./dist/server/index.js');
const content = await import('./dist/index.js');
expect(typeof (content.default as any).readLength).toEqual('function');
}
});
46 changes: 46 additions & 0 deletions e2e/cases/nonce/basic/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,49 @@ test('should apply nonce to script and style tags', async () => {
);
expect(html).toContain(`<style nonce="CSP_NONCE_PLACEHOLDER">body{`);
});

test('should apply environment nonce', async () => {
const rsbuild = await build({
cwd: __dirname,
rsbuildConfig: {
environments: {
web: {
security: {
nonce: 'CSP_NONCE_PLACEHOLDER',
},
output: {
distPath: {
root: 'dist',
},
},
},
web1: {
security: {
nonce: 'CSP_NONCE_PLACEHOLDER1',
},
output: {
distPath: {
root: 'dist/dist1',
},
},
},
},
},
});
const files = await rsbuild.unwrapOutputJSON();
const html =
files[Object.keys(files).find((file) => file.endsWith('dist/index.html'))!];
expect(html).toContain(
`<script defer="defer" nonce="CSP_NONCE_PLACEHOLDER">`,
);
expect(html).toContain(`<style nonce="CSP_NONCE_PLACEHOLDER">body{`);

const html1 =
files[
Object.keys(files).find((file) => file.endsWith('dist1/index.html'))!
];
expect(html1).toContain(
`<script defer="defer" nonce="CSP_NONCE_PLACEHOLDER1">`,
);
expect(html1).toContain(`<style nonce="CSP_NONCE_PLACEHOLDER1">body{`);
});
2 changes: 1 addition & 1 deletion e2e/cases/output/externals/tests/index.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { join, resolve } from 'node:path';
import { resolve } from 'node:path';
import { build, gotoPage } from '@e2e/helper';
import { expect, test } from '@playwright/test';
import { pluginReact } from '@rsbuild/plugin-react';
Expand Down
12 changes: 11 additions & 1 deletion e2e/cases/performance/print-file-size/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ test.describe('should print file size correctly', async () => {
expect(logs.some((log) => log.includes('Gzipped size:'))).toBeTruthy();
});

test('should print size of multiple targets correctly', async () => {
test('should print size of multiple environments correctly', async () => {
await build({
cwd,
rsbuildConfig: {
Expand All @@ -52,13 +52,20 @@ test.describe('should print file size correctly', async () => {
node: {
output: {
target: 'node',
distPath: {
root: 'dist/server',
},
},
},
},
},
});

// dist/index.html
expect(
logs.some((log) => log.includes('File') && log.includes('(web)')),
).toBeTruthy();

expect(
logs.some(
(log) =>
Expand All @@ -69,6 +76,9 @@ test.describe('should print file size correctly', async () => {
).toBeTruthy();

// dist/server/index.js
expect(
logs.some((log) => log.includes('File') && log.includes('(node)')),
).toBeTruthy();
expect(
logs.some(
(log) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export default {
node: {
output: {
target: 'node',
distPath: {
root: 'dist/server',
},
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions e2e/cases/progress/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ webpackOnlyTest('should emit progress log in non-TTY environment', async () => {
});

expect(
infoMsgs.some((message) => message.includes('Client compile progress')),
infoMsgs.some((message) => message.includes('Compile progress')),
).toBeTruthy();
expect(
readyMsgs.some((message) => message.includes('Client compiled')),
readyMsgs.some((message) => message.includes('Compiled')),
).toBeTruthy();

process.stdout.isTTY = true;
Expand Down
Loading

0 comments on commit 964fc04

Please sign in to comment.