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
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
1 change: 1 addition & 0 deletions react/yarn-pnp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "buf-yarn-pnp",
"packageManager": "[email protected]",
"private": true,
"type": "module",
"scripts": {
"start": "vite --port 3000",
"build": "tsc && vite build",
Expand Down
42 changes: 42 additions & 0 deletions vue/cypress.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { defineConfig } from "cypress";
import webpackPreprocessor from "@cypress/webpack-preprocessor";
import ResolveTypeScriptPlugin from "resolve-typescript-plugin";

// 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
Comment on lines +5 to +7
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.


const options = {
webpackOptions: {
resolve: {
extensions: [".ts", ".tsx", ".js"],
plugins: [new ResolveTypeScriptPlugin()],
},
module: {
rules: [
{
test: /\.tsx?$/,
loader: "ts-loader",
options: { transpileOnly: true },
},
],
},
},
};

export default defineConfig({
e2e: {
specPattern: "cypress/e2e/**/*.{cy,spec}.{js,jsx,ts,tsx}",
baseUrl: "http://localhost:4173",
setupNodeEvents(on) {
on("file:preprocessor", webpackPreprocessor(options));
},
},

component: {
devServer: {
framework: "vue",
bundler: "vite",
},
},
});
38 changes: 0 additions & 38 deletions vue/cypress.config.ts

This file was deleted.

1 change: 1 addition & 0 deletions vue/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "buf-vue",
"version": "0.0.0",
"type": "module",
"scripts": {
"start": "vite",
"build": "run-p type-check build-only",
Expand Down