[1.0] Drop CJS build and export types first#235
Conversation
|
Hey Ben, Thank you for this. Is Vite removing support for CJS in a major version? I just spun up an older version of the Laravel application skeleton and confirmed that this change alone will break potentially thousands(?) of user-land Laravel applications that were created before we moved the skeleton (https://github.com/laravel/laravel) to use The Vite configuration file for the Laravel skeleton has always used ESM import / export... import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';
export default defineConfig({
plugins: [
laravel({
input: ['resources/css/app.css', 'resources/js/app.js'],
refresh: true,
}),
],
});However, because we didn't have After we migrated the skeleton to use Lines 38 to 39 in f89fcde Remembering I'm not an expert on the JS build tooling, I think that Vite dropping support for CJS shouldn't impact this library directly, as we don't build the library with Vite - although it would mean we could drop CJS support, which is what your PR is aiming to do. It would mean that any user-land application that wanted to upgrade to the version of Vite that drops CJS support would need to make sure they have I would love to know if that sounds correct to you. |
Did you test or are you inferring that from the code? If you tested it, can you share the steps with me so I can check it out? Can you share a link to one of these old projects with me?
Yes, it would be in a major version. TBD whether Vite 5 will remove it or just cause a warning, but either way we're trying to migrate as much as we can now.
I wouldn't expect that to be true. If you're doing an
No, they shouldn't need to go that far. They just need to use the plugin from an |
Here is a bash script that produces the problem. It downloads the skeleton before we made the This is the commit before we made the change: https://github.com/laravel/laravel/tree/d14bdeeb6db121cc7d181ce5497211612ce4bc10 if you don't feel comfortable running the wget unzip etc. You will need to have the wget --output-document laravel-skeleton-pre-modules.zip https://github.com/laravel/laravel/archive/d14bdeeb6db121cc7d181ce5497211612ce4bc10.zip
unzip ./laravel-skeleton-pre-modules.zip -d ./
cd laravel-d14bdeeb6db121cc7d181ce5497211612ce4bc10
npm install
npm link laravel-vite-plugin
npm run build
Good to hear there will be a major.
We just have the This is the error...
This error is resolved if I add |
|
Hmm. The skeleton project doesn't look valid to me because it has ESM code in a I'll let you figure out how to proceed and take it from here. One suggestion would be to push a release that does a check for |
|
Something to keep in mind is that any change to the Laravel skeleton will not roll out to existing applications, as that code all becomes user-land code. I think this will actually be alright, though - although not ideal. When Vite 5 is released we would tag version a major version of the plugin. We would note in our upgrade guide that Vite 5 is now required and that So I think we can probably move ahead with this as it is. I'm going to discuss it with the team today internally. Going to mark this one as a draft until we know how we want to proceed. Thanks, Ben! |
There was a problem hiding this comment.
Happy to get this one moving into our yet to be released 1.x branch.
This 1.x branch won't be released / tagged until Vite 5 comes out.
We will document the upgrade path in the upgrade guide once Vite 5 is released and we have an understanding of any additional things we need to document for Laravel projects.
Thanks again, Ben!
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [laravel-vite-plugin](https://togithub.com/laravel/vite-plugin) | [`^0.8.0` -> `^1.0.0`](https://renovatebot.com/diffs/npm/laravel-vite-plugin/0.7.8/1.0.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>laravel/vite-plugin (laravel-vite-plugin)</summary> ### [`v1.0.2`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v102---2024-02-28) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v1.0.1...v1.0.2) - \[1.x] Fix HMR issue when `resources/lang` directory doesn't exist and a symlink is present in the root directory by [@​jessarcher](https://togithub.com/jessarcher) in [https://github.com/laravel/vite-plugin/pull/285](https://togithub.com/laravel/vite-plugin/pull/285) ### [`v1.0.1`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v101---2023-12-27) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v1.0.0...v1.0.1) - \[1.x] Simpler conditional by [@​Jubeki](https://togithub.com/Jubeki) in [https://github.com/laravel/vite-plugin/pull/273](https://togithub.com/laravel/vite-plugin/pull/273) - \[1.x] Account for imported CSS files while cleaning by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/275](https://togithub.com/laravel/vite-plugin/pull/275) - \[1.x] Fix exit error messages by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/276](https://togithub.com/laravel/vite-plugin/pull/276) ### [`v1.0.0`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v100---2023-12-19) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.8.1...v1.0.0) - \[1.0] Drop CJS build and export types first by [@​benmccann](https://togithub.com/benmccann) in [https://github.com/laravel/vite-plugin/pull/235](https://togithub.com/laravel/vite-plugin/pull/235) - \[1.x] Introduce `clean-orphaned-assets` binary by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/251](https://togithub.com/laravel/vite-plugin/pull/251) - \[0.8.x] Respect vite server.origin in viteDevServerUrl by [@​nurdism](https://togithub.com/nurdism) in [https://github.com/laravel/vite-plugin/pull/255](https://togithub.com/laravel/vite-plugin/pull/255) - \[1.x] Vite 5 by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/269](https://togithub.com/laravel/vite-plugin/pull/269) - \[0.8.x] Fallback pages by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/271](https://togithub.com/laravel/vite-plugin/pull/271) - \[1.x] Auto detect Valet / Herd TLS certificates by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/180](https://togithub.com/laravel/vite-plugin/pull/180) ### [`v0.8.1`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v081---2023-09-26) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.8.0...v0.8.1) - \[0.8] Fix issue with `0.0.0.0` network resolution by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/241](https://togithub.com/laravel/vite-plugin/pull/241) - Upgrade vitest by [@​sapphi-red](https://togithub.com/sapphi-red) in [https://github.com/laravel/vite-plugin/pull/246](https://togithub.com/laravel/vite-plugin/pull/246) ### [`v0.8.0`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v080---2023-08-08) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.7.8...v0.8.0) - fix: compile error following upgrade.md's vite to mix guide by [@​AshboDev](https://togithub.com/AshboDev) in [https://github.com/laravel/vite-plugin/pull/231](https://togithub.com/laravel/vite-plugin/pull/231) - Support Laravel Herd by [@​claudiodekker](https://togithub.com/claudiodekker) in [https://github.com/laravel/vite-plugin/pull/233](https://togithub.com/laravel/vite-plugin/pull/233) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tisnamuliarta/laravel-shadcn). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzAuMCIsInVwZGF0ZWRJblZlciI6IjM3LjIzMC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
[](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [laravel-vite-plugin](https://togithub.com/laravel/vite-plugin) | [`^0.7.5` -> `^1.0.0`](https://renovatebot.com/diffs/npm/laravel-vite-plugin/0.7.8/1.0.2) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | [](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>laravel/vite-plugin (laravel-vite-plugin)</summary> ### [`v1.0.2`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v102---2024-02-28) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v1.0.1...v1.0.2) - \[1.x] Fix HMR issue when `resources/lang` directory doesn't exist and a symlink is present in the root directory by [@​jessarcher](https://togithub.com/jessarcher) in [https://github.com/laravel/vite-plugin/pull/285](https://togithub.com/laravel/vite-plugin/pull/285) ### [`v1.0.1`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v101---2023-12-27) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v1.0.0...v1.0.1) - \[1.x] Simpler conditional by [@​Jubeki](https://togithub.com/Jubeki) in [https://github.com/laravel/vite-plugin/pull/273](https://togithub.com/laravel/vite-plugin/pull/273) - \[1.x] Account for imported CSS files while cleaning by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/275](https://togithub.com/laravel/vite-plugin/pull/275) - \[1.x] Fix exit error messages by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/276](https://togithub.com/laravel/vite-plugin/pull/276) ### [`v1.0.0`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v100---2023-12-19) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.8.1...v1.0.0) - \[1.0] Drop CJS build and export types first by [@​benmccann](https://togithub.com/benmccann) in [https://github.com/laravel/vite-plugin/pull/235](https://togithub.com/laravel/vite-plugin/pull/235) - \[1.x] Introduce `clean-orphaned-assets` binary by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/251](https://togithub.com/laravel/vite-plugin/pull/251) - \[0.8.x] Respect vite server.origin in viteDevServerUrl by [@​nurdism](https://togithub.com/nurdism) in [https://github.com/laravel/vite-plugin/pull/255](https://togithub.com/laravel/vite-plugin/pull/255) - \[1.x] Vite 5 by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/269](https://togithub.com/laravel/vite-plugin/pull/269) - \[0.8.x] Fallback pages by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/271](https://togithub.com/laravel/vite-plugin/pull/271) - \[1.x] Auto detect Valet / Herd TLS certificates by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/180](https://togithub.com/laravel/vite-plugin/pull/180) ### [`v0.8.1`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v081---2023-09-26) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.8.0...v0.8.1) - \[0.8] Fix issue with `0.0.0.0` network resolution by [@​timacdonald](https://togithub.com/timacdonald) in [https://github.com/laravel/vite-plugin/pull/241](https://togithub.com/laravel/vite-plugin/pull/241) - Upgrade vitest by [@​sapphi-red](https://togithub.com/sapphi-red) in [https://github.com/laravel/vite-plugin/pull/246](https://togithub.com/laravel/vite-plugin/pull/246) ### [`v0.8.0`](https://togithub.com/laravel/vite-plugin/blob/HEAD/CHANGELOG.md#v080---2023-08-08) [Compare Source](https://togithub.com/laravel/vite-plugin/compare/v0.7.8...v0.8.0) - fix: compile error following upgrade.md's vite to mix guide by [@​AshboDev](https://togithub.com/AshboDev) in [https://github.com/laravel/vite-plugin/pull/231](https://togithub.com/laravel/vite-plugin/pull/231) - Support Laravel Herd by [@​claudiodekker](https://togithub.com/claudiodekker) in [https://github.com/laravel/vite-plugin/pull/233](https://togithub.com/laravel/vite-plugin/pull/233) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/tisnamuliarta/laravel-shadcn). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yMzguMSIsInVwZGF0ZWRJblZlciI6IjM3LjIzOC4xIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->
* Export types first * Drop CJS build * Remove CJS build step * Use `"type": "module"` in the project * Remove `mjs` extension from build output * Fix ESLint configuration which does not support ESM --------- Co-authored-by: Tim MacDonald <hello@timacdonald.me>

Closes #234. There were only four projects I saw using CJS and I've sent PRs to migrate three of them
Also,
typesmust be exported first. See https://publint.dev/laravel-vite-plugin@0.7.8 for more details regarding that