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

将 node 环境的 tsconfig 单独抽离出来 #3961

Open
wants to merge 6 commits into
base: preview-features
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
'import/no-default-export': 'error',
'import/no-named-default': 'off',

'@typescript-eslint/consistent-type-imports': 'error',
'@typescript-eslint/member-delimiter-style': 'off',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
Expand Down
102 changes: 86 additions & 16 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,63 +8,108 @@
"command": "pnpm ts-node ./dev-tools/dev-server/index.ts",
"group": "build",
"problemMatcher": [],
"label": "启动开发服务 dev-server"
"label": "启动开发服务 dev-server",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --config ./webpack/webpack.dev.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "本体:编译开发版本 dev:build-core"
"label": "本体:编译开发版本 dev:build-core",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --watch --config ./webpack/webpack.dev.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "本体:监视开发版本 dev:watch-core"
"label": "本体:监视开发版本 dev:watch-core",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm serve dist -p ${input:serverPort}",
"group": "build",
"problemMatcher": [],
"label": "本体:启动服务器 dev:serve-core"
"label": "本体:启动服务器 dev:serve-core",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm serve registry/dist -p ${input:serverPort}",
"group": "build",
"problemMatcher": [],
"label": "功能:启动服务器 dev:serve-features"
"label": "功能:启动服务器 dev:serve-features",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --watch --config ./registry/webpack/components.ts --progress --mode=development",
"group": "build",
"problemMatcher": [],
"label": "功能:监视组件 dev:watch-components"
"label": "功能:监视组件 dev:watch-components",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --watch --config ./registry/webpack/plugins.ts --progress --mode=development",
"group": "build",
"problemMatcher": [],
"label": "功能:监视插件 dev:watch-plugins"
"label": "功能:监视插件 dev:watch-plugins",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm tsc -p tsconfig.type-check.json --noEmit",
"command": "pnpm tsc -p tsconfig.json --noEmit",
"group": "build",
"problemMatcher": [],
"label": "生产:类型检查 prod:type"
"label": "生产:类型检查 prod:type",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm --silent webpack --config ./webpack/webpack.prod.ts --profile --json > dist/profile.json && pnpm webpack-bundle-analyzer dist/profile.json",
"group": "build",
"problemMatcher": [],
"label": "本体:打包分析 prod:analyze"
"label": "本体:打包分析 prod:analyze",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
Expand All @@ -85,35 +130,60 @@
"command": "pnpm webpack --config ./webpack/webpack.prod.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "本体:编译生产版本 prod:build-core"
"label": "本体:编译生产版本 prod:build-core",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --config ./registry/webpack/components.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "功能:编译组件 prod:build-components"
"label": "功能:编译组件 prod:build-components",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --config ./registry/webpack/plugins.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "功能:编译插件 prod:build-plugins"
"label": "功能:编译插件 prod:build-plugins",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --config ./registry/webpack/all.ts",
"group": "build",
"problemMatcher": [],
"label": "功能:编译所有 prod:build-features"
"label": "功能:编译所有 prod:build-features",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
"command": "pnpm webpack --config ./registry/webpack/docs.ts --progress",
"group": "build",
"problemMatcher": [],
"label": "功能:编译功能文档 prod:build-docs"
"label": "功能:编译功能文档 prod:build-docs",
"options": {
"env": {
"TS_NODE_PROJECT": "tsconfig.node.json"
}
}
},
{
"type": "shell",
Expand Down Expand Up @@ -142,4 +212,4 @@
"default": "5000"
}
]
}
}
2 changes: 1 addition & 1 deletion dev-tools/dev-server/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { readFileSync, existsSync } from 'fs'
import { existsSync, readFileSync } from 'fs'

