From 20bdcb7dadc96cec1ae7fe4fe55e9142fe160a0a Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Thu, 17 Aug 2023 15:20:24 +0200 Subject: [PATCH] Migrate to ES6 modules Configure project to use ES6 modules to enable top-level await capabilities. This change helps project to align well with modern JS standards. - Set `type` to `module` in `package.json`. - Use import/export syntax in Cypress configuration files. - Rename configurations files that do not support modules to use the `.cjs` extension: - `vue.config.js` to `vue.config.cjs` (vuejs/vue-cli#4477). - `babel.config.js` to `babel.config.cjs (babel/babel-loader#894) - `.eslintrc.js` to `.eslintrc.cjs` (eslint/eslint#13440, eslint/eslint#14137) - `postcss.config.js` to `postcss.config.cjs` (postcss/postcss#1771) --- .eslintrc.js => .eslintrc.cjs | 0 babel.config.js => babel.config.cjs | 0 cypress.config.ts | 5 +++-- package.json | 1 + postcss.config.js => postcss.config.cjs | 0 tests/e2e/{.eslintrc.js => .eslintrc.cjs} | 0 tests/e2e/plugins/index.js | 2 +- vue.config.js => vue.config.cjs | 0 8 files changed, 5 insertions(+), 3 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename babel.config.js => babel.config.cjs (100%) rename postcss.config.js => postcss.config.cjs (100%) rename tests/e2e/{.eslintrc.js => .eslintrc.cjs} (100%) rename vue.config.js => vue.config.cjs (100%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/babel.config.js b/babel.config.cjs similarity index 100% rename from babel.config.js rename to babel.config.cjs diff --git a/cypress.config.ts b/cypress.config.ts index 6f5440d8f..028df27d1 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,4 +1,5 @@ -import { defineConfig } from 'cypress' +import { defineConfig } from 'cypress'; +import setupPlugins from './tests/e2e/plugins/index.js'; export default defineConfig({ fixturesFolder: 'tests/e2e/fixtures', @@ -6,7 +7,7 @@ export default defineConfig({ videosFolder: 'tests/e2e/videos', e2e: { setupNodeEvents(on, config) { - return require('./tests/e2e/plugins/index.js')(on, config) + return setupPlugins(on, config); }, specPattern: 'tests/e2e/specs/**/*.cy.{js,jsx,ts,tsx}', supportFile: 'tests/e2e/support/index.js', diff --git a/package.json b/package.json index c86c2e04f..f1f658192 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "slogan": "Now you have the choice", "description": "Enforce privacy & security best-practices on Windows, macOS and Linux, because privacy is sexy 🍑🍆", "author": "undergroundwires", + "type": "module", "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", diff --git a/postcss.config.js b/postcss.config.cjs similarity index 100% rename from postcss.config.js rename to postcss.config.cjs diff --git a/tests/e2e/.eslintrc.js b/tests/e2e/.eslintrc.cjs similarity index 100% rename from tests/e2e/.eslintrc.js rename to tests/e2e/.eslintrc.cjs diff --git a/tests/e2e/plugins/index.js b/tests/e2e/plugins/index.js index 2b816f152..bf36e7355 100644 --- a/tests/e2e/plugins/index.js +++ b/tests/e2e/plugins/index.js @@ -9,7 +9,7 @@ // /* eslint-disable import/no-extraneous-dependencies, global-require */ // const webpack = require('@cypress/webpack-preprocessor') -module.exports = (on, config) => { +export default (on, config) => { // on('file:preprocessor', webpack({ // webpackOptions: require('@vue/cli-service/webpack.config'), // watchOptions: {} diff --git a/vue.config.js b/vue.config.cjs similarity index 100% rename from vue.config.js rename to vue.config.cjs