mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
build: babel -> swc
This commit is contained in:
parent
d149a4903d
commit
750f8e4462
7 changed files with 768 additions and 1661 deletions
20
.swcrc
Normal file
20
.swcrc
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
{
|
||||
"$schema": "https://swc.rs/schema.json",
|
||||
"jsc": {
|
||||
"parser": {
|
||||
"syntax": "typescript",
|
||||
"tsx": true,
|
||||
"decorators": false,
|
||||
"dynamicImport": true
|
||||
},
|
||||
"transform": {
|
||||
"react": {
|
||||
"runtime": "automatic"
|
||||
}
|
||||
},
|
||||
"target": "es2022"
|
||||
},
|
||||
"module": {
|
||||
"type": "es6"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
// `.babelrc` is not loaded by babel-loader for files under node_modules, but `babel.config.js` is
|
||||
module.exports = {
|
||||
env: {
|
||||
test: {
|
||||
plugins: ['babel-plugin-transform-es2015-modules-commonjs'],
|
||||
},
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@babel/preset-env',
|
||||
{
|
||||
modules: false,
|
||||
targets: {
|
||||
esmodules: true,
|
||||
},
|
||||
exclude: [
|
||||
'@babel/plugin-transform-async-to-generator',
|
||||
'@babel/plugin-proposal-object-rest-spread',
|
||||
],
|
||||
},
|
||||
],
|
||||
'@babel/preset-typescript',
|
||||
'@babel/preset-react',
|
||||
],
|
||||
plugins: ['@babel/plugin-proposal-optional-chaining', '@babel/plugin-proposal-class-properties'],
|
||||
}
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
import eslint from "@eslint/js";
|
||||
import tseslint from "typescript-eslint";
|
||||
import react from "eslint-plugin-react";
|
||||
import reactHooks from "eslint-plugin-react-hooks";
|
||||
import eslintConfigPrettier from "eslint-config-prettier";
|
||||
import globals from "globals";
|
||||
import eslint from '@eslint/js'
|
||||
import eslintConfigPrettier from 'eslint-config-prettier'
|
||||
import react from 'eslint-plugin-react'
|
||||
import reactHooks from 'eslint-plugin-react-hooks'
|
||||
import globals from 'globals'
|
||||
import tseslint from 'typescript-eslint'
|
||||
|
||||
export default tseslint.config(
|
||||
eslint.configs.recommended,
|
||||
|
|
@ -11,31 +11,31 @@ export default tseslint.config(
|
|||
eslintConfigPrettier,
|
||||
{
|
||||
ignores: [
|
||||
"dist*/",
|
||||
"node_modules/",
|
||||
"Safari/",
|
||||
"vscode-icons/",
|
||||
"server/",
|
||||
"**/*.d.ts",
|
||||
"playwright-report/",
|
||||
"test-results/",
|
||||
'dist*/',
|
||||
'node_modules/',
|
||||
'Safari/',
|
||||
'vscode-icons/',
|
||||
'server/',
|
||||
'**/*.d.ts',
|
||||
'playwright-report/',
|
||||
'test-results/',
|
||||
],
|
||||
},
|
||||
{
|
||||
files: ["**/*.ts", "**/*.tsx"],
|
||||
files: ['**/*.ts', '**/*.tsx'],
|
||||
languageOptions: {
|
||||
ecmaVersion: "latest",
|
||||
sourceType: "module",
|
||||
ecmaVersion: 'latest',
|
||||
sourceType: 'module',
|
||||
globals: {
|
||||
...globals.es2022,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["src/**/*.ts", "src/**/*.tsx"],
|
||||
files: ['src/**/*.ts', 'src/**/*.tsx'],
|
||||
plugins: {
|
||||
react,
|
||||
"react-hooks": reactHooks,
|
||||
'react-hooks': reactHooks,
|
||||
},
|
||||
languageOptions: {
|
||||
globals: {
|
||||
|
|
@ -44,17 +44,17 @@ export default tseslint.config(
|
|||
},
|
||||
settings: {
|
||||
react: {
|
||||
version: "detect",
|
||||
version: 'detect',
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
...react.configs.recommended.rules,
|
||||
...reactHooks.configs.recommended.rules,
|
||||
"react-hooks/rules-of-hooks": "off", // for IIFC
|
||||
'react-hooks/rules-of-hooks': 'off', // for IIFC
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ["e2e/**/*.ts"],
|
||||
files: ['e2e/**/*.ts'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
|
|
@ -62,11 +62,37 @@ export default tseslint.config(
|
|||
},
|
||||
},
|
||||
{
|
||||
files: ["scripts/**/*.js"],
|
||||
files: ['scripts/**/*.js'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
},
|
||||
},
|
||||
);
|
||||
{
|
||||
files: ['scripts/vscode-icons/**/*.js'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
...globals.browser,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
},
|
||||
},
|
||||
{
|
||||
files: ['*.config.{js,ts,cjs,cts}', '*.{cjs,cts}'],
|
||||
languageOptions: {
|
||||
globals: {
|
||||
...globals.node,
|
||||
},
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-require-imports': 'off',
|
||||
},
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ module.exports = {
|
|||
testMatch: ['**/?(*.)+(spec|test).ts?(x)'],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
|
||||
testPathIgnorePatterns: ['/node_modules/', '.d.ts$', '<rootDir>/vscode-icons/'],
|
||||
testPathIgnorePatterns: ['/node_modules/', '.d.ts$', '<rootDir>/vscode-icons/', '<rootDir>/e2e/'],
|
||||
|
||||
// The regexp pattern or array of patterns that Jest uses to detect test files
|
||||
// testRegex: [],
|
||||
|
|
@ -162,12 +162,27 @@ module.exports = {
|
|||
// timers: "real",
|
||||
|
||||
// A map from regular expressions to paths to transformers
|
||||
// transform: null,
|
||||
transform: {
|
||||
'^.+\\.(t|j)sx?$': [
|
||||
'@swc/jest',
|
||||
{
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'typescript',
|
||||
tsx: true,
|
||||
},
|
||||
transform: {
|
||||
react: {
|
||||
runtime: 'automatic',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
||||
// transformIgnorePatterns: [
|
||||
// "/node_modules/"
|
||||
// ],
|
||||
transformIgnorePatterns: ['/node_modules/(?!(webext-.*|superstruct)/)'],
|
||||
|
||||
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
|
||||
// unmockedModulePathPatterns: undefined,
|
||||
36
package.json
36
package.json
|
|
@ -11,18 +11,18 @@
|
|||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"dev": "VERSION=dev-v$(node scripts/get-version.js) NODE_OPTIONS=--openssl-legacy-provider webpack-dashboard -- webpack --watch",
|
||||
"dev": "VERSION=dev-v$(node scripts/get-version.js) webpack-dashboard -- webpack --watch",
|
||||
"dev:all": "GITAKO_TARGET= yarn run dev",
|
||||
"debug-firefox": "web-ext run --source-dir=dist-firefox --keep-profile-changes --start-url https://github.com/EnixCoda/Gitako",
|
||||
"prepare": "husky install",
|
||||
"postinstall": "patch-package",
|
||||
"postversion": "sh scripts/post-version.sh",
|
||||
"build": "VERSION=v$(node scripts/get-version.js) NODE_OPTIONS=--openssl-legacy-provider NODE_ENV=production webpack",
|
||||
"build": "VERSION=v$(node scripts/get-version.js) NODE_ENV=production webpack",
|
||||
"build:all": "GITAKO_TARGET= yarn run build",
|
||||
"build:analyze": "ANALYZE= yarn run build",
|
||||
"test": "playwright test",
|
||||
"test:ui": "playwright test --ui",
|
||||
"test:unit": "NODE_ENV=test jest --config jest.config.js"
|
||||
"test:unit": "NODE_ENV=test jest --config jest.config.cjs"
|
||||
},
|
||||
"dependencies": {
|
||||
"@primer/css": "^20.4.3",
|
||||
|
|
@ -45,15 +45,10 @@
|
|||
"webextension-polyfill": "^0.11.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.17.6",
|
||||
"@babel/core": "^7.17.9",
|
||||
"@babel/plugin-proposal-class-properties": "^7.16.7",
|
||||
"@babel/plugin-proposal-optional-chaining": "^7.16.7",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@babel/preset-react": "^7.16.7",
|
||||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@playwright/test": "^1.40.0",
|
||||
"@sentry/cli": "^1.64.2",
|
||||
"@swc/core": "^1.15.8",
|
||||
"@swc/jest": "^0.2.39",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@types/dotenv": "^6",
|
||||
"@types/firefox-webext-browser": "^120.0.3",
|
||||
|
|
@ -69,39 +64,38 @@
|
|||
"@types/styled-components": "^5.1.25",
|
||||
"@typescript-eslint/eslint-plugin": "^8.28.0",
|
||||
"@typescript-eslint/parser": "^8.28.0",
|
||||
"babel-loader": "^8.2.5",
|
||||
"babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
|
||||
"clean-webpack-plugin": "^4.0.0",
|
||||
"copy-webpack-plugin": "^12.0.2",
|
||||
"css-loader": "^2.1.0",
|
||||
"copy-webpack-plugin": "^13.0.1",
|
||||
"css-loader": "^7.1.2",
|
||||
"dotenv": "^6.2.0",
|
||||
"dotenv-webpack": "^8.1.0",
|
||||
"eslint": "^9.39.0",
|
||||
"eslint-config-prettier": "^10.1.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"eslint-plugin-react-hooks": "^5.2.0",
|
||||
"file-loader": "^3.0.1",
|
||||
"fork-ts-checker-webpack-plugin": "^9.0.2",
|
||||
"file-loader": "^6.2.0",
|
||||
"fork-ts-checker-webpack-plugin": "^9.1.0",
|
||||
"globals": "^16.0.0",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"json-loader": "^0.5.7",
|
||||
"lint-staged": "^13.0.3",
|
||||
"mini-css-extract-plugin": "^2.9.0",
|
||||
"mini-css-extract-plugin": "^2.10.0",
|
||||
"patch-package": "^8.0.0",
|
||||
"prettier": "^3.8.0",
|
||||
"raw-loader": "^4.0.0",
|
||||
"sass": "^1.26.2",
|
||||
"sass-loader": "^8.0.2",
|
||||
"sass-loader": "^16.0.6",
|
||||
"swc-loader": "^0.2.7",
|
||||
"ts-node": "^10.9.2",
|
||||
"typescript": "^5.9.3",
|
||||
"typescript-eslint": "^8.53.0",
|
||||
"url-loader": "^1.1.2",
|
||||
"url-loader": "^4.1.1",
|
||||
"web-ext": "^7.11.0",
|
||||
"webpack": "^5.91.0",
|
||||
"webpack": "^5.104.1",
|
||||
"webpack-bundle-analyzer": "^4.10.2",
|
||||
"webpack-cli": "^5.1.4",
|
||||
"webpack-cli": "^6.0.1",
|
||||
"webpack-dashboard": "^3.3.8"
|
||||
},
|
||||
"prettier": {
|
||||
|
|
|
|||
|
|
@ -145,18 +145,23 @@ function createConfig({ envTarget }: { envTarget: Target }) {
|
|||
rules: [
|
||||
{
|
||||
test: /\.tsx?$/,
|
||||
loader: 'babel-loader',
|
||||
loader: 'swc-loader',
|
||||
include: [srcPath],
|
||||
exclude: /node_modules/,
|
||||
sideEffects: false,
|
||||
},
|
||||
{
|
||||
test: /\.[cm]?js$/,
|
||||
loader: 'babel-loader',
|
||||
loader: 'swc-loader',
|
||||
// Transpile as least files under node_modules
|
||||
include: /node_modules\/(webext-.*|superstruct)\/.*\.[cm]?js$/,
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
jsc: {
|
||||
parser: {
|
||||
syntax: 'ecmascript',
|
||||
},
|
||||
target: 'es2022',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue