mirror of
https://github.com/alex8088/electron-vite.git
synced 2026-07-10 16:31:10 +08:00
Compare commits
11 Commits
8e1f9f6845
...
f951edf492
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f951edf492 | ||
|
|
7c6020e11b | ||
|
|
4e48537b39 | ||
|
|
10099eced0 | ||
|
|
fbc45f696b | ||
|
|
d30d3765eb | ||
|
|
5c4c28ca0a | ||
|
|
5e31794c2d | ||
|
|
588b39b0b4 | ||
|
|
ce56ecd4dc | ||
|
|
5021496f74 |
@ -18,6 +18,7 @@ module.exports = {
|
||||
'plugin:prettier/recommended'
|
||||
],
|
||||
rules: {
|
||||
'prettier/prettier': 'warn',
|
||||
'no-empty': ['warn', { allowEmptyCatch: true }],
|
||||
'@typescript-eslint/ban-ts-comment': ['error', { 'ts-ignore': 'allow-with-description' }],
|
||||
'@typescript-eslint/explicit-function-return-type': 'error',
|
||||
|
||||
11
.vscode/settings.json
vendored
Normal file
11
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
},
|
||||
"[json]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
|
||||
|
||||
"mainEntryPointFilePath": "./dist/types/index.d.ts",
|
||||
|
||||
"dtsRollup": {
|
||||
"enabled": true,
|
||||
"untrimmedFilePath": "",
|
||||
"publicTrimmedFilePath": "./dist/index.d.ts"
|
||||
},
|
||||
|
||||
"apiReport": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"docModel": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"tsdocMetadata": {
|
||||
"enabled": false
|
||||
},
|
||||
|
||||
"messages": {
|
||||
"compilerMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
}
|
||||
},
|
||||
|
||||
"extractorMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning",
|
||||
"addToApiReportFile": true
|
||||
},
|
||||
|
||||
"ae-missing-release-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
},
|
||||
|
||||
"tsdocMessageReporting": {
|
||||
"default": {
|
||||
"logLevel": "warning"
|
||||
},
|
||||
|
||||
"tsdoc-undefined-tag": {
|
||||
"logLevel": "none"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
45
package.json
45
package.json
@ -36,7 +36,7 @@
|
||||
"format": "prettier --write .",
|
||||
"lint": "eslint --ext .ts src/**",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"build": "npm run lint && node scripts/build.js"
|
||||
"build": "pnpm run lint && rollup -c rollup.config.ts --configPlugin typescript"
|
||||
},
|
||||
"simple-git-hooks": {
|
||||
"pre-commit": "npx lint-staged",
|
||||
@ -61,31 +61,30 @@
|
||||
}
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/api-extractor": "^7.36.1",
|
||||
"@rollup/plugin-node-resolve": "^15.1.0",
|
||||
"@rollup/plugin-typescript": "^9.0.2",
|
||||
"@swc/core": "^1.3.68",
|
||||
"@types/node": "^18.16.19",
|
||||
"@typescript-eslint/eslint-plugin": "^6.2.0",
|
||||
"@typescript-eslint/parser": "^6.2.0",
|
||||
"eslint": "^8.44.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-plugin-prettier": "^5.0.0",
|
||||
"fs-extra": "^11.1.1",
|
||||
"lint-staged": "^13.2.3",
|
||||
"prettier": "^3.0.0",
|
||||
"rollup": "^3.26.2",
|
||||
"simple-git-hooks": "^2.8.1",
|
||||
"tslib": "^2.6.0",
|
||||
"typescript": "5.0.4",
|
||||
"vite": "^4.4.2"
|
||||
"@rollup/plugin-node-resolve": "^15.2.3",
|
||||
"@rollup/plugin-typescript": "^11.1.5",
|
||||
"@swc/core": "^1.3.100",
|
||||
"@types/node": "^18.19.3",
|
||||
"@typescript-eslint/eslint-plugin": "^6.13.2",
|
||||
"@typescript-eslint/parser": "^6.13.2",
|
||||
"eslint": "^8.55.0",
|
||||
"eslint-config-prettier": "^9.1.0",
|
||||
"eslint-plugin-prettier": "^5.0.1",
|
||||
"lint-staged": "^15.2.0",
|
||||
"prettier": "^3.1.0",
|
||||
"rollup": "^4.6.1",
|
||||
"rollup-plugin-dts": "^6.1.0",
|
||||
"simple-git-hooks": "^2.9.0",
|
||||
"tslib": "^2.6.2",
|
||||
"typescript": "^5.3.3",
|
||||
"vite": "^5.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@babel/core": "^7.22.8",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.22.5",
|
||||
"@babel/core": "^7.23.5",
|
||||
"@babel/plugin-transform-arrow-functions": "^7.23.3",
|
||||
"cac": "^6.7.14",
|
||||
"esbuild": "^0.18.11",
|
||||
"magic-string": "^0.30.1",
|
||||
"esbuild": "^0.19.8",
|
||||
"magic-string": "^0.30.5",
|
||||
"picocolors": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
1644
pnpm-lock.yaml
generated
1644
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
54
rollup.config.ts
Normal file
54
rollup.config.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import { createRequire } from 'node:module'
|
||||
import fs from 'node:fs/promises'
|
||||
import { type Plugin, defineConfig } from 'rollup'
|
||||
import ts from '@rollup/plugin-typescript'
|
||||
import resolve from '@rollup/plugin-node-resolve'
|
||||
import dts from 'rollup-plugin-dts'
|
||||
|
||||
const require = createRequire(import.meta.url)
|
||||
const pkg = require('./package.json')
|
||||
|
||||
const external = ['esbuild', ...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
|
||||
|
||||
function clean(when: 'buildStart' | 'buildEnd', target: string): Plugin {
|
||||
const _clean = async (target): Promise<void> => {
|
||||
await fs.rm(target, { recursive: true, force: true }).catch(() => {})
|
||||
}
|
||||
return {
|
||||
name: 'clean',
|
||||
buildStart: async (): Promise<void> => {
|
||||
if (when !== 'buildStart') return
|
||||
await _clean(target)
|
||||
},
|
||||
buildEnd: async (): Promise<void> => {
|
||||
if (when !== 'buildEnd') return
|
||||
await _clean(target)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default defineConfig([
|
||||
{
|
||||
input: ['src/index.ts', 'src/cli.ts'],
|
||||
output: {
|
||||
dir: 'dist',
|
||||
entryFileNames: '[name].js',
|
||||
chunkFileNames: 'chunks/lib-[hash].js',
|
||||
format: 'cjs'
|
||||
},
|
||||
external,
|
||||
plugins: [
|
||||
clean('buildStart', 'dist'),
|
||||
ts({ compilerOptions: { rootDir: 'src', declaration: true, declarationDir: 'dist/types' } }),
|
||||
resolve()
|
||||
],
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
},
|
||||
{
|
||||
input: 'dist/types/index.d.ts',
|
||||
output: [{ file: pkg.types, format: 'es' }],
|
||||
plugins: [dts(), clean('buildEnd', 'dist/types')]
|
||||
}
|
||||
])
|
||||
@ -1,67 +0,0 @@
|
||||
const path = require('path')
|
||||
const colors = require('picocolors')
|
||||
const fs = require('fs-extra')
|
||||
const rollup = require('rollup')
|
||||
const typescript = require('@rollup/plugin-typescript')
|
||||
const { nodeResolve } = require('@rollup/plugin-node-resolve')
|
||||
const { Extractor, ExtractorConfig } = require('@microsoft/api-extractor')
|
||||
|
||||
;(async () => {
|
||||
const dist = path.resolve(__dirname, '../dist')
|
||||
|
||||
await fs.remove(dist)
|
||||
|
||||
console.log()
|
||||
console.log(colors.bold(colors.yellow(`Rolling up ts code...`)))
|
||||
|
||||
const pkg = require('../package.json')
|
||||
|
||||
const external = ['esbuild', ...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})]
|
||||
|
||||
const bundle = await rollup.rollup({
|
||||
input: {
|
||||
index: path.resolve(__dirname, '../src/index.ts'),
|
||||
cli: path.resolve(__dirname, '../src/cli.ts')
|
||||
},
|
||||
external,
|
||||
plugins: [
|
||||
typescript({
|
||||
tsconfig: path.resolve(__dirname, '../tsconfig.json')
|
||||
}),
|
||||
nodeResolve()
|
||||
],
|
||||
treeshake: {
|
||||
moduleSideEffects: false
|
||||
}
|
||||
})
|
||||
await bundle.write({
|
||||
dir: dist,
|
||||
entryFileNames: '[name].js',
|
||||
chunkFileNames: 'chunks/lib-[hash].js',
|
||||
format: 'cjs'
|
||||
})
|
||||
|
||||
console.log(colors.bold(colors.yellow(`Rolling up type definitions...`)))
|
||||
|
||||
if (pkg.types) {
|
||||
const extractorConfig = ExtractorConfig.loadFileAndPrepare(path.resolve(__dirname, '../api-extractor.json'))
|
||||
const extractorResult = Extractor.invoke(extractorConfig, {
|
||||
localBuild: true,
|
||||
showVerboseMessages: true
|
||||
})
|
||||
|
||||
if (extractorResult.succeeded) {
|
||||
console.log(colors.green('API Extractor completed successfully'))
|
||||
} else {
|
||||
console.error(
|
||||
`API Extractor completed with ${extractorResult.errorCount} errors` +
|
||||
` and ${extractorResult.warningCount} warnings`
|
||||
)
|
||||
process.exitCode = 1
|
||||
}
|
||||
}
|
||||
|
||||
await fs.remove(path.resolve(dist, 'types'))
|
||||
|
||||
console.log(colors.green(`Build ${pkg.name}@${pkg.version} successfully`))
|
||||
})()
|
||||
@ -14,10 +14,7 @@
|
||||
"noUnusedLocals": true,
|
||||
"noUnusedParameters": true,
|
||||
"noImplicitAny": false,
|
||||
"noImplicitReturns": true,
|
||||
"declaration": true,
|
||||
"declarationDir": "dist/types",
|
||||
"outDir": "dist"
|
||||
"noImplicitReturns": true
|
||||
},
|
||||
"include": ["src"]
|
||||
"include": ["src", "rollup.config.ts"]
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user