@modern-js/server 3.0.0-alpha.1 → 3.0.0
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/cjs/createDevServer.js +1 -2
- package/dist/cjs/dev-tools/https/index.js +1 -6
- package/dist/esm/createDevServer.mjs +4 -5
- package/dist/esm/dev-tools/https/index.mjs +2 -7
- package/dist/esm/dev-tools/watcher/index.mjs +2 -2
- package/dist/esm/dev.mjs +1 -1
- package/dist/esm/helpers/index.mjs +7 -7
- package/dist/esm/index.mjs +1 -1
- package/dist/esm-node/createDevServer.mjs +2 -2
- package/dist/esm-node/dev-tools/https/index.mjs +7 -7
- package/dist/esm-node/dev-tools/watcher/dependencyTree.mjs +1 -0
- package/dist/esm-node/dev-tools/watcher/index.mjs +2 -0
- package/dist/esm-node/dev-tools/watcher/statsCache.mjs +1 -0
- package/dist/esm-node/dev.mjs +1 -0
- package/dist/esm-node/helpers/devOptions.mjs +1 -0
- package/dist/esm-node/helpers/fileReader.mjs +1 -0
- package/dist/esm-node/helpers/index.mjs +2 -0
- package/dist/esm-node/helpers/mock.mjs +1 -0
- package/dist/esm-node/helpers/repack.mjs +2 -0
- package/dist/esm-node/helpers/utils.mjs +1 -0
- package/dist/esm-node/index.mjs +1 -0
- package/dist/esm-node/types.mjs +1 -0
- package/dist/types/types.d.ts +1 -5
- package/package.json +13 -31
- package/rstest.config.ts +5 -0
|
@@ -73,8 +73,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
73
73
|
compiler = context.compiler;
|
|
74
74
|
});
|
|
75
75
|
const builderDevServer = await builder?.createDevServer({
|
|
76
|
-
runCompile: options.runCompile
|
|
77
|
-
compiler: options.compiler
|
|
76
|
+
runCompile: options.runCompile
|
|
78
77
|
});
|
|
79
78
|
server.addPlugins([
|
|
80
79
|
(0, external_dev_js_namespaceObject.devPlugin)({
|
|
@@ -32,12 +32,7 @@ const genHttpsOptions = async (userOptions, pwd)=>{
|
|
|
32
32
|
if (!httpsOptions.key || !httpsOptions.cert) {
|
|
33
33
|
let devcertPath;
|
|
34
34
|
try {
|
|
35
|
-
devcertPath =
|
|
36
|
-
paths: [
|
|
37
|
-
pwd,
|
|
38
|
-
__dirname
|
|
39
|
-
]
|
|
40
|
-
});
|
|
35
|
+
devcertPath = (0, utils_namespaceObject.tryResolve)('devcert', pwd, __dirname);
|
|
41
36
|
} catch (err) {
|
|
42
37
|
const packageManager = await (0, utils_namespaceObject.getPackageManager)(pwd);
|
|
43
38
|
const command = utils_namespaceObject.chalk.yellow.bold(`${packageManager} add devcert@1.2.2 -D`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import node_path from "node:path";
|
|
2
2
|
import { createServerBase } from "@modern-js/server-core";
|
|
3
3
|
import { createNodeServer, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
4
|
-
import { devPlugin } from "./dev";
|
|
5
|
-
import { getDevAssetPrefix, getDevOptions } from "./helpers";
|
|
4
|
+
import { devPlugin } from "./dev.mjs";
|
|
5
|
+
import { getDevAssetPrefix, getDevOptions } from "./helpers/index.mjs";
|
|
6
6
|
async function createDevServer(options, applyPlugins) {
|
|
7
7
|
const { config, pwd, serverConfigPath, builder } = options;
|
|
8
8
|
const dev = getDevOptions(options.dev);
|
|
@@ -25,7 +25,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
25
25
|
const isHttp2 = !!devHttpsOption;
|
|
26
26
|
let nodeServer;
|
|
27
27
|
if (devHttpsOption) {
|
|
28
|
-
const { genHttpsOptions } = await import("./dev-tools/https");
|
|
28
|
+
const { genHttpsOptions } = await import("./dev-tools/https/index.mjs");
|
|
29
29
|
const httpsOptions = await genHttpsOptions(devHttpsOption, pwd);
|
|
30
30
|
nodeServer = await createNodeServer(server.handle.bind(server), httpsOptions, isHttp2);
|
|
31
31
|
} else nodeServer = await createNodeServer(server.handle.bind(server));
|
|
@@ -35,8 +35,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
35
35
|
compiler = context.compiler;
|
|
36
36
|
});
|
|
37
37
|
const builderDevServer = await builder?.createDevServer({
|
|
38
|
-
runCompile: options.runCompile
|
|
39
|
-
compiler: options.compiler
|
|
38
|
+
runCompile: options.runCompile
|
|
40
39
|
});
|
|
41
40
|
server.addPlugins([
|
|
42
41
|
devPlugin({
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import { chalk, getPackageManager, logger } from "@modern-js/utils";
|
|
1
|
+
import { chalk, getPackageManager, logger, tryResolve } from "@modern-js/utils";
|
|
2
2
|
const genHttpsOptions = async (userOptions, pwd)=>{
|
|
3
3
|
const httpsOptions = 'boolean' == typeof userOptions ? {} : userOptions;
|
|
4
4
|
if (!httpsOptions.key || !httpsOptions.cert) {
|
|
5
5
|
let devcertPath;
|
|
6
6
|
try {
|
|
7
|
-
devcertPath =
|
|
8
|
-
paths: [
|
|
9
|
-
pwd,
|
|
10
|
-
__dirname
|
|
11
|
-
]
|
|
12
|
-
});
|
|
7
|
+
devcertPath = tryResolve('devcert', pwd, __dirname);
|
|
13
8
|
} catch (err) {
|
|
14
9
|
const packageManager = await getPackageManager(pwd);
|
|
15
10
|
const command = chalk.yellow.bold(`${packageManager} add devcert@1.2.2 -D`);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { chokidar, fs } from "@modern-js/utils";
|
|
3
|
-
import { DependencyTree } from "./dependencyTree";
|
|
4
|
-
import { StatsCache } from "./statsCache";
|
|
3
|
+
import { DependencyTree } from "./dependencyTree.mjs";
|
|
4
|
+
import { StatsCache } from "./statsCache.mjs";
|
|
5
5
|
const defaultWatchOptions = {
|
|
6
6
|
ignoreInitial: true,
|
|
7
7
|
ignored: /api\/typings\/.*/
|
package/dist/esm/dev.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { connectMid2HonoMid } from "@modern-js/server-core/node";
|
|
2
2
|
import { API_DIR, SHARED_DIR } from "@modern-js/utils";
|
|
3
|
-
import { getDevOptions, getMockMiddleware, initFileReader, onRepack, startWatcher } from "./helpers";
|
|
3
|
+
import { getDevOptions, getMockMiddleware, initFileReader, onRepack, startWatcher } from "./helpers/index.mjs";
|
|
4
4
|
const devPlugin = (options, compiler)=>({
|
|
5
5
|
name: '@modern-js/plugin-dev',
|
|
6
6
|
setup (api) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
3
3
|
import { SERVER_BUNDLE_DIRECTORY, SERVER_DIR, logger } from "@modern-js/utils";
|
|
4
|
-
import dev_tools_watcher, { mergeWatchOptions } from "../dev-tools/watcher";
|
|
5
|
-
import { initOrUpdateMockMiddlewares } from "./mock";
|
|
6
|
-
import { debug } from "./utils";
|
|
7
|
-
export * from "./repack";
|
|
8
|
-
export * from "./devOptions";
|
|
9
|
-
export * from "./fileReader";
|
|
10
|
-
export * from "./mock";
|
|
4
|
+
import dev_tools_watcher, { mergeWatchOptions } from "../dev-tools/watcher/index.mjs";
|
|
5
|
+
import { initOrUpdateMockMiddlewares } from "./mock.mjs";
|
|
6
|
+
import { debug } from "./utils.mjs";
|
|
7
|
+
export * from "./repack.mjs";
|
|
8
|
+
export * from "./devOptions.mjs";
|
|
9
|
+
export * from "./fileReader.mjs";
|
|
10
|
+
export * from "./mock.mjs";
|
|
11
11
|
async function onServerChange({ pwd, filepath, event, server }) {
|
|
12
12
|
const { mock } = AGGRED_DIR;
|
|
13
13
|
const mockPath = path.normalize(path.join(pwd, mock));
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { createDevServer } from "./createDevServer";
|
|
1
|
+
import { createDevServer } from "./createDevServer.mjs";
|
|
2
2
|
export { createDevServer };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "node:module";
|
|
1
2
|
import node_path from "node:path";
|
|
2
3
|
import { createServerBase } from "@modern-js/server-core";
|
|
3
4
|
import { createNodeServer, loadServerRuntimeConfig } from "@modern-js/server-core/node";
|
|
@@ -35,8 +36,7 @@ async function createDevServer(options, applyPlugins) {
|
|
|
35
36
|
compiler = context.compiler;
|
|
36
37
|
});
|
|
37
38
|
const builderDevServer = await builder?.createDevServer({
|
|
38
|
-
runCompile: options.runCompile
|
|
39
|
-
compiler: options.compiler
|
|
39
|
+
runCompile: options.runCompile
|
|
40
40
|
});
|
|
41
41
|
server.addPlugins([
|
|
42
42
|
devPlugin({
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
3
|
+
import { fileURLToPath as __rspack_fileURLToPath } from "node:url";
|
|
4
|
+
import { dirname as __rspack_dirname } from "node:path";
|
|
5
|
+
import { chalk, getPackageManager, logger, tryResolve } from "@modern-js/utils";
|
|
6
|
+
var https_dirname = __rspack_dirname(__rspack_fileURLToPath(import.meta.url));
|
|
2
7
|
const genHttpsOptions = async (userOptions, pwd)=>{
|
|
3
8
|
const httpsOptions = 'boolean' == typeof userOptions ? {} : userOptions;
|
|
4
9
|
if (!httpsOptions.key || !httpsOptions.cert) {
|
|
5
10
|
let devcertPath;
|
|
6
11
|
try {
|
|
7
|
-
devcertPath =
|
|
8
|
-
paths: [
|
|
9
|
-
pwd,
|
|
10
|
-
__dirname
|
|
11
|
-
]
|
|
12
|
-
});
|
|
12
|
+
devcertPath = tryResolve('devcert', pwd, https_dirname);
|
|
13
13
|
} catch (err) {
|
|
14
14
|
const packageManager = await getPackageManager(pwd);
|
|
15
15
|
const command = chalk.yellow.bold(`${packageManager} add devcert@1.2.2 -D`);
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
1
3
|
import path from "path";
|
|
2
4
|
import { chokidar, fs } from "@modern-js/utils";
|
|
3
5
|
import { DependencyTree } from "./dependencyTree.mjs";
|
package/dist/esm-node/dev.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
1
3
|
import path from "path";
|
|
2
4
|
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
3
5
|
import { SERVER_BUNDLE_DIRECTORY, SERVER_DIR, logger } from "@modern-js/utils";
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import __rslib_shim_module__ from "node:module";
|
|
2
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(/*#__PURE__*/ (()=>import.meta.url)());
|
|
1
3
|
import { fileReader } from "@modern-js/runtime-utils/fileReader";
|
|
2
4
|
const cleanSSRCache = (distDir)=>{
|
|
3
5
|
Object.keys(require.cache).forEach((key)=>{
|
package/dist/esm-node/index.mjs
CHANGED
package/dist/esm-node/types.mjs
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "node:module";
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Server as NodeServer } from 'node:http';
|
|
2
2
|
import type { Http2SecureServer } from 'node:http2';
|
|
3
|
-
import type { BuilderInstance
|
|
3
|
+
import type { BuilderInstance } from '@modern-js/builder';
|
|
4
4
|
import type { DevServerHttpsOptions, ExposeServerApis, RequestHandler } from '@modern-js/types';
|
|
5
5
|
import type { ServerBase, ServerBaseOptions, ServerPlugin } from '@modern-js/server-core';
|
|
6
6
|
export type { DevServerHttpsOptions };
|
|
@@ -48,10 +48,6 @@ export type DevServerOptions = {
|
|
|
48
48
|
export type ExtraOptions = {
|
|
49
49
|
dev: DevServerOptions;
|
|
50
50
|
runCompile?: boolean;
|
|
51
|
-
/**
|
|
52
|
-
* The existing compiler can be used here.
|
|
53
|
-
*/
|
|
54
|
-
compiler?: Rspack.Compiler | Rspack.MultiCompiler;
|
|
55
51
|
serverConfigPath: string;
|
|
56
52
|
builder?: BuilderInstance;
|
|
57
53
|
plugins?: ServerPlugin[];
|
package/package.json
CHANGED
|
@@ -15,72 +15,54 @@
|
|
|
15
15
|
"modern",
|
|
16
16
|
"modern.js"
|
|
17
17
|
],
|
|
18
|
-
"version": "3.0.0
|
|
19
|
-
"jsnext:source": "./src/index.ts",
|
|
18
|
+
"version": "3.0.0",
|
|
20
19
|
"types": "./dist/types/index.d.ts",
|
|
21
20
|
"main": "./dist/cjs/index.js",
|
|
22
|
-
"module": "./dist/esm/index.mjs",
|
|
23
21
|
"exports": {
|
|
24
22
|
".": {
|
|
25
23
|
"types": "./dist/types/index.d.ts",
|
|
26
24
|
"modern:source": "./src/index.ts",
|
|
27
|
-
"jsnext:source": "./src/index.ts",
|
|
28
25
|
"node": {
|
|
29
26
|
"import": "./dist/esm-node/index.mjs",
|
|
30
27
|
"require": "./dist/cjs/index.js"
|
|
31
28
|
},
|
|
32
|
-
"default": "./dist/
|
|
33
|
-
},
|
|
34
|
-
"./hmr-client": {
|
|
35
|
-
"types": "./dist/types/dev-tools/dev-middleware/hmr-client/index.d.ts",
|
|
36
|
-
"jsnext:source": "./src/dev-tools/dev-middleware/hmr-client/index.ts",
|
|
37
|
-
"node": {
|
|
38
|
-
"require": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
|
|
39
|
-
},
|
|
40
|
-
"default": "./dist/cjs/dev-tools/dev-middleware/hmr-client/index.js"
|
|
29
|
+
"default": "./dist/cjs/index.js"
|
|
41
30
|
}
|
|
42
31
|
},
|
|
43
32
|
"typesVersions": {
|
|
44
33
|
"*": {
|
|
45
34
|
".": [
|
|
46
35
|
"./dist/types/index.d.ts"
|
|
47
|
-
],
|
|
48
|
-
"hmr-client": [
|
|
49
|
-
"./dist/types/dev-tools/dev-middleware/hmr-client/index.d.ts"
|
|
50
36
|
]
|
|
51
37
|
}
|
|
52
38
|
},
|
|
53
39
|
"dependencies": {
|
|
54
|
-
"@babel/core": "^7.28.5",
|
|
55
|
-
"@babel/register": "^7.28.3",
|
|
56
40
|
"@swc/helpers": "^0.5.17",
|
|
57
|
-
"axios": "^1.13.
|
|
41
|
+
"axios": "^1.13.4",
|
|
58
42
|
"connect-history-api-fallback": "^2.0.0",
|
|
59
43
|
"http-compression": "1.0.6",
|
|
60
44
|
"minimatch": "^3.1.2",
|
|
61
45
|
"path-to-regexp": "^6.3.0",
|
|
62
|
-
"ws": "^8.
|
|
63
|
-
"@modern-js/
|
|
64
|
-
"@modern-js/
|
|
65
|
-
"@modern-js/types": "3.0.0
|
|
66
|
-
"@modern-js/utils": "3.0.0
|
|
67
|
-
"@modern-js/server-utils": "3.0.0
|
|
46
|
+
"ws": "^8.19.0",
|
|
47
|
+
"@modern-js/server-core": "3.0.0",
|
|
48
|
+
"@modern-js/runtime-utils": "3.0.0",
|
|
49
|
+
"@modern-js/types": "3.0.0",
|
|
50
|
+
"@modern-js/utils": "3.0.0",
|
|
51
|
+
"@modern-js/server-utils": "3.0.0"
|
|
68
52
|
},
|
|
69
53
|
"devDependencies": {
|
|
70
|
-
"@rslib/core": "0.19.
|
|
54
|
+
"@rslib/core": "0.19.4",
|
|
71
55
|
"@types/connect-history-api-fallback": "^1.5.4",
|
|
72
|
-
"@types/jest": "^29.5.14",
|
|
73
56
|
"@types/minimatch": "^3.0.5",
|
|
74
57
|
"@types/node": "^20",
|
|
75
58
|
"@types/ws": "^8.18.1",
|
|
76
|
-
"jest": "^29.7.0",
|
|
77
59
|
"node-mocks-http": "^1.17.2",
|
|
78
60
|
"ts-node": "^10.9.2",
|
|
79
61
|
"tsconfig-paths": "4.2.0",
|
|
80
62
|
"typescript": "^5",
|
|
81
63
|
"websocket": "^1.0.35",
|
|
82
|
-
"@
|
|
83
|
-
"@
|
|
64
|
+
"@scripts/rstest-config": "2.66.0",
|
|
65
|
+
"@modern-js/builder": "3.0.0",
|
|
84
66
|
"@modern-js/rslib": "2.68.10"
|
|
85
67
|
},
|
|
86
68
|
"peerDependencies": {
|
|
@@ -107,6 +89,6 @@
|
|
|
107
89
|
"scripts": {
|
|
108
90
|
"build": "rslib build",
|
|
109
91
|
"dev": "rslib build --watch",
|
|
110
|
-
"test": "
|
|
92
|
+
"test": "rstest"
|
|
111
93
|
}
|
|
112
94
|
}
|