Skip to content

Commit 7303d88

Browse files
authored
Merge branch 'main' into chore/biome
2 parents 8130851 + 47aaa8c commit 7303d88

8 files changed

Lines changed: 60 additions & 140 deletions

File tree

.github/workflows/release.yml

Lines changed: 9 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: Release Full
32

43
on:
@@ -29,25 +28,22 @@ on:
2928
- latest
3029
- beta
3130
- alpha
32-
31+
3332
dry_run:
3433
type: boolean
3534
description: "DryRun release"
3635
required: true
3736
default: false
3837

3938
permissions:
39+
contents: write
4040
# To publish packages with provenance
4141
id-token: write
4242

4343
jobs:
4444
release:
4545
name: Release
4646
environment: npm
47-
permissions:
48-
contents: write
49-
# To publish packages with provenance
50-
id-token: write
5147
runs-on: ubuntu-latest
5248

5349
steps:
@@ -63,41 +59,21 @@ jobs:
6359
node-version: 20
6460
cache: "pnpm"
6561

62+
# Update npm to the latest version to enable OIDC
63+
- name: Update npm
64+
run: |
65+
npm install -g npm@latest
66+
npm --version
67+
6668
- name: Install Dependencies
6769
run: pnpm install
6870

6971
- name: Run Test
7072
run: pnpm run test
71-
- name: Obtain OIDC token
72-
id: oidc
73-
run: |
74-
token=$(curl --fail -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" \
75-
"$ACTIONS_ID_TOKEN_REQUEST_URL&audience=cfa.rspack.dev" | jq -r '.value')
76-
echo "::add-mask::${token}"
77-
echo "token=${token}" >> $GITHUB_OUTPUT
78-
shell: bash
79-
- name: Obtain GitHub credentials
80-
id: github_creds
81-
run: |
82-
token=$(curl --fail "https://cfa.rspack.dev/api/request/${{ secrets.CFA_PROJECT_ID }}/github/credentials" \
83-
-X POST \
84-
-H "Content-Type: application/json" \
85-
-H "Authorization: bearer ${{ secrets.CFA_SECRET }}" \
86-
--data "{\"token\":\"${{ steps.oidc.outputs.token }}\"}" | jq -r '.GITHUB_TOKEN')
87-
echo "::add-mask::${token}"
88-
echo "token=${token}" >> $GITHUB_OUTPUT
89-
shell: bash
73+
9074
- name: Try release to npm
9175
run: pnpm run release
9276
env:
9377
DRY_RUN: ${{ inputs.dry_run }}
9478
TAG: ${{ inputs.tag }}
9579
VERSION: ${{ inputs.version }}
96-
CFA_HOST: https://cfa.rspack.dev
97-
GITHUB_TOKEN: ${{ steps.github_creds.outputs.token }}
98-
GITHUB_OIDC_TOKEN: ${{ steps.oidc.outputs.token }}
99-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
100-
CFA_PROJECT_ID: ${{ secrets.CFA_PROJECT_ID }}
101-
CFA_SECRET: ${{ secrets.CFA_SECRET }}
102-
103-

README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ Import the plugin in your code:
3636
```js
3737
// Named import (recommended)
3838
import { ReactRefreshRspackPlugin } from "@rspack/plugin-react-refresh";
39-
4039
```
4140

4241
- CommonJS:
@@ -101,12 +100,31 @@ Compared to the previous approach, this method decouples the React Fast Refresh
101100

102101
## Options
103102

103+
### test
104+
105+
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
106+
- Default: `undefined`
107+
108+
Specifies which files should be processed by the React Refresh loader. This option is passed to the `builtin:react-refresh-loader` as the `rule.test` condition.
109+
110+
Works identically to Rspack's [rule.test](https://rspack.dev/config/module#ruletest) option.
111+
112+
```js
113+
new ReactRefreshPlugin({
114+
test: [/\.jsx$/, /\.tsx$/],
115+
});
116+
```
117+
104118
### include
105119

