Skip to content

[1.x] Vite 5 #269

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

Merged
merged 10 commits into from
Dec 15, 2023
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/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x]
node-version: [18.x, 20.x, 21.x]

steps:
- name: Checkout code
Expand Down
31 changes: 31 additions & 0 deletions UPGRADE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Upgrade Guide

## `0.x` to `1.x`

This release adds support for Vite 5 and removes support for Vite 3 and 4.

### Notable Changes

1. Dropped support for CJS: https://github.com/laravel/vite-plugin/pull/235
2. Dropped support for a `boolean` value of `server.https` option in `vite.config.js`: https://github.com/laravel/vite-plugin/pull/254

### Upgrade Path

1. Update to the latest version of the `laravel-vite-plugin`, `vite`, and any Vite plugins you may have installed, such as [@vitejs/plugin-vue](https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue) or [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/tree/main/packages/plugin-react).

The following command will update `laravel-vite-plugin` and `vite` only:

```
npm install vite@^5.0.0 laravel-vite-plugin@^1.x
```

You should also check the upgrade guide and changelogs for any packages you update. The [`vite` migrations guide](https://vitejs.dev/guide/migration.html) is available on their website.

2. Ensure your `package.json` contains `"type": "module"`.

Run the following command in your project's root directory or anywhere you have your `package.json` files:

```sh
npm pkg set type=module
```

You may also need to rename any `*.js` configuration files that contain CJS, which is the older-style Node-flavored `var plugin = require('plugin')` syntax, to `filename.cjs` after making this change.

## Migrating from Laravel Mix to Vite

> **Note**
Expand Down
3 changes: 0 additions & 3 deletions import.meta.url-polyfill.js

This file was deleted.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@
"esbuild": "0.16.10",
"eslint": "^8.14.0",
"typescript": "^4.6.4",
"vite": "^4.0.0",
"vite": "^5.0.0",
"vitest": "^0.34.4"
},
"peerDependencies": {
"vite": "^3.0.0 || ^4.0.0"
"vite": "^5.0.0"
},
"engines": {
"node": ">=14"
"node": "^18.0.0 || >=20.0.0"
},
"dependencies": {
"picocolors": "^1.0.0",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ function resolveLaravelPlugin(pluginConfig: Required<PluginConfig>): LaravelPlug
...serverConfig.hmr,
...(userConfig.server?.hmr === true ? {} : userConfig.server?.hmr),
},
https: userConfig.server?.https === false ? false : {
https: typeof userConfig.server?.https !== 'undefined' ? userConfig.server.https : {
...serverConfig.https,
...(userConfig.server?.https === true ? {} : userConfig.server?.https),
},
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"compilerOptions": {
"outDir": "./dist",
"target": "ES2020",
"module": "ES2020",
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"resolveJsonModule": true,
"strict": true,
"declaration": true,
Expand Down