interface DevServerConfig {
port?: number
Expand Down
7 changes: 4 additions & 3 deletions dev-tools/dev-server/core-watcher.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import webpack from 'webpack'
import exitHook from 'async-exit-hook'
import webpackConfig from '../../webpack/webpack.dev'
import { sendMessage } from './web-socket-server'
import webpack from 'webpack'

import webpackConfig from 'webpack/webpack.dev'
import { defaultWatcherHandler } from './watcher-common'
import { sendMessage } from './web-socket-server'

export const startCoreWatcher = () =>
new Promise<void>(resolve => {
Expand Down
2 changes: 1 addition & 1 deletion dev-tools/dev-server/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { startDevServer } from './server'
import { startCoreWatcher } from './core-watcher'
import { startDevServer } from './server'
import { startWebSocketServer } from './web-socket-server'

startDevServer().then(server => {
Expand Down
6 changes: 4 additions & 2 deletions dev-tools/dev-server/registry-watcher.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Watching, Configuration, webpack } from 'webpack'
import exitHook from 'async-exit-hook'
import type { Configuration, Watching } from 'webpack'
import { webpack } from 'webpack'

import { fromId } from '../../registry/lib/id'
import { devServerConfig } from './config'
import { defaultWatcherHandler } from './watcher-common'
import { sendMessage } from './web-socket-server'
import { devServerConfig } from './config'

export const watchers: { url: string; instance: Watching }[] = []
export const parseRegistryUrl = (url: string) => {
Expand Down
10 changes: 6 additions & 4 deletions dev-tools/dev-server/server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { createServer, Server } from 'http'
import { Configuration } from 'webpack'
import exitHook from 'async-exit-hook'
import type { Server } from 'http'
import { createServer } from 'http'
import handler from 'serve-handler'
import type { Configuration } from 'webpack'

import { buildByEntry } from 'registry/webpack/config'
import { devServerConfig } from './config'
import { buildByEntry } from '../../registry/webpack/config'
import { parseRegistryUrl, startRegistryWatcher, watchers } from './registry-watcher'
import { exitWebSocketServer } from './web-socket-server'
import { watchers, parseRegistryUrl, startRegistryWatcher } from './registry-watcher'

export const startDevServer = () =>
new Promise<Server>(resolve => {
Expand Down
7 changes: 0 additions & 7 deletions dev-tools/dev-server/tsconfig.json

This file was deleted.

2 changes: 1 addition & 1 deletion dev-tools/dev-server/watcher-common.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stats } from 'webpack'
import type { Stats } from 'webpack'

export const defaultWatcherHandler = (
initCallback: (result: Stats) => void,
Expand Down
5 changes: 3 additions & 2 deletions dev-tools/dev-server/web-socket-server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import exitHook from 'async-exit-hook'
import { Server } from 'http'
import type { Server } from 'http'
import { WebSocketServer } from 'ws'
import { Payload } from './payload'

import type { Payload } from './payload'
import { stopInstance, watchers } from './registry-watcher'

let server: WebSocketServer
Expand Down
13 changes: 0 additions & 13 deletions dev-tools/donate-table/tsconfig.json

This file was deleted.

4 changes: 4 additions & 0 deletions dev-tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// 为 IDE 提供的配置
{
"extends": "../tsconfig.node.json"
}
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"author": "Grant Howard, Coulomb-G",
"license": "MIT",
"scripts": {
"build-core": "webpack --config ./webpack/webpack.prod.ts --bail",
"build-features": "webpack --config ./registry/webpack/all.ts --bail",
"build-core": "cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack --config ./webpack/webpack.prod.ts --bail",
"build-features": "cross-env TS_NODE_PROJECT='tsconfig.node.json' webpack --config ./registry/webpack/all.ts --bail",
"lint": "eslint --quiet --fix . --ext .ts,.vue",
"lint-check": "eslint . --ext .ts,.vue",
"type": "tsc -p tsconfig.type-check.json --noEmit"
"type": "tsc -p tsconfig.json --noEmit"
},
"devDependencies": {
"@babel/core": "7.17.9",
Expand All @@ -29,14 +29,16 @@
"@types/serve-handler": "^6.1.1",
"@types/sortablejs": "^1.10.7",
"@types/streamsaver": "^2.0.1",
"@types/webpack-env": "^1.15.1",
"@types/webpack-env": "^1.16.4",
"@types/ws": "^8.2.3",
"@typescript-eslint/eslint-plugin": "^5.9.1",
"@typescript-eslint/parser": "^5.9.1",
"@vue/tsconfig": "^0.1.3",
"async-exit-hook": "^2.0.1",
"autoprefixer": "^10.0.1",
"babel-loader": "^8.1.0",
"browserslist": "^4.21.4",
"cross-env": "^7.0.3",
"css-loader": "^5.0.0",
"eslint": "^7.32.0",
"eslint-config-airbnb-base": "^14.1.0",
Expand All @@ -57,6 +59,7 @@
"terser-webpack-plugin": "^5.0.1",
"to-string-loader": "^1.2.0",
"ts-node": "^10.7.0",
"tsconfig-paths": "^4.1.2",
"typescript": "^4.4.4",
"vue-loader": "^15.8.3",
"vue-template-compiler": "^2.6.11",
Expand Down
Loading