use pnpm, typescript boilerplate

This commit is contained in:
Kirill Zhumarin 2025-12-21 20:31:30 +00:00
parent 475c0d386c
commit 846b20d537
11 changed files with 2503 additions and 3169 deletions

View file

@ -4,3 +4,26 @@ root = true
indent_style = tab
indent_size = 4
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
max_line_length = 120
[*.md]
max_line_length = off
trim_trailing_whitespace = false
[*.py]
indent_size = 4
indent_style = space
[*.yml]
indent_size = 2
indent_style = space
[*.yaml]
indent_size = 2
indent_style = space
[{*.js,*.ts,*.jsx,*.tsx,*.vue}]
ij_typescript_spaces_within_imports = true

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
# IDE
.idea
# Logs
logs
*.log

View file

@ -9,8 +9,8 @@
<script>
(function () {
let media = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
let themeChange = () => {
const media = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)');
const themeChange = () => {
document.documentElement.setAttribute('data-bs-theme', media.matches ? 'dark' : 'light');
};
if (media) {
@ -23,6 +23,6 @@
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script src="/src/index.jsx" type="module"></script>
<script src="/src/index.tsx" type="module"></script>
</body>
</html>

View file

@ -1,19 +0,0 @@
{
"compilerOptions": {
"strict": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"types": ["vite/client"],
"noEmit": true,
"isolatedModules": true,
"baseUrl": "src/",
"paths": {
"~/*": ["*"]
}
}
}

2265
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -12,19 +12,27 @@
},
"license": "MIT",
"devDependencies": {
"solid-devtools": "^0.29.2",
"vite": "^5.0.11",
"vite-plugin-solid": "^2.8.2"
"@suid/vite-plugin": "^0.4.1",
"solid-devtools": "^0.29.3",
"vite": "^5.4.21",
"vite-plugin-solid": "^2.11.10",
"vite-plugin-solid-svg": "^0.8.1"
},
"dependencies": {
"@solidjs/router": "^0.13.3",
"bootstrap": "^5.3.3",
"bootstrap-icons": "^1.11.3",
"@solidjs/router": "^0.13.6",
"@suid/types": "^0.8.0",
"@types/debug": "^4.1.12",
"@types/sprintf-js": "^1.1.4",
"bootstrap": "^5.3.8",
"bootstrap-icons": "^1.13.1",
"date-fns": "^3.6.0",
"highlight.js": "^11.9.0",
"sass": "^1.77.1",
"solid-bootstrap": "^1.0.20",
"solid-js": "^1.8.11"
"highlight.js": "^11.11.1",
"sass": "^1.97.1",
"solid-bootstrap": "^1.0.21",
"solid-js": "^1.9.10",
"typescript": "^5.9.3",
"vite-plugin-node-polyfills": "^0.17.0",
"vite-tsconfig-paths": "^6.0.3"
},
"packageManager": "pnpm@11.0.0-dev.1005+sha512.91f84a392eea348ea4852a182912d2520273a4336f933b78cc44bc931eb999923c097e9433a9b355adc1f725725ea99082fc9f032a559df832632e764c92c798"
}

3134
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff

42
tsconfig.json Normal file
View file

@ -0,0 +1,42 @@
{
"compilerOptions": {
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "preserve",
"jsxImportSource": "solid-js",
"lib": [
"ESNext",
"DOM",
"DOM.Iterable"
],
"module": "ESNext",
"moduleResolution": "bundler",
"noEmit": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"baseUrl": ".",
"paths": {
"@/*": [
"./src/*"
]
},
"resolveJsonModule": true,
"skipLibCheck": true,
"strict": true,
"target": "ESNext",
"types": [
"vite-plugin-solid-svg/types-component-solid",
"vite/client",
"@types/w3c-web-serial"
]
},
"include": [
"src"
],
"references": [{
"path": "./tsconfig.node.json"
}]
}

11
tsconfig.node.json Normal file
View file

@ -0,0 +1,11 @@
{
"compilerOptions": {
"composite": true,
"skipLibCheck": true,
"module": "ESNext",
"moduleResolution": "bundler",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true
},
"include": ["vite.config.ts", "lingui.config.ts"]
}

View file

@ -1,50 +0,0 @@
import { defineConfig } from 'vite';
import solidPlugin from 'vite-plugin-solid';
// import devtools from 'solid-devtools/vite';
import path from 'path';
import fs from 'fs';
const ROUTES = [
`/re`,
`/swilib`,
`/swilib/phone`,
];
function postBuildPlugin() {
return {
name: 'postbuild-plugin',
async closeBundle() {
let outDir = `${import.meta.dirname}/dist`;
for (let routeDir of ROUTES) {
let symlinkSrc = path.relative(`${outDir}/${routeDir}`, `${outDir}/index.html`);
let symlinkDst = `${outDir}/${routeDir}/index.html`;
fs.mkdirSync(`${outDir}/${routeDir}`, { recursive: true });
if (!fs.existsSync(symlinkDst))
fs.symlinkSync(symlinkSrc, `${outDir}/${routeDir}/index.html`);
}
}
};
}
export default defineConfig({
resolve: {
alias: [{ find: '~', replacement: path.resolve(import.meta.dirname, '/src') }],
},
plugins: [
/*
Uncomment the following line to enable solid-devtools.
For more info see https://github.com/thetarnav/solid-devtools/tree/main/packages/extension#readme
*/
// devtools(),
solidPlugin(),
postBuildPlugin(),
],
server: {
port: 3000,
},
build: {
target: 'esnext',
},
});

91
vite.config.ts Normal file
View file

@ -0,0 +1,91 @@
import { defineConfig, Plugin } from 'vite';
import solidPlugin from 'vite-plugin-solid';
import suidPlugin from "@suid/vite-plugin";
import { nodePolyfills } from 'vite-plugin-node-polyfills';
import solidSvg from 'vite-plugin-solid-svg'
import tsconfigPaths from 'vite-tsconfig-paths';
import path from 'node:path';
import fs from 'node:fs';
const ROUTES = [
`/re`,
`/swilib`,
`/swilib/phone`,
];
function postBuildPlugin(): Plugin {
return {
name: 'postbuild-plugin',
async closeBundle() {
const isSymlinkExists = (file: string) => {
try {
fs.lstatSync(file);
return true;
} catch (e) {
return false;
}
};
let outDir = `${import.meta.dirname}/dist`;
for (let routeDir of ROUTES) {
let symlinkSrc = path.relative(`${outDir}/${routeDir}`, `${outDir}/index.html`);
let symlinkDst = `${outDir}/${routeDir}/index.html`;
fs.mkdirSync(`${outDir}/${routeDir}`, { recursive: true });
if (isSymlinkExists(symlinkDst))
fs.unlinkSync(symlinkDst);
fs.symlinkSync(symlinkSrc, `${outDir}/${routeDir}/index.html`);
}
}
};
}
export default defineConfig({
worker: {
format: 'es',
plugins: () => [ tsconfigPaths(), nodePolyfills() ]
},
plugins: [
suidPlugin(),
solidPlugin(),
tsconfigPaths(),
nodePolyfills(),
postBuildPlugin(),
solidSvg({
defaultAsComponent: true,
svgo: {
enabled: true,
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
},
}),
],
optimizeDeps: {
exclude: [
'siemens-sms-parser',
'@sie-js/creampie',
'@sie-js/libffshit',
'@ffmpeg/util',
'@ffmpeg/ffmpeg',
'@ffmpeg/core',
],
},
server: {
port: 3000,
},
build: {
target: 'esnext'
},
});