Skip to content
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 Vite CJS build warning for Yarn and Vue #1722

Merged
merged 2 commits into from
Jul 31, 2024
Merged

Conversation

smaye81
Copy link
Member

@smaye81 smaye81 commented Jul 30, 2024

Fixes #1721

This fixes the warning about Vite's deprecated CJS build in the react/yarn-pnp and vue projects by converting them to an ESM module. Previously, they were both CJS, most likely due to a simple oversight.

With Vue, it also involved renaming the Cypress config to be a .js file. Vue scaffolds Cypress config files to be a .ts file, which in turn does not work with ESM modules. See this issue for more info.

For more info on the Vite CJS message: https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

@smaye81 smaye81 force-pushed the sayers/fix_vite_cjs_warning branch from c891f0e to e36f807 Compare July 30, 2024 19:01
@smaye81 smaye81 requested a review from timostamm July 30, 2024 19:03
@timostamm
Copy link
Member

Just noticed: The warning also appears for vue.

smaye81 added 2 commits July 31, 2024 10:30
Signed-off-by: Steve Ayers <[email protected]>
Signed-off-by: Steve Ayers <[email protected]>
@smaye81 smaye81 force-pushed the sayers/fix_vite_cjs_warning branch from c5b0798 to 721ec13 Compare July 31, 2024 14:30
@smaye81 smaye81 changed the title Fix Vite CJS build warning Fix Vite CJS build warning for Yarn and Vue Jul 31, 2024
@smaye81 smaye81 requested a review from timostamm July 31, 2024 14:32
Comment on lines +5 to +7
// Note that vue scaffolds a cypress config with a .ts extension, but this doesn't
// work with ESM modules. Renaming this file to have a .js extension fixes the issue.
// See: https://github.com/cypress-io/cypress/issues/23552
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

npm create vue@latest actually does scaffold a .ts file, and it doesn't use the webpack-preprocessor.

I think we might only need the webpack-preprocessor for .js import extensions. We don't add them with v2 anymore, so I think we can simplify this example a lot, and reduce the diff to the default setup. But I don't think it's worth doing that here, in v1.

@smaye81 smaye81 merged commit 91c8ef6 into main Jul 31, 2024
9 checks passed
@smaye81 smaye81 deleted the sayers/fix_vite_cjs_warning branch July 31, 2024 15:32
smaye81 added a commit that referenced this pull request Aug 12, 2024
Fixes #1721 

This fixes the warning about Vite's deprecated CJS build in the
`react/yarn-pnp` and `vue` projects by converting them to an ESM module.
Previously, they were both CJS, most likely due to a simple oversight.

With Vue, it also involved renaming the Cypress config to be a `.js`
file. Vue scaffolds Cypress config files to be a `.ts` file, which in
turn does not work with ESM modules. See [this
issue](cypress-io/cypress#23552) for more
info.

For more info on the Vite CJS message:
https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated

---------

Signed-off-by: Steve Ayers <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid Vite's deprecated CJS build of the Node API
2 participants