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

refactor: replace webpack with vite #1944

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
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
21 changes: 0 additions & 21 deletions .babelrc.js

This file was deleted.

3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ dist
.env
yarn-error.log
coverage
cypress/downloads
cypress/downloads
.swc/
File renamed without changes.
File renamed without changes.
9 changes: 5 additions & 4 deletions cypress/cypress.config.js → cypress/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { defineConfig } = require('cypress')
const fs = require('fs')
import { defineConfig } from 'cypress'
import dotenv from 'dotenv'
import fs from 'node:fs'

require('dotenv').config({ path: '../.env' })
dotenv.config({ path: '../.env' })

module.exports = defineConfig({
export default defineConfig({
projectId: 'u863yi',
retries: 3,
e2e: {
Expand Down
2 changes: 1 addition & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export default [
},
},
{
files: ['**/*.js'],
files: ['**/*.cjs'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
},
Expand Down
4 changes: 3 additions & 1 deletion src/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@
/>

<script src="env-config.js"></script>
<title><%= htmlWebpackPlugin.options.title %></title>
<title><%- title %></title>
<link rel="shortcut icon" href="<%- favicon %>" type="image/svg" />
</head>
<body>
<!-- React app root element -->
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
11 changes: 7 additions & 4 deletions jest.config.js → jest.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
module.exports = {
import type { Config } from 'jest'

export default {
// The root of your source code, typically /src
// `<rootDir>` is a token Jest substitutes
roots: ['<rootDir>/src'],
Expand All @@ -9,7 +11,7 @@ module.exports = {
// using ts-jest
transform: {
'^.+\\.tsx?$': 'ts-jest',
'\\.svg$': '<rootDir>/__mocks__/svgMock.js',
'\\.svg$': '<rootDir>/__mocks__/svgMock.cjs',
},

transformIgnorePatterns: [
Expand All @@ -29,6 +31,7 @@ module.exports = {
coverageReporters: ['text', 'lcov'],
collectCoverage: false, // set to true to collect coverage
coverageThreshold: {
global: {},
'src/hooks/ui/useShortcuts.tsx': {
statements: 90,
},
Expand All @@ -49,7 +52,7 @@ module.exports = {
moduleNameMapper: {
'^~/(.*)$': '<rootDir>/src/$1',
'ace-builds': '<rootDir>/node_modules/ace-builds',
'\\.(css|less|sass|scss)$': '<rootDir>/__mocks__/styleMock.js',
'\\.(css|less|sass|scss)$': '<rootDir>/__mocks__/styleMock.cjs',
},

// Module file extensions for importing
Expand All @@ -65,4 +68,4 @@ module.exports = {
NANGO_PUBLIC_KEY: '',
SENTRY_DSN: 'https://sentry.io/',
},
}
} satisfies Config
60 changes: 25 additions & 35 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,35 @@
"name": "lago-front",
"version": "1.0.0",
"description": "Front application of Lago",
"main": "index.js",
"repository": "[email protected]:getlago/lago-front.git",
"author": "Lago tech team <[email protected]>",
"license": "MIT",
"private": true,
"type": "module",
"sideEffects": false,
"changelog": {
"repo": "[email protected]:getlago/lago-front.git"
},
"scripts": {
"start": "webpack serve --config ./webpack.dev.js",
"start:build": "yarn build && npx http-server-spa ./dist",
"build": "webpack --config ./webpack.prod.js",
"lint": "prettier --check src/**/*.{ts,tsx,svg,html} --check cypress/**/*.ts && eslint",
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"lint": "prettier --check src/**/*.{ts,tsx,svg} --check index.html --check cypress/**/*.ts && eslint",
"eslint": "eslint",
"lint:fix": "prettier --write {src,cypress}/** && eslint --fix .",
"lint:fix": "prettier --write {src,cypress}/** index.html && eslint --fix .",
"codegen": "graphql-codegen --config codegen.yml -r dotenv/config",
"codegen:watch": "graphql-codegen --config codegen.yml -r dotenv/config --watch",
"test": "jest --config jest.config.js",
"test:e2e": "cypress open --config-file cypress/cypress.config.js",
"test": "jest --config jest.config.ts",
"test:e2e": "cypress open --config-file cypress/cypress.config.ts",
"translations:add": "node scripts/translations/add",
"translations:inspect": "node scripts/translations/inspect",
"changelog:update": "auto-changelog --template=.changelog/regular.hbs",
"codemod": "node scripts/codemod.js",
"postinstall": "npx yarn-deduplicate"
"postinstall": "npx yarn-deduplicate",
"bundle-analyzer": "vite-bundle-visualizer --sourcemap"
},
"packageManager": "[email protected]",
"devDependencies": {
"@babel/core": "7.23.0",
"@babel/plugin-syntax-dynamic-import": "7.8.3",
"@babel/preset-env": "7.22.20",
"@babel/preset-react": "7.22.15",
"@emotion/react": "11.13.5",
"@emotion/styled": "11.13.5",
"@eslint/compat": "^1.2.2",
Expand All @@ -42,8 +41,9 @@
"@graphql-codegen/typescript-operations": "4.2.3",
"@graphql-codegen/typescript-react-apollo": "4.3.2",
"@parcel/watcher": "^2.3.0",
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
"@svgr/webpack": "8.1.0",
"@svgr/core": "^8.1.0",
"@svgr/plugin-svgo": "^8.1.0",
"@swc/plugin-styled-components": "^6.0.2",
"@testing-library/dom": "^10.0.0",
"@testing-library/jest-dom": "6.4.8",
"@testing-library/react": "16.0.0",
Expand All @@ -54,24 +54,20 @@
"@types/jsonwebtoken": "^9.0.2",
"@types/lodash": "4.17.13",
"@types/luxon": "3.4.2",
"@types/node": "^22.10.2",
"@types/prismjs": "1.26.3",
"@types/react": "18.2.38",
"@types/react-dom": "18.2.17",
"@types/react-router-dom": "5.3.3",
"@types/react-window": "1.8.5",
"@types/sanitize-html": "2.9.5",
"@types/webpack": "5.28.5",
"@vitejs/plugin-react-swc": "^3.7.2",
"auto-changelog": "2.4.0",
"autoprefixer": "^10.4.19",
"babel-loader": "9.1.3",
"babel-plugin-prismjs": "2.1.0",
"babel-plugin-styled-components": "2.1.4",
"class-variance-authority": "^0.7.0",
"css-loader": "^7.1.2",
"cssnano": "^7.0.6",
"cypress": "13.14.2",
"dotenv": "16.3.1",
"duplicate-package-checker-webpack-plugin": "3.0.0",
"eslint": "^9.15.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.31.0",
Expand All @@ -80,32 +76,28 @@
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-hooks": "^5.0.0",
"eslint-plugin-tailwindcss": "^3.17.5",
"file-loader": "6.2.0",
"fork-ts-checker-webpack-plugin": "9.0.2",
"gettext-extractor": "3.8.0",
"glob": "^10.3.4",
"globals": "^15.12.0",
"html-webpack-plugin": "5.5.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
"jscodeshift": "^17.1.1",
"postcss": "^8.4.38",
"postcss-loader": "^8.1.1",
"postcss-preset-env": "^9.5.13",
"prettier": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.6",
"react-refresh": "^0.14.2",
"style-loader": "^4.0.0",
"tailwind-merge": "^2.5.2",
"tailwindcss": "^3.4.11",
"ts-jest": "29.2.4",
"ts-loader": "9.5.1",
"ts-node": "^10.9.2",
"typescript": "5.5.3",
"webpack": "5.94.0",
"webpack-bundle-analyzer": "^4.10.2",
"webpack-cli": "5.1.4",
"webpack-dev-server": "^5.2.0",
"webpack-merge": "5.9.0"
"typescript-eslint": "^8.14.0",
"vite": "^6.0.5",
"vite-bundle-visualizer": "^1.2.1",
"vite-plugin-html": "^3.2.2",
"vite-plugin-svgr": "^4.3.0",
"vite-plugin-top-level-await": "^1.4.4",
"vite-plugin-wasm": "^3.4.1"
},
"dependencies": {
"@apollo/client": "3.11.4",
Expand Down Expand Up @@ -133,8 +125,6 @@
"recharts": "^2.9.0",
"sanitize-html": "2.12.1",
"styled-components": "^6.1.13",
"typescript-eslint": "^8.14.0",
"yarn": "1.22.19",
"yup": "1.2.0"
},
"engines": {
Expand Down
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
8 changes: 3 additions & 5 deletions scripts/codemod.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
/* eslint no-console: ["error", { allow: ["info"] }] */

const path = require('path')

const { globSync } = require('glob')
const { run: jscodeshift } = require('jscodeshift/src/Runner')
import { globSync } from 'glob'
import { run as jscodeshift } from 'jscodeshift/src/Runner'
import path from 'node:path'

const SRC_DIR = './src/'

Expand Down
2 changes: 1 addition & 1 deletion scripts/transforms/skeleton-migrate-margin-values.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (file, api) {
export default function (file, api) {
// Alias the jscodeshift API for ease of use.
const j = api.jscodeshift

Expand Down
2 changes: 1 addition & 1 deletion scripts/transforms/skeleton-migrate-width-values.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (file, api) {
export default function (file, api) {
// Alias the jscodeshift API for ease of use.
const j = api.jscodeshift

Expand Down
2 changes: 1 addition & 1 deletion scripts/transforms/skeleton-remove-unnecessary-height.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module.exports = function (file, api) {
export default function (file, api) {
// Alias the jscodeshift API for ease of use.
const j = api.jscodeshift

Expand Down
2 changes: 1 addition & 1 deletion scripts/translations/add.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint no-console: ["error", { allow: ["info"] }] */
const fs = require('fs')
import fs from 'node:fs'

const KEY_RANDOM_CHARS_LENGTH = 11
const TRANSLATIONS_FOLDER = './translations'
Expand Down
11 changes: 5 additions & 6 deletions scripts/translations/inspect.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint no-console: ["error", { allow: ["info"] }] */
const fs = require('fs')
const path = require('path')

const _ = require('lodash')
const { globSync } = require('glob')
const { GettextExtractor, JsExtractors } = require('gettext-extractor')
import { GettextExtractor, JsExtractors } from 'gettext-extractor'
import { globSync } from 'glob'
import _ from 'lodash'
import fs from 'node:fs'
import path from 'node:path'

const SRC_DIR = './src/'
const TRANSLATION_FILES_PATH = './translations/base.json' // './translations/**.json' for when we'll support several languages
Expand Down
Loading