@modern-js/server-core 2.0.0-beta.1 → 2.0.0-beta.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,38 @@
1
1
  # @modern-js/server-plugin
2
2
 
3
+ ## 2.0.0-beta.2
4
+
5
+ ### Major Changes
6
+
7
+ - dda38c9c3e: chore: v2
8
+
9
+ ### Minor Changes
10
+
11
+ - 543be9558e: feat: compile server loader and support handle loader request
12
+ feat: 编译 server loader 并支持处理 loader 的请求
13
+
14
+ ### Patch Changes
15
+
16
+ - 15bf09d9c8: feat: support completely custom server, export render() api for render single page
17
+ feat: 支持完全自定义 Server,导出 render() 方法用来渲染单个页面
18
+ - cc971eabfc: refactor: move server plugin load logic in `@modern-js/core`
19
+ refactor:移除在 `@modern-js/core` 中的 server 插件加载逻辑
20
+ - Updated dependencies [92f0ead]
21
+ - Updated dependencies [edd1cfb1af]
22
+ - Updated dependencies [cc971eabfc]
23
+ - Updated dependencies [5b9049f2e9]
24
+ - Updated dependencies [92004d1]
25
+ - Updated dependencies [b8bbe036c7]
26
+ - Updated dependencies [d5a31df781]
27
+ - Updated dependencies [dda38c9c3e]
28
+ - Updated dependencies [3bbea92b2a]
29
+ - Updated dependencies [f179749]
30
+ - Updated dependencies [abf3421a75]
31
+ - Updated dependencies [543be9558e]
32
+ - Updated dependencies [14b712da84]
33
+ - @modern-js/utils@2.0.0-beta.2
34
+ - @modern-js/plugin@2.0.0-beta.2
35
+
3
36
  ## 2.0.0-beta.1
4
37
 
5
38
  ### Major Changes
@@ -1,3 +1,4 @@
1
1
  export * from "./plugin";
2
2
  export * from '@modern-js/plugin';
3
- export * from "./loadPlugins";
3
+ export * from "./loadPlugins";
4
+ export * from "./types/config";
File without changes
File without changes
@@ -0,0 +1,7 @@
1
+ export * from "./bff";
2
+ export * from "./html";
3
+ export * from "./output";
4
+ export * from "./server";
5
+ export * from "./source";
6
+ export * from "./tools";
7
+ export {};
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -35,4 +35,15 @@ Object.keys(_loadPlugins).forEach(function (key) {
35
35
  return _loadPlugins[key];
36
36
  }
37
37
  });
38
+ });
39
+ var _config = require("./types/config");
40
+ Object.keys(_config).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _config[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _config[key];
47
+ }
48
+ });
38
49
  });
File without changes
File without changes
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _bff = require("./bff");
7
+ Object.keys(_bff).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _bff[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _bff[key];
14
+ }
15
+ });
16
+ });
17
+ var _html = require("./html");
18
+ Object.keys(_html).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _html[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _html[key];
25
+ }
26
+ });
27
+ });
28
+ var _output = require("./output");
29
+ Object.keys(_output).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _output[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _output[key];
36
+ }
37
+ });
38
+ });
39
+ var _server = require("./server");
40
+ Object.keys(_server).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _server[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _server[key];
47
+ }
48
+ });
49
+ });
50
+ var _source = require("./source");
51
+ Object.keys(_source).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _source[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _source[key];
58
+ }
59
+ });
60
+ });
61
+ var _tools = require("./tools");
62
+ Object.keys(_tools).forEach(function (key) {
63
+ if (key === "default" || key === "__esModule") return;
64
+ if (key in exports && exports[key] === _tools[key]) return;
65
+ Object.defineProperty(exports, key, {
66
+ enumerable: true,
67
+ get: function () {
68
+ return _tools[key];
69
+ }
70
+ });
71
+ });
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,3 +1,4 @@
1
1
  export * from './plugin';
2
2
  export * from '@modern-js/plugin';
3
- export * from './loadPlugins';
3
+ export * from './loadPlugins';
4
+ export * from './types/config';
@@ -19,13 +19,13 @@ export declare const loadPlugins: (appDirectory: string, configPlugins: ServerPl
19
19
  filename: string;
20
20
  event: "add" | "unlink" | "change";
21
21
  }[]>;
22
- beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
22
+ beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
23
23
  setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
24
- afterDevServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
24
+ afterDevServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
25
25
  beforeRouteSet: import("@modern-js/plugin").AsyncPipeline<import("./plugin").Route[], import("./plugin").Route[]>;
26
26
  afterRouteSet: import("@modern-js/plugin").AsyncPipeline<unknown, unknown>;
