Skip to content

Commit 86679e8

Browse files
authored
Merge pull request #129 from DTStack/feat_6.5.2
Feat 6.5.2
2 parents 2bfe317 + 11bc19c commit 86679e8

File tree

15 files changed

+3140
-1534
lines changed

15 files changed

+3140
-1534
lines changed

.changeset/giant-moons-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ko': patch
3+
---
4+
5+
optimize devServer complation log and add dev log config

.changeset/long-jobs-grow.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ko': patch
3+
---
4+
5+
add port select when port used
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ko': patch
3+
---
4+
5+
add --max_old_space_size

.changeset/witty-items-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'ko': patch
3+
---
4+
5+
remove antd4Options when antd upgrade to 4+

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@
2424
}
2525
},
2626
"devDependencies": {
27-
"@changesets/cli": "^2.22.0",
28-
"@commitlint/cli": "^17.0.0",
29-
"@commitlint/config-conventional": "^17.0.0",
27+
"@changesets/cli": "^2.26.0",
28+
"@commitlint/cli": "^17.4.4",
29+
"@commitlint/config-conventional": "^17.4.4",
3030
"@tsconfig/node14": "^1.0.3",
31-
"@types/node": "^17.0.35",
32-
"commitizen": "^4.2.4",
31+
"@types/node": "^17.0.45",
32+
"commitizen": "^4.3.0",
3333
"cz-conventional-changelog": "^3.3.0",
34-
"husky": "^8.0.1",
35-
"prettier": "^2.6.2"
34+
"husky": "^8.0.3",
35+
"prettier": "^2.8.4"
3636
},
3737
"packageManager": "pnpm@6.32.12"
3838
}

packages/ko/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '@nuxt/friendly-errors-webpack-plugin';

packages/ko/package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"bugs": {
2121
"url": "https://github.com/DTStack/ko/issues"
2222
},
23+
"typings": "index.d.ts",
2324
"repository": {
2425
"type": "git",
2526
"url": "https://github.com/DTStack/ko",
@@ -41,6 +42,7 @@
4142
},
4243
"dependencies": {
4344
"@babel/core": "^7.18.0",
45+
"@nuxt/friendly-errors-webpack-plugin": "^2.5.2",
4446
"@parcel/css": "^1.12.2",
4547
"@pmmmwh/react-refresh-webpack-plugin": "^0.5.7",
4648
"auto-polyfills-webpack-plugin": "workspace:^1.1.0",
@@ -57,9 +59,11 @@
5759
"crypto-browserify": "^3.12.0",
5860
"css-loader": "^6.7.1",
5961
"css-minimizer-webpack-plugin": "^4.0.0",
62+
"detect-port": "^1.3.0",
6063
"dynamic-resolve-webpack-plugin": "workspace:^2.0.0",
6164
"esbuild-loader": "^2.19.0",
6265
"html-webpack-plugin": "^5.5.0",
66+
"inquirer": "^8.2.2",
6367
"ko-lints": "workspace:^4.0.0",
6468
"less": "^3.13.1",
6569
"less-loader": "^9.1.0",
@@ -86,6 +90,8 @@
8690
},
8791
"devDependencies": {
8892
"@types/case-sensitive-paths-webpack-plugin": "^2.1.6",
93+
"@types/detect-port": "^1.3.2",
94+
"@types/inquirer": "^8.2.2",
8995
"@types/jest": "^27.5.1",
9096
"@types/lodash": "^4.14.182",
9197
"@types/webpack-bundle-analyzer": "^4.4.1",

packages/ko/src/actions/dev.ts

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import Service from '../core/service';
66
import WebpackConfig from '../webpack';
77
import ActionFactory from './factory';
88
import { ICliOptions } from '../types';
9+
import detect from 'detect-port';
10+
import inquirer from 'inquirer';
911

1012
class Dev extends ActionFactory {
1113
private webpackConfig: WebpackConfig;
@@ -92,13 +94,44 @@ class Dev extends ActionFactory {
9294
this.service.commander.bindAction(cmdName, this.action.bind(this));
9395
}
9496

97+
private async changePort(newPort: number, port: number) {
98+
const question = {
99+
type: 'confirm',
100+
name: 'changePort',
101+
message: `port: ${port} has been used,use new port ${newPort} instead?`,
102+
default: true,
103+
};
104+
const answer = await inquirer.prompt([question]);
105+
if (answer.changePort) {
106+
return newPort;
107+
}
108+
this.errorStdout(`so sorry, ${port} already in use!!`);
109+
process.exit(0);
110+
}
111+
112+
private async checkPort(port: number) {
113+
const newPort = await detect(port);
114+
if (newPort === port) {
115+
return newPort;
116+
}
117+
const isInteractive = process.stdout.isTTY;
118+
if (isInteractive) {
119+
return this.changePort(newPort, port);
120+
}
121+
}
122+
95123
protected async action(cliOpts: ICliOptions) {
96124
process.title = 'ko-dev';
97125
process.env.NODE_ENV = 'development';
98126
this.service.freezeCliOptsWith(cliOpts);
99127
const config = await this.generateConfig();
128+
const port = config.devServer?.port as number;
129+
const newPort = (await this.checkPort(port)) as number;
100130
const compiler = Webpack(config);
101-
const devServer = new WebpackDevServer(config.devServer, compiler);
131+
const devServer = new WebpackDevServer(
132+
{ ...config.devServer, port: newPort },
133+
compiler
134+
);
102135
await devServer.start();
103136
const exitProcess = (callback?: () => void) => () => {
104137
callback && callback();

packages/ko/src/cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/bin/env node
1+
#!/usr/bin/env node --max_old_space_size=4096
22
'use strict';
33
import Service from './core/service';
44
import Dev from './actions/dev';

packages/ko/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ export type IOptions = {
1919
analyzer?: boolean;
2020
extraPostCSSPlugins?: Plugin[];
2121
lessOptions?: any;
22-
antdV4LessOptions?: any;
2322
// integrated plugins options
2423
dynamicResolve?: <T extends any>(request: T) => T;
2524
autoPolyfills: boolean | AutoPolyfillsWebpackPluginOptions;
@@ -30,6 +29,7 @@ export type IOptions = {
3029
port: number;
3130
staticPath?: string;
3231
historyApiFallback?: any;
32+
compilationSuccessInfo?: { messages: string[]; notes?: string[] };
3333
};
3434
// experimental features
3535
experiment?: {

0 commit comments

Comments
 (0)