-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
fix!: use type module (revert #1411) #1465
Conversation
✅ Deploy Preview for vitest-dev ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify site settings. |
Will it revert errors for users? If so, what should we recommend people? |
Yes it will revert the errors. Following #1411 (comment), if they're using the new |
In that case, should we also extend our defaults? vitest/packages/vitest/src/defaults.ts Lines 15 to 16 in fef00a7
vitest/packages/vitest/src/defaults.ts Line 33 in fef00a7
|
I think that makes sense 👍 |
/cc @aleclarson |
I would hold this for a while longer. Indeed the usage in #1411 might better use |
The "better solution" I mentioned in that thread goes like this: ".": {
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
},
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}, That would be how Vitest's Both |
First of all, we already saw in that PR that it doesn't work, does it? TypeScript has a bug preventing that. Second of all, I don't see how this is a "better solution"? We will essentially double package size just to please few people with TypeScript issues that can be resolved on their end? Those files won't even be run in any situation. |
The two differences from your idea are that (1)
No, the new // dist/index.d.cts
export * from './index.mjs'
// dist/index.cjs
export * from './index.mjs' |
But this wouldn't work for the same reason it doesn't work right now, no? You cannot use static import/export inside cjs. This is also just a hack to please typescript. They added this extensions for a the reason we are trying to fix here, so I would rather go with it. |
Those modules would never be loaded by Node.js runtime, so no errors would occur. Correction: The It's not a "hack", because the TypeScript team themselves said it's a valid solution. |
No, I mean by TypeScript. Why would Current problem:
|
Ok, I've looked through the threads, and now I see that @aleclarson's idea is valid. We can include it in this PR actually, and safely merge it. @antfu, what do you think? |
I can't really follow the topic, but sure, if it helps and doesn't break anything else :) |
Is there anything blocking this from being merged? |
This needs updating, we changed quite a few APIs since then, and if merged, Vitest won't work. |
For a package with:
Running
Is there a known workaround? |
I've updated the PR. Tried to update some of the newer places, and the tests seems to be passing, except ubuntu node14 (not sure if it's a fluke). |
@jroru My workaround until this PR is merged has been to use |
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [@vitest/coverage-c8](https://togithub.com/vitest-dev/vitest) | [`0.23.4` -> `0.24.0`](https://renovatebot.com/diffs/npm/@vitest%2fcoverage-c8/0.23.4/0.24.0) | [![age](https://badges.renovateapi.com/packages/npm/@vitest%2fcoverage-c8/0.24.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/@vitest%2fcoverage-c8/0.24.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/@vitest%2fcoverage-c8/0.24.0/compatibility-slim/0.23.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/@vitest%2fcoverage-c8/0.24.0/confidence-slim/0.23.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>vitest-dev/vitest</summary> ### [`v0.24.0`](https://togithub.com/vitest-dev/vitest/releases/tag/v0.24.0) [Compare Source](https://togithub.com/vitest-dev/vitest/compare/v0.23.4...v0.24.0) ##### 🚨 Breaking Changes - Use type module (revert [#​1411](https://togithub.com/vitest-dev/vitest/issues/1411)) - by [@​bluwy](https://togithub.com/bluwy) and [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/1465](https://togithub.com/vitest-dev/vitest/issues/1465) - Drop support for Vite 2 - by [@​antfu](https://togithub.com/antfu) and [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/1928](https://togithub.com/vitest-dev/vitest/issues/1928) ##### 🚀 Features - **benchmark**: Todo mode - by [@​Aslemammad](https://togithub.com/Aslemammad) in [https://github.com/vitest-dev/vitest/issues/2057](https://togithub.com/vitest-dev/vitest/issues/2057) - **inline-snapshot**: Support comment - by [@​azaleta](https://togithub.com/azaleta) in [https://github.com/vitest-dev/vitest/issues/2077](https://togithub.com/vitest-dev/vitest/issues/2077) ##### 🐞 Bug Fixes - Run related test, even if test doesn't have dependencies - by [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/2043](https://togithub.com/vitest-dev/vitest/issues/2043) - Check for asymmetricMatch before accessing - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(75719)</samp>](https://togithub.com/vitest-dev/vitest/commit/757199a6) - Check hook teardown return type, closes [#​2092](https://togithub.com/vitest-dev/vitest/issues/2092) - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(cba3f)</samp>](https://togithub.com/vitest-dev/vitest/commit/cba3ff09) - Don't stop watch mode, if non-object error is thrown, close [#​2106](https://togithub.com/vitest-dev/vitest/issues/2106) - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(bd677)</samp>](https://togithub.com/vitest-dev/vitest/commit/bd677017) - Use correct source maps in stacktrace - by [@​haikyuu](https://togithub.com/haikyuu) in [https://github.com/vitest-dev/vitest/issues/2027](https://togithub.com/vitest-dev/vitest/issues/2027) - Import CustomEventMap from vite for vite-node - by [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/2124](https://togithub.com/vitest-dev/vitest/issues/2124) - **jsdom**: Use jsdom Blob instead of Node, if jsdom is enabled - by [@​ChpShy](https://togithub.com/ChpShy) in [https://github.com/vitest-dev/vitest/issues/2086](https://togithub.com/vitest-dev/vitest/issues/2086) ##### [View changes on GitHub](https://togithub.com/vitest-dev/vitest/compare/v0.23.4...v0.24.0) </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, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/AlexKMarshall/necromunda-turbo). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjIuMyIsInVwZGF0ZWRJblZlciI6IjMyLjIyMi4zIn0=-->
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [vitest](https://togithub.com/vitest-dev/vitest) | [`0.23.4` -> `0.24.0`](https://renovatebot.com/diffs/npm/vitest/0.23.4/0.24.0) | [![age](https://badges.renovateapi.com/packages/npm/vitest/0.24.0/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/npm/vitest/0.24.0/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/npm/vitest/0.24.0/compatibility-slim/0.23.4)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/npm/vitest/0.24.0/confidence-slim/0.23.4)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>vitest-dev/vitest</summary> ### [`v0.24.0`](https://togithub.com/vitest-dev/vitest/releases/tag/v0.24.0) [Compare Source](https://togithub.com/vitest-dev/vitest/compare/v0.23.4...v0.24.0) ##### 🚨 Breaking Changes - Use type module (revert [#​1411](https://togithub.com/vitest-dev/vitest/issues/1411)) - by [@​bluwy](https://togithub.com/bluwy) and [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/1465](https://togithub.com/vitest-dev/vitest/issues/1465) - Drop support for Vite 2 - by [@​antfu](https://togithub.com/antfu) and [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/1928](https://togithub.com/vitest-dev/vitest/issues/1928) ##### 🚀 Features - **benchmark**: Todo mode - by [@​Aslemammad](https://togithub.com/Aslemammad) in [https://github.com/vitest-dev/vitest/issues/2057](https://togithub.com/vitest-dev/vitest/issues/2057) - **inline-snapshot**: Support comment - by [@​azaleta](https://togithub.com/azaleta) in [https://github.com/vitest-dev/vitest/issues/2077](https://togithub.com/vitest-dev/vitest/issues/2077) ##### 🐞 Bug Fixes - Run related test, even if test doesn't have dependencies - by [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/2043](https://togithub.com/vitest-dev/vitest/issues/2043) - Check for asymmetricMatch before accessing - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(75719)</samp>](https://togithub.com/vitest-dev/vitest/commit/757199a6) - Check hook teardown return type, closes [#​2092](https://togithub.com/vitest-dev/vitest/issues/2092) - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(cba3f)</samp>](https://togithub.com/vitest-dev/vitest/commit/cba3ff09) - Don't stop watch mode, if non-object error is thrown, close [#​2106](https://togithub.com/vitest-dev/vitest/issues/2106) - by [@​sheremet-va](https://togithub.com/sheremet-va) [<samp>(bd677)</samp>](https://togithub.com/vitest-dev/vitest/commit/bd677017) - Use correct source maps in stacktrace - by [@​haikyuu](https://togithub.com/haikyuu) in [https://github.com/vitest-dev/vitest/issues/2027](https://togithub.com/vitest-dev/vitest/issues/2027) - Import CustomEventMap from vite for vite-node - by [@​sheremet-va](https://togithub.com/sheremet-va) in [https://github.com/vitest-dev/vitest/issues/2124](https://togithub.com/vitest-dev/vitest/issues/2124) - **jsdom**: Use jsdom Blob instead of Node, if jsdom is enabled - by [@​ChpShy](https://togithub.com/ChpShy) in [https://github.com/vitest-dev/vitest/issues/2086](https://togithub.com/vitest-dev/vitest/issues/2086) ##### [View changes on GitHub](https://togithub.com/vitest-dev/vitest/compare/v0.23.4...v0.24.0) </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, click this checkbox. --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/AlexKMarshall/necromunda-turbo). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMjIuMyIsInVwZGF0ZWRJblZlciI6IjMyLjIyMi4zIn0=-->
Reverts #1411 (and also #1439)
Ref: #1411 (comment)
It's not needed to remove type module to fix the issue stated in the PR