@4399ywkf/core 5.1.3 → 5.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +93 -27
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +92 -26
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +2 -2
- package/dist/rspack/index.d.ts +1 -1
- package/dist/rspack/index.js +3 -2
- package/dist/rspack/index.js.map +1 -1
- package/dist/{schema-C91lhskq.d.ts → schema-CuEnqbqQ.d.ts} +5 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { G as GeneratorContext, e as PluginHooks, Y as YwkfConfig, f as PluginConfig } from './schema-
|
|
2
|
-
export { A as AnalyticsPluginOptions, h as BiomePluginOptions, j as BrowserCheckPluginOptions, k as BrowserMinVersions, y as BuildHooks, C as CodeInjection, D as DevServerConfig, E as EnvConfig, m as GarfishPluginOptions, F as GeneratedFile, J as GeneratorHooks, H as HtmlConfig, I as I18nPluginOptions, M as MicroFrontendConfig, q as MockPluginOptions, b as OutputConfig, P as PerformanceConfig, K as PluginContext, s as ReactQueryPluginOptions, R as RouterConfig, L as RouterHooks, N as RuntimeHooks, S as StyleConfig, u as TailwindPluginOptions, v as ThemePluginOptions, T as ToolsConfig, Q as YwkfPlugin, Z as ZustandPluginOptions, g as analyticsPlugin, i as biomePlugin, l as browserCheckPlugin, d as defaultConfig, a as defineConfig, n as garfishPlugin, o as getDefaultBiomeConfig, p as i18nPlugin, r as mockPlugin, t as reactQueryPlugin, w as tailwindPlugin, x as themePlugin, z as zustandPlugin } from './schema-
|
|
1
|
+
import { G as GeneratorContext, e as PluginHooks, Y as YwkfConfig, f as PluginConfig } from './schema-CuEnqbqQ.js';
|
|
2
|
+
export { A as AnalyticsPluginOptions, h as BiomePluginOptions, j as BrowserCheckPluginOptions, k as BrowserMinVersions, y as BuildHooks, C as CodeInjection, D as DevServerConfig, E as EnvConfig, m as GarfishPluginOptions, F as GeneratedFile, J as GeneratorHooks, H as HtmlConfig, I as I18nPluginOptions, M as MicroFrontendConfig, q as MockPluginOptions, b as OutputConfig, P as PerformanceConfig, K as PluginContext, s as ReactQueryPluginOptions, R as RouterConfig, L as RouterHooks, N as RuntimeHooks, S as StyleConfig, u as TailwindPluginOptions, v as ThemePluginOptions, T as ToolsConfig, Q as YwkfPlugin, Z as ZustandPluginOptions, g as analyticsPlugin, i as biomePlugin, l as browserCheckPlugin, d as defaultConfig, a as defineConfig, n as garfishPlugin, o as getDefaultBiomeConfig, p as i18nPlugin, r as mockPlugin, t as reactQueryPlugin, w as tailwindPlugin, x as themePlugin, z as zustandPlugin } from './schema-CuEnqbqQ.js';
|
|
3
3
|
import { Compiler } from '@rspack/core';
|
|
4
4
|
export { PluginManager, createPlugin, definePlugin } from './plugin/index.js';
|
|
5
5
|
export { ConventionalRouteGenerator, ConventionalRoutePlugin, ConventionalRoutePluginOptions, GeneratorOptions, RouteConfig, generateConventionalRoutes } from './router/index.js';
|
package/dist/index.js
CHANGED
|
@@ -2125,6 +2125,7 @@ var defaultConfig = {
|
|
|
2125
2125
|
appName: "app",
|
|
2126
2126
|
appCName: "\u5E94\u7528",
|
|
2127
2127
|
strictMode: true,
|
|
2128
|
+
reactCompiler: false,
|
|
2128
2129
|
dev: {
|
|
2129
2130
|
port: 3e3,
|
|
2130
2131
|
host: "127.0.0.1",
|
|
@@ -3443,7 +3444,7 @@ var coreNodeModules = join12(__dirname, "../../node_modules");
|
|
|
3443
3444
|
function createBaseConfig(config, cwd, options = {}) {
|
|
3444
3445
|
const isDev = options.isDev ?? process.env.NODE_ENV !== "production";
|
|
3445
3446
|
const { resolveApp } = createPathResolver(cwd);
|
|
3446
|
-
const { appName, appCName, output, html, alias: userAlias, microFrontend, router } = config;
|
|
3447
|
+
const { appName, appCName, output, html, alias: userAlias, microFrontend, router, reactCompiler } = config;
|
|
3447
3448
|
const ywkfOutputDir = resolveApp(".ywkf");
|
|
3448
3449
|
const defaultAlias = {
|
|
3449
3450
|
"@": resolveApp("src"),
|
|
@@ -3529,7 +3530,8 @@ function createBaseConfig(config, cwd, options = {}) {
|
|
|
3529
3530
|
runtime: "automatic",
|
|
3530
3531
|
development: isDev,
|
|
3531
3532
|
refresh: isDev
|
|
3532
|
-
}
|
|
3533
|
+
},
|
|
3534
|
+
...reactCompiler ? { reactCompiler } : {}
|
|
3533
3535
|
},
|
|
3534
3536
|
target: "es2015"
|
|
3535
3537
|
},
|
|
@@ -4447,33 +4449,74 @@ import { RspackDevServer } from "@rspack/dev-server";
|
|
|
4447
4449
|
import chalk3 from "chalk";
|
|
4448
4450
|
|
|
4449
4451
|
// src/cli/port.ts
|
|
4452
|
+
import { execFile } from "child_process";
|
|
4450
4453
|
import net from "net";
|
|
4451
|
-
|
|
4452
|
-
|
|
4454
|
+
import { promisify } from "util";
|
|
4455
|
+
var execFileAsync = promisify(execFile);
|
|
4456
|
+
var PortInUseError = class extends Error {
|
|
4457
|
+
constructor(port, host) {
|
|
4458
|
+
super(`Port ${port} is already in use on ${host}`);
|
|
4459
|
+
this.port = port;
|
|
4460
|
+
this.host = host;
|
|
4461
|
+
this.name = "PortInUseError";
|
|
4462
|
+
}
|
|
4463
|
+
};
|
|
4464
|
+
function ensurePortAvailable(port, host) {
|
|
4465
|
+
return new Promise((resolve5, reject) => {
|
|
4453
4466
|
const server = net.createServer();
|
|
4454
4467
|
server.once("error", (err) => {
|
|
4455
4468
|
if (err.code === "EADDRINUSE") {
|
|
4456
|
-
|
|
4469
|
+
reject(new PortInUseError(port, host));
|
|
4457
4470
|
} else {
|
|
4458
|
-
|
|
4471
|
+
reject(err);
|
|
4459
4472
|
}
|
|
4460
4473
|
});
|
|
4461
4474
|
server.once("listening", () => {
|
|
4462
|
-
server.close(() => resolve5(
|
|
4475
|
+
server.close(() => resolve5());
|
|
4463
4476
|
});
|
|
4464
4477
|
server.listen(port, host);
|
|
4465
4478
|
});
|
|
4466
4479
|
}
|
|
4467
|
-
async function
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4480
|
+
async function findPortHolder(port) {
|
|
4481
|
+
try {
|
|
4482
|
+
if (process.platform === "win32") {
|
|
4483
|
+
const { stdout: stdout2 } = await execFileAsync("netstat", ["-ano", "-p", "tcp"], {
|
|
4484
|
+
timeout: 1500
|
|
4485
|
+
});
|
|
4486
|
+
const pid2 = parseWindowsNetstatPid(stdout2, port);
|
|
4487
|
+
return pid2 === null ? null : { pid: pid2 };
|
|
4488
|
+
}
|
|
4489
|
+
const { stdout } = await execFileAsync(
|
|
4490
|
+
"lsof",
|
|
4491
|
+
["-nP", `-iTCP:${port}`, "-sTCP:LISTEN", "-t"],
|
|
4492
|
+
{ timeout: 1500 }
|
|
4493
|
+
);
|
|
4494
|
+
const pid = Number.parseInt(stdout.trim().split(/\s+/)[0], 10);
|
|
4495
|
+
if (!Number.isInteger(pid)) return null;
|
|
4496
|
+
let name;
|
|
4497
|
+
try {
|
|
4498
|
+
const { stdout: comm } = await execFileAsync(
|
|
4499
|
+
"ps",
|
|
4500
|
+
["-p", String(pid), "-o", "comm="],
|
|
4501
|
+
{ timeout: 1500 }
|
|
4502
|
+
);
|
|
4503
|
+
name = comm.trim().split("/").pop() || void 0;
|
|
4504
|
+
} catch {
|
|
4505
|
+
}
|
|
4506
|
+
return { pid, name };
|
|
4507
|
+
} catch {
|
|
4508
|
+
return null;
|
|
4473
4509
|
}
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
)
|
|
4510
|
+
}
|
|
4511
|
+
function parseWindowsNetstatPid(stdout, port) {
|
|
4512
|
+
for (const line of stdout.split(/\r?\n/)) {
|
|
4513
|
+
const parts = line.trim().split(/\s+/);
|
|
4514
|
+
if (parts.length >= 5 && parts[3] === "LISTENING" && parts[1]?.endsWith(`:${port}`)) {
|
|
4515
|
+
const pid = Number.parseInt(parts[4], 10);
|
|
4516
|
+
if (Number.isInteger(pid)) return pid;
|
|
4517
|
+
}
|
|
4518
|
+
}
|
|
4519
|
+
return null;
|
|
4477
4520
|
}
|
|
4478
4521
|
|
|
4479
4522
|
// src/cli/restart-watcher.ts
|
|
@@ -4538,6 +4581,22 @@ async function loadFullConfig(cwd, mode, envSnapshot, opts = {}) {
|
|
|
4538
4581
|
loadEnv(config, cwd, mode, "development");
|
|
4539
4582
|
return config;
|
|
4540
4583
|
}
|
|
4584
|
+
async function renderPortInUseError(err) {
|
|
4585
|
+
const holder = await findPortHolder(err.port);
|
|
4586
|
+
console.error();
|
|
4587
|
+
console.error(chalk3.red(` \u2716 \u7AEF\u53E3 ${err.port} \u5DF2\u88AB\u5360\u7528\uFF0C\u65E0\u6CD5\u542F\u52A8 dev server`));
|
|
4588
|
+
if (holder) {
|
|
4589
|
+
const label = holder.name ? `${holder.name} ` : "";
|
|
4590
|
+
const killCmd = process.platform === "win32" ? `taskkill /PID ${holder.pid} /F` : `kill ${holder.pid}`;
|
|
4591
|
+
console.error(chalk3.gray(` \u5360\u7528\u8FDB\u7A0B\uFF1A${label}(PID ${holder.pid})`));
|
|
4592
|
+
console.error(chalk3.gray(` \xB7 \u7ED3\u675F\u5B83\uFF1A${killCmd}`));
|
|
4593
|
+
console.error(chalk3.gray(" \xB7 \u6216\u4FEE\u6539\u914D\u7F6E dev.port \u6362\u4E00\u4E2A\u7AEF\u53E3"));
|
|
4594
|
+
} else {
|
|
4595
|
+
console.error(chalk3.gray(" \xB7 \u4FEE\u6539\u914D\u7F6E dev.port \u6362\u4E00\u4E2A\u7AEF\u53E3"));
|
|
4596
|
+
console.error(chalk3.gray(" \xB7 \u6216\u5148\u91CA\u653E\u5360\u7528\u8BE5\u7AEF\u53E3\u7684\u8FDB\u7A0B"));
|
|
4597
|
+
}
|
|
4598
|
+
console.error();
|
|
4599
|
+
}
|
|
4541
4600
|
async function startDevServer(cwd, config) {
|
|
4542
4601
|
const pluginManager = new PluginManager(config, cwd, true);
|
|
4543
4602
|
if (config.plugins && config.plugins.length > 0) {
|
|
@@ -4547,13 +4606,9 @@ async function startDevServer(cwd, config) {
|
|
|
4547
4606
|
let rspackConfig = createRspackConfig(config, cwd, { isDev: true });
|
|
4548
4607
|
rspackConfig = await pluginManager.applyRspackConfigHooks(rspackConfig);
|
|
4549
4608
|
const host = config.dev.host || "127.0.0.1";
|
|
4550
|
-
const
|
|
4551
|
-
|
|
4609
|
+
const port = config.dev.port || 3e3;
|
|
4610
|
+
await ensurePortAvailable(port, host);
|
|
4552
4611
|
const pluginNames = pluginManager.getPluginNames();
|
|
4553
|
-
if (port !== preferredPort) {
|
|
4554
|
-
console.log(chalk3.yellow(` Port ${preferredPort} is in use, using ${port} instead.
|
|
4555
|
-
`));
|
|
4556
|
-
}
|
|
4557
4612
|
const printer = new DevPrinter(host, port, pluginNames);
|
|
4558
4613
|
printer.printBanner();
|
|
4559
4614
|
printer.printBuildStart();
|
|
@@ -4671,10 +4726,17 @@ async function dev(options = {}) {
|
|
|
4671
4726
|
await current.close();
|
|
4672
4727
|
current = await startDevServer(cwd, nextConfig);
|
|
4673
4728
|
} catch (error) {
|
|
4674
|
-
|
|
4675
|
-
|
|
4676
|
-
|
|
4677
|
-
|
|
4729
|
+
if (error instanceof PortInUseError) {
|
|
4730
|
+
await renderPortInUseError(error);
|
|
4731
|
+
console.error(
|
|
4732
|
+
chalk3.red(" \u2716 dev server \u91CD\u542F\u5931\u8D25\uFF0C\u5F53\u524D\u670D\u52A1\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4FEE\u6B63\u540E\u4FDD\u5B58\u91CD\u8BD5")
|
|
4733
|
+
);
|
|
4734
|
+
} else {
|
|
4735
|
+
console.error(
|
|
4736
|
+
chalk3.red(" \u2716 dev server \u91CD\u542F\u5931\u8D25\uFF0C\u5F53\u524D\u670D\u52A1\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4FEE\u6B63\u540E\u4FDD\u5B58\u91CD\u8BD5:")
|
|
4737
|
+
);
|
|
4738
|
+
console.error(error);
|
|
4739
|
+
}
|
|
4678
4740
|
}
|
|
4679
4741
|
} while (pending);
|
|
4680
4742
|
} finally {
|
|
@@ -4683,6 +4745,10 @@ async function dev(options = {}) {
|
|
|
4683
4745
|
}
|
|
4684
4746
|
});
|
|
4685
4747
|
} catch (error) {
|
|
4748
|
+
if (error instanceof PortInUseError) {
|
|
4749
|
+
await renderPortInUseError(error);
|
|
4750
|
+
process.exit(1);
|
|
4751
|
+
}
|
|
4686
4752
|
console.error();
|
|
4687
4753
|
console.error(chalk3.red(" \u2716 Dev server failed to start"));
|
|
4688
4754
|
console.error(error);
|