27
- beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
28
- afterProdServer: import("@modern-js/plugin").ParallelWorkflow<import("./plugin").ServerOptions, any>;
27
+ beforeProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
28
+ afterProdServer: import("@modern-js/plugin").ParallelWorkflow<import(".").ServerOptions, any>;
29
29
  listen: import("@modern-js/plugin").ParallelWorkflow<{
30
30
  ip: string;
31
31
  port: number;
@@ -59,6 +59,6 @@ export declare const loadPlugins: (appDirectory: string, configPlugins: ServerPl
59
59
  reset: import("@modern-js/plugin").ParallelWorkflow<void, unknown>;
60
60
  }, {
61
61
  useAppContext: () => import("@modern-js/types").ISAppContext;
62
- useConfigContext: () => import("@modern-js/core").UserConfig;
62
+ useConfigContext: () => import(".").UserConfig;
63
63
  setAppContext: (value: import("@modern-js/types").ISAppContext) => void;
64
64
  }>[];
@@ -3,20 +3,8 @@ import { IncomingMessage, ServerResponse } from 'http';
3
3
  import type { Component } from 'react';
4
4
  import { CommonAPI, ToThreads, AsyncSetup, PluginOptions } from '@modern-js/plugin';
5
5
  import type { ModernServerContext, BaseSSRServerContext, AfterMatchContext, AfterRenderContext, MiddlewareContext, ISAppContext, ServerRoute } from '@modern-js/types';
6
- import type { NormalizedConfig, UserConfig } from '@modern-js/core';
7
6
  import type { Options } from 'http-proxy-middleware';
8
- /** The subset of NormalizedConfig, which really need in server */
9
- export declare type ServerOptions = {
10
- output: Pick<NormalizedConfig['output'], 'path' | 'assetPrefix'>;
11
- source: Pick<NormalizedConfig['source'], 'alias' | 'envVars' | 'globalVars'>;
12
- tools: {
13
- babel: NormalizedConfig['tools']['babel'];
14
- };
15
- server: NormalizedConfig['server'];
16
- runtime: NormalizedConfig['runtime'];
17
- bff: NormalizedConfig['bff'];
18
- plugins: NormalizedConfig['plugins'];
19
- };
7
+ import type { ServerOptions, UserConfig } from './types/config';
20
8
  export declare type WebAdapter = (ctx: MiddlewareContext) => void | Promise<void>;
21
9
  export declare type Adapter = (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;
22
10
  export declare type WebServerStartInput = {
@@ -402,7 +390,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
402
390
  useAppContext: () => ISAppContext;
403
391
  useConfigContext: () => UserConfig;
404
392
  setAppContext: (value: ISAppContext) => void;
405
- }>, Record<string, unknown>> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
393
+ }>, Record<string, unknown>, any, any> | undefined) => import("@modern-js/plugin").AsyncPlugin<{
406
394
  gather: import("@modern-js/plugin").ParallelWorkflow<{
407
395
  addWebMiddleware: (_input: any) => void;
408
396
  addAPIMiddleware: (_input: any) => void;
@@ -0,0 +1,5 @@
1
+ export interface BffUserConfig {
2
+ prefix?: string;
3
+ proxy?: Record<string, string>;
4
+ }
5
+ export declare type BffNormalizedConfig = BffUserConfig;
@@ -0,0 +1,5 @@
1
+ export interface HtmlUserConfig {
2
+ favicon?: string;
3
+ faviconByEntries?: Record<string, string | undefined>;
4
+ }
5
+ export declare type HtmlNormalizedConfig = HtmlUserConfig;
@@ -0,0 +1,34 @@
1
+ import { BffNormalizedConfig, BffUserConfig } from './bff';
2
+ import { HtmlNormalizedConfig, HtmlUserConfig } from './html';
3
+ import { OutputNormalizedConfig, OutputUserConfig } from './output';
4
+ import { ServerNormalizedConfig, ServerUserConfig } from './server';
5
+ import { SourceNormalizedConfig, SourceUserConfig } from './source';
6
+ import { ToolsNormalizedConfig, ToolsUserConfig } from './tools';
7
+ export * from './bff';
8
+ export * from './html';
9
+ export * from './output';
10
+ export * from './server';
11
+ export * from './source';
12
+ export * from './tools';
13
+ interface RuntimeUserConfig {
14
+ [property: string]: any;
15
+ }
16
+ declare type RuntimeNormalizedConfig = RuntimeUserConfig;
17
+ export interface UserConfig {
18
+ output?: OutputUserConfig;
19
+ source?: SourceUserConfig;
20
+ tools?: ToolsUserConfig;
21
+ server?: ServerUserConfig;
22
+ runtime?: RuntimeUserConfig;
23
+ html?: HtmlUserConfig;
24
+ bff?: BffUserConfig;
25
+ }
26
+ export declare type ServerOptions = {
27
+ output: OutputNormalizedConfig;
28
+ source: SourceNormalizedConfig;
29
+ tools: ToolsNormalizedConfig;
30
+ server: ServerNormalizedConfig;
31
+ runtime: RuntimeNormalizedConfig;
32
+ html: HtmlNormalizedConfig;
33
+ bff: BffNormalizedConfig;
34
+ };
@@ -0,0 +1,17 @@
1
+ export interface OutputUserConfig {
2
+ distPath?: {
3
+ root?: string;
4
+ js?: string;
5
+ css?: string;
6
+ svg?: string;
7
+ font?: string;
8
+ html?: string;
9
+ image?: string;
10
+ media?: string;
11
+ server?: string;
12
+ };
13
+ path?: string;
14
+ assetPrefix?: string;
15
+ polyfill?: 'entry' | 'usage' | 'ua' | 'off';
16
+ }
17
+ export declare type OutputNormalizedConfig = OutputUserConfig;
@@ -0,0 +1,27 @@
1
+ import type { WatchOptions } from '@modern-js/utils';
2
+ declare type Route = string | string[] | {
3
+ route?: string | string[];
4
+ disableSpa?: boolean;
5
+ resHeaders?: Record<string, unknown>;
6
+ };
7
+ export declare type Routes = Record<string, Route>;
8
+ export declare type SSR = boolean | {
9
+ mode?: 'string' | 'stream';
10
+ };
11
+ export declare type SSRByEntries = Record<string, SSR>;
12
+ export interface ServerUserConfig {
13
+ routes?: Routes;
14
+ publicRoutes?: Record<string, string>;
15
+ ssr?: SSR;
16
+ ssrByEntries?: SSRByEntries;
17
+ baseUrl?: string | string[];
18
+ port?: number;
19
+ logger?: boolean | Record<string, any>;
20
+ metrics?: boolean | Record<string, any>;
21
+ enableMicroFrontendDebug?: boolean;
22
+ watchOptions?: WatchOptions;
23
+ compiler?: 'babel' | 'typescript';
24
+ disableFrameworkExt?: boolean;
25
+ }
26
+ export declare type ServerNormalizedConfig = ServerUserConfig;
27
+ export {};
@@ -0,0 +1,3 @@
1
+ declare type ArrayOrNot<T> = T | T[];
2
+ export declare type ChainedConfig<Config, Utils = unknown> = ArrayOrNot<Config | (keyof Utils extends never ? (config: Config) => Config | void : (config: Config, utils: Utils) => Config | void)>;
3
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { Alias } from '@modern-js/utils';
2
+ import type { ChainedConfig } from './share';
3
+ declare type JSONPrimitive = string | number | boolean | null;
4
+ declare type JSONArray = Array<JSONValue>;
5
+ declare type JSONObject = {
6
+ [key: string]: JSONValue;
7
+ };
8
+ declare type JSONValue = JSONPrimitive | JSONObject | JSONArray;
9
+ export interface SourceUserConfig {
10
+ alias?: ChainedConfig<Alias>;
11
+ define?: Record<string, any>;
12
+ globalVars?: Record<string, JSONValue>;
13
+ }
14
+ export declare type SourceNormalizedConfig = SourceUserConfig;
15
+ export {};
@@ -0,0 +1,9 @@
1
+ import { BabelConfigUtils } from '@modern-js/babel-preset-app';
2
+ import { BabelTransformOptions } from '@modern-js/types/common';
3
+ import { ChainedConfig } from './share';
4
+ declare type ToolsBabelConfig = ChainedConfig<BabelTransformOptions, BabelConfigUtils>;
5
+ export interface ToolsUserConfig {
6
+ babel?: ToolsBabelConfig;
7
+ }
8
+ export declare type ToolsNormalizedConfig = ToolsUserConfig;
9
+ export {};
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "2.0.0-beta.1",
14
+ "version": "2.0.0-beta.2",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/types/index.d.ts",
17
17
  "main": "./dist/js/node/index.js",
@@ -29,8 +29,8 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@modern-js/plugin": "2.0.0-beta.1",
33
- "@modern-js/utils": "2.0.0-beta.1"
32
+ "@modern-js/plugin": "2.0.0-beta.2",
33
+ "@modern-js/utils": "2.0.0-beta.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/jest": "^27",
@@ -39,10 +39,10 @@
39
39
  "jest": "^27",
40
40
  "ts-jest": "^27.0.4",
41
41
  "typescript": "^4",
42
- "@modern-js/core": "2.0.0-beta.1",
43
- "@modern-js/types": "2.0.0-beta.1",
44
- "@scripts/build": "2.0.0-beta.1",
45
- "@scripts/jest-config": "2.0.0-beta.1"
42
+ "@modern-js/types": "2.0.0-beta.2",
43
+ "@modern-js/babel-preset-app": "2.0.0-beta.2",
44
+ "@scripts/build": "2.0.0-beta.2",
45
+ "@scripts/jest-config": "2.0.0-beta.2"
46
46
  },
47
47
  "sideEffects": false,
48
48
  "modernConfig": {
@@ -55,9 +55,9 @@
55
55
  "access": "public"
56
56
  },
57
57
  "scripts": {
58
- "new": "modern new",
59
- "dev": "modern build --watch",
60
- "build": "modern build",
58
+ "new": "modern-lib new",
59
+ "dev": "modern-lib build --watch",
60
+ "build": "modern-lib build",
61
61
  "test": "jest --passWithNoTests"
62
62
  }
63
63
  }