106120
- Type: [Rspack.RuleSetCondition](https://rspack.dev/config/module#condition)
107121
- Default: `/\.([cm]js|[jt]sx?|flow)$/i`
108122

109-
Include files to be processed by the plugin. The value is the same as the [rule.test](https://rspack.dev/config/module#ruletest) option in Rspack.
123+
Explicitly includes files to be processed by the React Refresh loader. This option is passed to the `builtin:react-refresh-loader` as the `rule.include` condition.
124+
125+
Use this to limit processing to specific directories or file patterns.
126+
127+
Works identically to Rspack's [rule.include](https://rspack.dev/config/module#ruleinclude) option.
110128

111129
```js
112130
new ReactRefreshPlugin({

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@rspack/plugin-react-refresh",
3-
"version": "1.4.3",
3+
"version": "1.5.0",
44
"repository": "https://github.com/rspack-contrib/rspack-plugin-react-refresh",
55
"license": "MIT",
66
"description": "React refresh plugin for Rspack",
@@ -37,7 +37,6 @@
3737
},
3838
"devDependencies": {
3939
"@biomejs/biome": "^1.9.4",
40-
"@continuous-auth/client": "2.3.2",
4140
"@rslib/core": "^0.11.0",
4241
"@rspack/core": "1.4.11",
4342
"@types/jest": "29.5.14",
@@ -72,7 +71,6 @@
7271
"packageManager": "pnpm@10.14.0",
7372
"publishConfig": {
7473
"access": "public",
75-
"registry": "https://registry.npmjs.org/",
76-
"provenance": true
74+
"registry": "https://registry.npmjs.org/"
7775
}
7876
}

pnpm-lock.yaml

Lines changed: 0 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/release.mjs

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
import path from 'path';
22
import * as url from 'url';
3-
import { getOtp } from '@continuous-auth/client';
43
import { $ } from 'execa';
54
import fs from 'fs-extra';
65
import { inc } from 'semver';
76

87
const RELEASE_TAG = process.env.TAG || 'beta';
98
const RELEASE_DRY_RUN = process.env.DRY_RUN || 'true';
109
const RELEASE_VERSION_TYPE = process.env.VERSION || 'prerelease';
11-
const RELEASE_NPM_TOKEN = process.env.NPM_TOKEN || '';
1210

1311
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
1412
const PKG_PATH = path.resolve(__dirname, '../package.json');
@@ -28,29 +26,16 @@ console.info(`Updating version from ${currentVersion} to ${nextVersion}`);
2826
pkg.version = nextVersion;
2927
fs.writeJsonSync(PKG_PATH, pkg, { spaces: 2 });
3028

31-
// Write npmrc
32-
const npmrcPath = `${process.env.HOME}/.npmrc`;
33-
console.info(`Writing npmrc to ${npmrcPath}`);
34-
fs.writeFileSync(
35-
npmrcPath,
36-
`//registry.npmjs.org/:_authToken=${RELEASE_NPM_TOKEN}`,
37-
);
38-
3929
// Publish to npm
4030
console.info(`Publishing to npm with tag ${RELEASE_TAG}`);
4131
const dryRun = RELEASE_DRY_RUN === 'true' ? ['--dry-run'] : [];
42-
console.log('Getting OTP code');
43-
let otp = await getOtp();
44-
console.log('OTP code get, continuing...');
4532

4633
try {
47-
await $`pnpm publish ${dryRun} --tag ${RELEASE_TAG} --otp ${otp} --no-git-checks --provenance`;
34+
await $`pnpm publish ${dryRun} --tag ${RELEASE_TAG} --no-git-checks`;
4835
console.info(`Published successfully`);
4936
} catch (e) {
5037
console.error(`Publish failed: ${e.message}`);
5138
process.exit(1);
52-
} finally {
53-
fs.removeSync(npmrcPath);
5439
}
5540

5641
// Push tag to github

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ReactRefreshRspackPlugin {
8080

8181
if (this.options.injectLoader) {
8282
compiler.options.module.rules.unshift({
83+
test: this.options.test,
8384
// biome-ignore lint: exists
8485
include: this.options.include!,
8586
exclude: {

0 commit comments

Comments
 (0)