From 472bba8f8c70ac20ade0a8f9949a7a87842b4c36 Mon Sep 17 00:00:00 2001 From: Jonson Petard <41122242+greenhat616@users.noreply.github.com> Date: Fri, 9 Feb 2024 13:40:06 +0800 Subject: [PATCH] chore(frontend)!: migrate to `esm` (#407) * chore(frontend)!: migrate to esm module * fix: lint --- .eslintrc.js => .eslintrc.cjs | 0 .../{config.js => config.cjs} | 0 ...ration.js => pre-changelog-generation.cjs} | 0 .github/workflows/publish.yml | 4 +- .lintstagedrc.js | 2 +- .stylelintrc.js | 6 +- commitlint.config.js | 2 +- package.json | 6 + pnpm-lock.yaml | 107 ++---------------- postcss.config.js | 2 +- 10 files changed, 27 insertions(+), 102 deletions(-) rename .eslintrc.js => .eslintrc.cjs (100%) rename .github/conventional-changelog/{config.js => config.cjs} (100%) rename .github/conventional-changelog/{pre-changelog-generation.js => pre-changelog-generation.cjs} (100%) diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 100% rename from .eslintrc.js rename to .eslintrc.cjs diff --git a/.github/conventional-changelog/config.js b/.github/conventional-changelog/config.cjs similarity index 100% rename from .github/conventional-changelog/config.js rename to .github/conventional-changelog/config.cjs diff --git a/.github/conventional-changelog/pre-changelog-generation.js b/.github/conventional-changelog/pre-changelog-generation.cjs similarity index 100% rename from .github/conventional-changelog/pre-changelog-generation.js rename to .github/conventional-changelog/pre-changelog-generation.cjs diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8091b4ab60..b8acf51ddb 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -68,8 +68,8 @@ jobs: tag-prefix: "v" # output-file: "UPDATELOG.md" # Since v1.4.3, using conventional-changelog-cli@v2.1.0 release-count: "10" - pre-changelog-generation: ".github/conventional-changelog/pre-changelog-generation.js" - config-file-path: ".github/conventional-changelog/config.js" + pre-changelog-generation: ".github/conventional-changelog/pre-changelog-generation.cjs" + config-file-path: ".github/conventional-changelog/config.cjs" git-branch: "main" env: NYANPASU_VERSION: ${{ steps.update-version.outputs.version }} diff --git a/.lintstagedrc.js b/.lintstagedrc.js index 9cc7a36c07..e7a8dfdfad 100644 --- a/.lintstagedrc.js +++ b/.lintstagedrc.js @@ -1,4 +1,4 @@ -module.exports = { +export default { "*.{js,cjs,.mjs,jsx}": ["prettier --write", "eslint --cache --fix"], "*.{ts,tsx}": [ "prettier --write", diff --git a/.stylelintrc.js b/.stylelintrc.js index 8e4e085fe4..441d49dae3 100644 --- a/.stylelintrc.js +++ b/.stylelintrc.js @@ -1,4 +1,6 @@ -module.exports = { +import PostCssScss from "postcss-scss"; + +export default { root: true, defaultSeverity: "error", plugins: [ @@ -48,7 +50,7 @@ module.exports = { overrides: [ { files: ["**/*.scss", "*.scss"], - customSyntax: require("postcss-scss"), + customSyntax: PostCssScss, rules: { "at-rule-no-unknown": null, "import-notation": null, diff --git a/commitlint.config.js b/commitlint.config.js index 5073c20db1..fa584fb6d9 100644 --- a/commitlint.config.js +++ b/commitlint.config.js @@ -1 +1 @@ -module.exports = { extends: ["@commitlint/config-conventional"] }; +export default { extends: ["@commitlint/config-conventional"] }; diff --git a/package.json b/package.json index aa45779635..97069488be 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "clash-nyanpasu", "version": "1.4.5", "license": "GPL-3.0", + "type": "module", "scripts": { "dev": "tauri dev -f default-meta -c ./backend/tauri/tauri.conf.json", "dev:diff": "tauri dev -f verge-dev -c ./backend/tauri/tauri.conf.json", @@ -54,6 +55,11 @@ } ] }, + "pnpm": { + "overrides": { + "vite-plugin-monaco-editor": "npm:vite-plugin-monaco-editor-new@1.1.3" + } + }, "dependencies": { "@dnd-kit/core": "6.1.0", "@dnd-kit/sortable": "8.0.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 307aab699d..fb02760000 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + vite-plugin-monaco-editor: npm:vite-plugin-monaco-editor-new@1.1.3 + dependencies: '@dnd-kit/core': specifier: 6.1.0 @@ -34,7 +37,7 @@ dependencies: version: 5.15.9(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) '@mui/x-data-grid': specifier: 6.19.3 - version: 6.19.3(@mui/material@5.15.9)(@mui/system@5.15.8)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) + version: 6.19.3(@mui/material@5.15.9)(@mui/system@5.15.9)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) '@tauri-apps/api': specifier: 1.5.3 version: 1.5.3 @@ -260,8 +263,8 @@ devDependencies: specifier: 5.1.0 version: 5.1.0(@types/node@18.19.0)(sass@1.70.0) vite-plugin-monaco-editor: - specifier: 1.1.0 - version: 1.1.0(monaco-editor@0.46.0) + specifier: npm:vite-plugin-monaco-editor-new@1.1.3 + version: /vite-plugin-monaco-editor-new@1.1.3(monaco-editor@0.46.0) vite-plugin-svgr: specifier: 4.2.0 version: 4.2.0(typescript@5.3.3)(vite@5.1.0) @@ -1348,23 +1351,6 @@ packages: react-transition-group: 4.4.5(react-dom@18.2.0)(react@18.2.0) dev: false - /@mui/private-theming@5.15.8(@types/react@18.2.55)(react@18.2.0): - resolution: {integrity: sha512-HMDPO416iMZPqs8nGUL3GJMDNpJtE1Uefw/Aw+zTKJHX5JnT+Bms41e2065BUT/zR5dYcKjFP4gQMwW5QX7nvA==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.23.9 - '@mui/utils': 5.15.8(@types/react@18.2.55)(react@18.2.0) - '@types/react': 18.2.55 - prop-types: 15.8.1 - react: 18.2.0 - dev: false - /@mui/private-theming@5.15.9(@types/react@18.2.55)(react@18.2.0): resolution: {integrity: sha512-/aMJlDOxOTAXyp4F2rIukW1O0anodAMCkv1DfBh/z9vaKHY3bd5fFf42wmP+0GRmwMinC5aWPpNfHXOED1fEtg==} engines: {node: '>=12.0.0'} @@ -1382,28 +1368,6 @@ packages: react: 18.2.0 dev: false - /@mui/styled-engine@5.15.8(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(react@18.2.0): - resolution: {integrity: sha512-31ZKPGsS0OiSwuzi8RWoTiWRdUWXPRiOQkyG9bRYX/zvoYeBXEdbsLEgbryug5mVRsPpvwbH5q/i/t6MkjQ71g==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@emotion/react': ^11.4.1 - '@emotion/styled': ^11.3.0 - react: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@emotion/react': - optional: true - '@emotion/styled': - optional: true - dependencies: - '@babel/runtime': 7.23.9 - '@emotion/cache': 11.11.0 - '@emotion/react': 11.11.3(@types/react@18.2.55)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.3)(@types/react@18.2.55)(react@18.2.0) - csstype: 3.1.2 - prop-types: 15.8.1 - react: 18.2.0 - dev: false - /@mui/styled-engine@5.15.9(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(react@18.2.0): resolution: {integrity: sha512-NRKtYkL5PZDH7dEmaLEIiipd3mxNnQSO+Yo8rFNBNptY8wzQnQ+VjayTq39qH7Sast5cwHKYFusUrQyD+SS4Og==} engines: {node: '>=12.0.0'} @@ -1426,36 +1390,6 @@ packages: react: 18.2.0 dev: false - /@mui/system@5.15.8(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react@18.2.0): - resolution: {integrity: sha512-BUMJvlz1UqIqDPyrvc+MwjOUkWKskUPAOUuRh2KMAworiXuuUmtIivxSfdGll2ex6RHSylu4yc5dJZByOI8EcQ==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@emotion/react': ^11.5.0 - '@emotion/styled': ^11.3.0 - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@emotion/react': - optional: true - '@emotion/styled': - optional: true - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.23.9 - '@emotion/react': 11.11.3(@types/react@18.2.55)(react@18.2.0) - '@emotion/styled': 11.11.0(@emotion/react@11.11.3)(@types/react@18.2.55)(react@18.2.0) - '@mui/private-theming': 5.15.8(@types/react@18.2.55)(react@18.2.0) - '@mui/styled-engine': 5.15.8(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(react@18.2.0) - '@mui/types': 7.2.13(@types/react@18.2.55) - '@mui/utils': 5.15.8(@types/react@18.2.55)(react@18.2.0) - '@types/react': 18.2.55 - clsx: 2.1.0 - csstype: 3.1.2 - prop-types: 15.8.1 - react: 18.2.0 - dev: false - /@mui/system@5.15.9(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react@18.2.0): resolution: {integrity: sha512-SxkaaZ8jsnIJ77bBXttfG//LUf6nTfOcaOuIgItqfHv60ZCQy/Hu7moaob35kBb+guxVJnoSZ+7vQJrA/E7pKg==} engines: {node: '>=12.0.0'} @@ -1515,24 +1449,6 @@ packages: react-is: 18.2.0 dev: false - /@mui/utils@5.15.8(@types/react@18.2.55)(react@18.2.0): - resolution: {integrity: sha512-Q6Z/xSxi1Z6xQ5Qj9p4ZTHudwfrrwFALtU6H1O222pXudg9Qm0zHdiwJQiHT9L6jMIN78ZujEfGHserMoHUrQw==} - engines: {node: '>=12.0.0'} - peerDependencies: - '@types/react': ^17.0.0 || ^18.0.0 - react: ^17.0.0 || ^18.0.0 - peerDependenciesMeta: - '@types/react': - optional: true - dependencies: - '@babel/runtime': 7.23.9 - '@types/prop-types': 15.7.11 - '@types/react': 18.2.55 - prop-types: 15.8.1 - react: 18.2.0 - react-is: 18.2.0 - dev: false - /@mui/utils@5.15.9(@types/react@18.2.55)(react@18.2.0): resolution: {integrity: sha512-yDYfr61bCYUz1QtwvpqYy/3687Z8/nS4zv7lv/ih/6ZFGMl1iolEvxRmR84v2lOYxlds+kq1IVYbXxDKh8Z9sg==} engines: {node: '>=12.0.0'} @@ -1551,7 +1467,7 @@ packages: react-is: 18.2.0 dev: false - /@mui/x-data-grid@6.19.3(@mui/material@5.15.9)(@mui/system@5.15.8)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0): + /@mui/x-data-grid@6.19.3(@mui/material@5.15.9)(@mui/system@5.15.9)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0): resolution: {integrity: sha512-RHt+MhTgvpXTWY0MYvzSNLF8npo+mlmWuTO+qKRt42Zj634IlUYDwW5jjQ9fWZnIpWJLunw253KqHoAlSAOXaw==} engines: {node: '>=14.0.0'} peerDependencies: @@ -1562,7 +1478,7 @@ packages: dependencies: '@babel/runtime': 7.23.9 '@mui/material': 5.15.9(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react-dom@18.2.0)(react@18.2.0) - '@mui/system': 5.15.8(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react@18.2.0) + '@mui/system': 5.15.9(@emotion/react@11.11.3)(@emotion/styled@11.11.0)(@types/react@18.2.55)(react@18.2.0) '@mui/utils': 5.15.7(@types/react@18.2.55)(react@18.2.0) clsx: 2.1.0 prop-types: 15.8.1 @@ -6423,11 +6339,12 @@ packages: spdx-expression-parse: 3.0.1 dev: true - /vite-plugin-monaco-editor@1.1.0(monaco-editor@0.46.0): - resolution: {integrity: sha512-IvtUqZotrRoVqwT0PBBDIZPNraya3BxN/bfcNfnxZ5rkJiGcNtO5eAOWWSgT7zullIAEqQwxMU83yL9J5k7gww==} + /vite-plugin-monaco-editor-new@1.1.3(monaco-editor@0.46.0): + resolution: {integrity: sha512-VprhuvcbxjMlhdJBlbSiXR9SR/TolRyTn9+2XKd5RnXdyv7e6R8UooLFmXtcBUgXZQ9hzGlJmOZ8m4/WrNss0w==} peerDependencies: - monaco-editor: '>=0.33.0' + monaco-editor: '>=0.45.0' dependencies: + esbuild: 0.19.10 monaco-editor: 0.46.0 dev: true diff --git a/postcss.config.js b/postcss.config.js index 3f1212bf8a..bb979c7b40 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,4 +1,4 @@ -module.exports = { +export default { plugins: { // to edit target browsers: use "browserslist" field in package.json "postcss-import": {},