Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vitejs/vite-plugin-react
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d758a2a44b0a2cb3c206fa61166cda9d5cf58221
Choose a base ref
...
head repository: vitejs/vite-plugin-react
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: cda8145b8dc5a7211c0e3f8a253b4cac9c2c3d42
Choose a head ref
  • 13 commits
  • 35 files changed
  • 4 contributors

Commits on Jan 15, 2023

  1. fix(deps): update all non-major dependencies (#81)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 15, 2023

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    e935a1f View commit details
  2. chore(deps): update dependency @types/fs-extra to v11 (#82)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 15, 2023
    Copy the full SHA
    c5d045d View commit details

Commits on Jan 23, 2023

  1. chore(deps): update all non-major dependencies (#92)

    Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
    renovate[bot] authored Jan 23, 2023
    Copy the full SHA
    02b8113 View commit details
  2. Copy the full SHA
    105808c View commit details
  3. Copy the full SHA
    545aa67 View commit details

Commits on Jan 25, 2023

  1. Copy the full SHA
    48017b7 View commit details
  2. Copy the full SHA
    c8dd1d6 View commit details
  3. Copy the full SHA
    ff85078 View commit details

Commits on Jan 28, 2023

  1. Copy the full SHA
    6097795 View commit details
  2. Copy the full SHA
    c3e5730 View commit details
  3. Copy the full SHA
    9af763d View commit details

Commits on Feb 2, 2023

  1. Copy the full SHA
    38d71f6 View commit details
  2. Copy the full SHA
    cda8145 View commit details
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -20,7 +20,7 @@
### Before submitting the PR, please make sure you do the following

- [ ] Read the [Contributing Guidelines](https://github.com/vitejs/vite-plugin-react/blob/main/CONTRIBUTING.md).
- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite-plugin-react/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [Commit Convention](https://github.com/vitejs/vite-plugin-react/blob/main/.github/commit-convention.md).
- [ ] Read the [Pull Request Guidelines](https://github.com/vitejs/vite-plugin-react/blob/main/CONTRIBUTING.md#pull-request-guidelines) and follow the [PR Title Convention](https://github.com/vitejs/vite-plugin-react/blob/main/.github/commit-convention.md).
- [ ] Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
- [ ] Provide a description in this PR that addresses **what** the PR is solving, or reference the issue that it solves (e.g. `fixes #123`).
- [ ] Ideally, include relevant tests that fail without this PR but pass with it.
61 changes: 3 additions & 58 deletions .github/commit-convention.md
Original file line number Diff line number Diff line change
@@ -8,64 +8,21 @@ Messages must be matched by the following regex:

<!-- prettier-ignore -->
```js
/^(revert: )?(feat|fix|docs|dx|refactor|perf|test|workflow|build|ci|chore|types|wip|release|deps)(\(.+\))?: .{1,50}/
/^(revert: )?(feat|fix|docs|style|refactor|perf|test|build|ci|chore)(\(.+\))?!?: .{1,50}/
```

#### Examples

Appears under "Features" header, `dev` subheader:

```
feat(dev): add 'comments' option
```

Appears under "Bug Fixes" header, `dev` subheader, with a link to issue #28:

```
fix(dev): fix dev error
close #28
```

Appears under "Performance Improvements" header, and under "Breaking Changes" with the breaking change explanation:

```
perf(build): remove 'foo' option
BREAKING CHANGE: The 'foo' option has been removed.
```

The following commit and commit `667ecc1` do not appear in the changelog if they are under the same release. If not, the revert commit appears under the "Reverts" header.

```
perf(build)!: remove 'foo' option
revert: feat(compiler): add 'comments' option
This reverts commit 667ecc1654a317a13331b17617d973392f415f02.
```

### Full Message Format

A commit message consists of a **header**, **body** and **footer**. The header has a **type**, **scope** and **subject**:

```
<type>(<scope>): <subject>
<BLANK LINE>
<body>
<BLANK LINE>
<footer>
```

The **header** is mandatory and the **scope** of the header is optional.

### Revert

If the commit reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit. In the body, it should say: `This reverts commit <hash>.`, where the hash is the SHA of the commit being reverted.

### Type

If the prefix is `feat`, `fix` or `perf`, it will appear in the changelog. However, if there is any [BREAKING CHANGE](#footer), the commit will always appear in the changelog.

Other prefixes are up to your discretion. Suggested prefixes are `docs`, `chore`, `style`, `refactor`, and `test` for non-changelog related tasks.
If the PR reverts a previous commit, it should begin with `revert: `, followed by the header of the reverted commit

### Scope

@@ -78,15 +35,3 @@ The subject contains a succinct description of the change:
- use the imperative, present tense: "change" not "changed" nor "changes"
- don't capitalize the first letter
- no dot (.) at the end

### Body

Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer

The footer should contain any information about **Breaking Changes** and is also the place to
reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.
2 changes: 0 additions & 2 deletions .github/renovate.json5
Original file line number Diff line number Diff line change
@@ -13,9 +13,7 @@
],
"ignoreDeps": [
// manually bumping
"rollup",
"node",
"typescript",

// breaking changes
"source-map", // `source-map:v0.7.0+` needs more investigation
17 changes: 0 additions & 17 deletions .github/semantic.yml

This file was deleted.

6 changes: 6 additions & 0 deletions .github/workflows/semantic-pull-request.yml
Original file line number Diff line number Diff line change
@@ -15,5 +15,11 @@ jobs:
steps:
- name: Validate PR title
uses: amannn/action-semantic-pull-request@v5
with:
subjectPattern: ^(?![A-Z]).+$
subjectPatternError: |
The subject "{subject}" found in the pull request title "{title}"
didn't match the configured pattern. Please ensure that the subject
doesn't start with an uppercase character.
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -27,10 +27,10 @@ This repo is a monorepo using pnpm workspaces. The package manager used to insta

- Make sure tests pass!

- Commit messages must follow the [commit message convention](./.github/commit-convention.md) so that changelogs can be automatically generated. Commit messages are automatically validated before commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).

- No need to worry about code style as long as you have installed the dev dependencies. Modified files are automatically formatted with Prettier on commit (by invoking [Git Hooks](https://git-scm.com/docs/githooks) via [simple-git-hooks](https://github.com/toplenboren/simple-git-hooks)).

- PR title must follow the [commit message convention](./.github/commit-convention.md) so that changelogs can be automatically generated.

## Running Tests

### Integration Tests
57 changes: 25 additions & 32 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@vitejs/vite-plugin-react-monorepo",
"private": true,
"type": "module",
"engines": {
"node": "^14.18.0 || >=16.0.0"
},
@@ -18,55 +19,47 @@
"postinstall": "simple-git-hooks",
"format": "prettier --write --cache .",
"lint": "eslint --cache .",
"typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit",
"typecheck": "tsc -p scripts && tsc -p playground && tsc -p packages/plugin-react",
"test": "run-s test-serve test-build",
"test-serve": "vitest run -c vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts",
"test-build-without-plugin-commonjs": "VITE_TEST_WITHOUT_PLUGIN_COMMONJS=1 pnpm test-build",
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts",
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts",
"test-serve": "vitest run -c playground/vitest.config.e2e.ts",
"test-build": "VITE_TEST_BUILD=1 vitest run -c playground/vitest.config.e2e.ts",
"debug-serve": "VITE_DEBUG_SERVE=1 vitest run -c playground/vitest.config.e2e.ts",
"debug-build": "VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c playground/vitest.config.e2e.ts",
"build": "pnpm -r --filter='./packages/*' run build",
"dev": "pnpm -r --parallel --filter='./packages/*' run dev",
"release": "tsx scripts/release.ts",
"ci-publish": "tsx scripts/publishCI.ts"
},
"devDependencies": {
"@types/babel__core": "^7.1.20",
"@types/fs-extra": "^9.0.13",
"@types/minimist": "^1.2.2",
"@types/babel__core": "^7.20.0",
"@types/fs-extra": "^11.0.1",
"@types/node": "^18.11.18",
"@types/picomatch": "^2.3.0",
"@types/prompts": "^2.4.2",
"@types/semver": "^7.3.13",
"@typescript-eslint/eslint-plugin": "^5.47.1",
"@typescript-eslint/parser": "^5.47.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vitejs/release-scripts": "^1.1.0",
"conventional-changelog-cli": "^2.2.2",
"eslint": "^8.31.0",
"eslint-define-config": "^1.13.0",
"eslint-plugin-import": "^2.26.0",
"eslint": "^8.32.0",
"eslint-define-config": "^1.14.0",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-regexp": "^1.11.0",
"eslint-plugin-regexp": "^1.12.0",
"execa": "^6.1.0",
"fs-extra": "^11.1.0",
"lint-staged": "^13.1.0",
"minimist": "^1.2.7",
"npm-run-all": "^4.1.5",
"picocolors": "^1.0.0",
"playwright-chromium": "^1.29.1",
"prettier": "2.8.1",
"prompts": "^2.4.2",
"rollup": "^3.7.0",
"semver": "^7.3.8",
"playwright-chromium": "^1.29.2",
"prettier": "2.8.3",
"rollup": "^3.10.1",
"simple-git-hooks": "^2.8.1",
"tsx": "^3.12.1",
"typescript": "^4.6.4",
"unbuild": "^1.0.2",
"vite": "^4.0.3",
"vitest": "^0.26.3"
"tsx": "^3.12.2",
"typescript": "^4.9.4",
"unbuild": "^1.1.1",
"vite": "^4.1.0-beta.0",
"vitest": "^0.27.3"
},
"simple-git-hooks": {
"pre-commit": "pnpm exec lint-staged --concurrent false",
"commit-msg": "pnpm exec tsx scripts/verifyCommit.ts $1"
"pre-commit": "pnpm exec lint-staged --concurrent false"
},
"lint-staged": {
"*": [
@@ -82,5 +75,5 @@
"eslint --cache --fix"
]
},
"packageManager": "pnpm@7.21.0"
"packageManager": "pnpm@7.25.1"
}
16 changes: 16 additions & 0 deletions packages/plugin-react/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 3.1.0 (2023-02-02)

* doc: add jsxImportSource option ([38d71f6](https://github.com/vitejs/vite-plugin-react/commit/38d71f6))
* chore: bump release-scripts, typecheck package in CI, remove cache for eslint ([9af763d](https://github.com/vitejs/vite-plugin-react/commit/9af763d))
* fix: fast-refresh explain link (#97) ([6097795](https://github.com/vitejs/vite-plugin-react/commit/6097795)), closes [#97](https://github.com/vitejs/vite-plugin-react/issues/97)



## 3.1.0-beta.0 (2023-01-25)

* fix: add RefreshSig to refresh content regex (closes #52) ([c8dd1d6](https://github.com/vitejs/vite-plugin-react/commit/c8dd1d6)), closes [#52](https://github.com/vitejs/vite-plugin-react/issues/52)
* fix(deps): update all non-major dependencies (#81) ([e935a1f](https://github.com/vitejs/vite-plugin-react/commit/e935a1f)), closes [#81](https://github.com/vitejs/vite-plugin-react/issues/81)
* feat: invalidate message and fix HMR for HOC, class component & styled component (#79) ([48017b7](https://github.com/vitejs/vite-plugin-react/commit/48017b7)), closes [#79](https://github.com/vitejs/vite-plugin-react/issues/79)



## <small>3.0.1 (2023-01-05)</small>

* fix: don't invalidate when code is invalid (#67) ([9231a86](https://github.com/vitejs/vite-plugin-react/commit/9231a86)), closes [#67](https://github.com/vitejs/vite-plugin-react/issues/67)
18 changes: 18 additions & 0 deletions packages/plugin-react/README.md
Original file line number Diff line number Diff line change
@@ -33,6 +33,16 @@ react({
})
```

### Configure the JSX import source

Control where the JSX factory is imported from. This option is ignored for classic `jsxRuntime`.

```js
react({
jsxImportSource: '@emotion/react',
})
```

## Opting out of the automatic JSX runtime

By default, the plugin uses the [automatic JSX runtime](https://github.com/alloc/vite-react-jsx#faq). However, if you encounter any issues, you may opt out using the `jsxRuntime` option.
@@ -105,3 +115,11 @@ Otherwise, you'll probably get this error:
```
Uncaught Error: @vitejs/plugin-react can't detect preamble. Something is wrong.
```

## Consistent components exports

For React refresh to work correctly, your file should only export React components. You can find a good explanation in the [Gatsby docs](https://www.gatsbyjs.com/docs/reference/local-development/fast-refresh/#how-it-works).

If an incompatible change in exports is found, the module will be invalidated and HMR will propagate. To make it easier to export simple constants alongside your component, the module is only invalidated when their value changes.

You can catch mistakes and get more detailed warning with this [eslint rule](https://github.com/ArnaudBarre/eslint-plugin-react-refresh).
11 changes: 6 additions & 5 deletions packages/plugin-react/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "@vitejs/plugin-react",
"version": "3.0.1",
"version": "3.1.0",
"license": "MIT",
"author": "Evan You",
"contributors": [
"Alec Larson"
"Alec Larson",
"Arnaud Barré"
],
"files": [
"dist"
@@ -21,7 +22,7 @@
},
"scripts": {
"dev": "unbuild --stub",
"build": "unbuild && pnpm run patch-cjs",
"build": "unbuild && pnpm run patch-cjs && tsx scripts/copyRefreshUtils.ts",
"patch-cjs": "tsx ../../scripts/patchCJS.ts",
"prepublishOnly": "npm run build"
},
@@ -38,13 +39,13 @@
},
"homepage": "https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react#readme",
"dependencies": {
"@babel/core": "^7.20.7",
"@babel/core": "^7.20.12",
"@babel/plugin-transform-react-jsx-self": "^7.18.6",
"@babel/plugin-transform-react-jsx-source": "^7.19.6",
"magic-string": "^0.27.0",
"react-refresh": "^0.14.0"
},
"peerDependencies": {
"vite": "^4.0.0"
"vite": "^4.1.0-beta.0"
}
}
3 changes: 3 additions & 0 deletions packages/plugin-react/scripts/copyRefreshUtils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { copyFileSync } from 'node:fs'

copyFileSync('src/refreshUtils.js', 'dist/refreshUtils.js')
1 change: 0 additions & 1 deletion packages/plugin-react/src/babel.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
declare module '@babel/plugin-transform-react-jsx'
declare module '@babel/plugin-transform-react-jsx-self'
declare module '@babel/plugin-transform-react-jsx-source'
declare module 'react-refresh/babel.js'
Loading