diff --git a/react/yarn-pnp/package.json b/react/yarn-pnp/package.json index 92aa59ebc..ef052ce77 100644 --- a/react/yarn-pnp/package.json +++ b/react/yarn-pnp/package.json @@ -2,6 +2,7 @@ "name": "buf-yarn-pnp", "packageManager": "yarn@4.0.2", "private": true, + "type": "module", "scripts": { "start": "vite --port 3000", "build": "tsc && vite build", diff --git a/vue/cypress.config.js b/vue/cypress.config.js new file mode 100644 index 000000000..113bb8ac0 --- /dev/null +++ b/vue/cypress.config.js @@ -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 + +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", + }, + }, +}); diff --git a/vue/cypress.config.ts b/vue/cypress.config.ts deleted file mode 100644 index f6a3ee277..000000000 --- a/vue/cypress.config.ts +++ /dev/null @@ -1,38 +0,0 @@ -import { defineConfig } from 'cypress' -const webpackPreprocessor = require('@cypress/webpack-preprocessor') -const ResolveTypeScriptPlugin = require('resolve-typescript-plugin') - -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, config) { - on('file:preprocessor', webpackPreprocessor(options)) - }, - }, - - component: { - devServer: { - framework: 'vue', - bundler: 'vite', - }, - }, -}) diff --git a/vue/package.json b/vue/package.json index 1f5003a96..0d6b83f2e 100644 --- a/vue/package.json +++ b/vue/package.json @@ -1,6 +1,7 @@ { "name": "buf-vue", "version": "0.0.0", + "type": "module", "scripts": { "start": "vite", "build": "run-p type-check build-only",