@modern-js/server-core 1.3.6-beta.0 → 1.4.1-beta.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/CHANGELOG.md +15 -0
- package/dist/js/modern/loadPlugins.js +1 -21
- package/dist/js/modern/plugin.js +3 -3
- package/dist/js/node/loadPlugins.js +1 -20
- package/dist/js/node/plugin.js +3 -4
- package/dist/types/plugin.d.ts +11 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @modern-js/server-plugin
|
|
2
2
|
|
|
3
|
+
## 1.4.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 77a8e9e: feat: support bff operators
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- f29e9ba: feat: simplify context usage, no longer depend on containers
|
|
12
|
+
- a90bc96: perf(babel): skip babel-plugin-import if package not installed
|
|
13
|
+
- Updated dependencies [f29e9ba]
|
|
14
|
+
- Updated dependencies [a90bc96]
|
|
15
|
+
- @modern-js/plugin@1.4.0
|
|
16
|
+
- @modern-js/utils@1.7.9
|
|
17
|
+
|
|
3
18
|
## 1.3.5
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -4,28 +4,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
4
4
|
|
|
5
5
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
6
6
|
|
|
7
|
-
import { compatRequire } from '@modern-js/utils';
|
|
7
|
+
import { compatRequire, tryResolve } from '@modern-js/utils';
|
|
8
8
|
import { createPlugin } from "./plugin";
|
|
9
|
-
|
|
10
|
-
const tryResolve = (name, appDirectory) => {
|
|
11
|
-
let filePath = '';
|
|
12
|
-
|
|
13
|
-
try {
|
|
14
|
-
filePath = require.resolve(name, {
|
|
15
|
-
paths: [appDirectory]
|
|
16
|
-
});
|
|
17
|
-
delete require.cache[filePath];
|
|
18
|
-
} catch (err) {
|
|
19
|
-
if (err.code === 'MODULE_NOT_FOUND') {
|
|
20
|
-
throw new Error(`Can not find plugin ${name}.`);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return filePath;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
9
|
export const loadPlugins = (plugins, appDirectory) => {
|
|
30
10
|
const resolvePlugin = p => {
|
|
31
11
|
const isPluginInstance = typeof p !== 'string' && !Array.isArray(p);
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { createContext, createAsyncManager, createAsyncPipeline, createAsyncWaterfall, createParallelWorkflow, createWaterfall } from '@modern-js/plugin';
|
|
2
|
-
|
|
3
|
-
enable(); // collect all middleware register in server plugins
|
|
4
|
-
|
|
2
|
+
// collect all middleware register in server plugins
|
|
5
3
|
const gather = createParallelWorkflow();
|
|
6
4
|
// config
|
|
7
5
|
const config = createWaterfall();
|
|
@@ -9,6 +7,7 @@ const prepare = createWaterfall();
|
|
|
9
7
|
const create = createAsyncPipeline();
|
|
10
8
|
const prepareWebServer = createAsyncPipeline();
|
|
11
9
|
const prepareApiServer = createAsyncPipeline();
|
|
10
|
+
const onApiChange = createAsyncPipeline();
|
|
12
11
|
const beforeDevServer = createParallelWorkflow();
|
|
13
12
|
const setupCompiler = createParallelWorkflow();
|
|
14
13
|
const afterDevServer = createParallelWorkflow(); // TODO FIXME
|
|
@@ -60,6 +59,7 @@ const serverHooks = {
|
|
|
60
59
|
create,
|
|
61
60
|
prepareWebServer,
|
|
62
61
|
prepareApiServer,
|
|
62
|
+
onApiChange,
|
|
63
63
|
beforeDevServer,
|
|
64
64
|
setupCompiler,
|
|
65
65
|
afterDevServer,
|
|
@@ -15,25 +15,6 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
15
15
|
|
|
16
16
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
|
|
18
|
-
const tryResolve = (name, appDirectory) => {
|
|
19
|
-
let filePath = '';
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
filePath = require.resolve(name, {
|
|
23
|
-
paths: [appDirectory]
|
|
24
|
-
});
|
|
25
|
-
delete require.cache[filePath];
|
|
26
|
-
} catch (err) {
|
|
27
|
-
if (err.code === 'MODULE_NOT_FOUND') {
|
|
28
|
-
throw new Error(`Can not find plugin ${name}.`);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
throw err;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return filePath;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
18
|
const loadPlugins = (plugins, appDirectory) => {
|
|
38
19
|
const resolvePlugin = p => {
|
|
39
20
|
const isPluginInstance = typeof p !== 'string' && !Array.isArray(p);
|
|
@@ -45,7 +26,7 @@ const loadPlugins = (plugins, appDirectory) => {
|
|
|
45
26
|
}
|
|
46
27
|
|
|
47
28
|
const [pkg, options] = typeof p === 'string' ? [p, undefined] : p;
|
|
48
|
-
const pluginPath = tryResolve(pkg, appDirectory);
|
|
29
|
+
const pluginPath = (0, _utils.tryResolve)(pkg, appDirectory);
|
|
49
30
|
let module = (0, _utils.compatRequire)(pluginPath);
|
|
50
31
|
const useNewSyntax = typeof module === 'function';
|
|
51
32
|
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -7,10 +7,7 @@ exports.useConfigContext = exports.useAppContext = exports.setAppContext = expor
|
|
|
7
7
|
|
|
8
8
|
var _plugin = require("@modern-js/plugin");
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
(0, _node.enable)(); // collect all middleware register in server plugins
|
|
13
|
-
|
|
10
|
+
// collect all middleware register in server plugins
|
|
14
11
|
const gather = (0, _plugin.createParallelWorkflow)();
|
|
15
12
|
// config
|
|
16
13
|
const config = (0, _plugin.createWaterfall)();
|
|
@@ -18,6 +15,7 @@ const prepare = (0, _plugin.createWaterfall)();
|
|
|
18
15
|
const create = (0, _plugin.createAsyncPipeline)();
|
|
19
16
|
const prepareWebServer = (0, _plugin.createAsyncPipeline)();
|
|
20
17
|
const prepareApiServer = (0, _plugin.createAsyncPipeline)();
|
|
18
|
+
const onApiChange = (0, _plugin.createAsyncPipeline)();
|
|
21
19
|
const beforeDevServer = (0, _plugin.createParallelWorkflow)();
|
|
22
20
|
const setupCompiler = (0, _plugin.createParallelWorkflow)();
|
|
23
21
|
const afterDevServer = (0, _plugin.createParallelWorkflow)(); // TODO FIXME
|
|
@@ -80,6 +78,7 @@ const serverHooks = {
|
|
|
80
78
|
create,
|
|
81
79
|
prepareWebServer,
|
|
82
80
|
prepareApiServer,
|
|
81
|
+
onApiChange,
|
|
83
82
|
beforeDevServer,
|
|
84
83
|
setupCompiler,
|
|
85
84
|
afterDevServer,
|
package/dist/types/plugin.d.ts
CHANGED
|
@@ -27,6 +27,10 @@ export declare type APIServerStartInput = {
|
|
|
27
27
|
middleware?: Array<any>;
|
|
28
28
|
};
|
|
29
29
|
};
|
|
30
|
+
declare type Change = {
|
|
31
|
+
filename: string;
|
|
32
|
+
event: 'add' | 'change' | 'unlink';
|
|
33
|
+
};
|
|
30
34
|
export declare type Route = Record<string, unknown>;
|
|
31
35
|
export declare type RequestResult = {
|
|
32
36
|
isfinish: boolean;
|
|
@@ -61,6 +65,7 @@ declare const serverHooks: {
|
|
|
61
65
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
62
66
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
63
67
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
68
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
64
69
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
65
70
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
66
71
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -125,6 +130,7 @@ export declare const createServerManager: () => import("@modern-js/plugin").Asyn
|
|
|
125
130
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
126
131
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
127
132
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
133
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
128
134
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
129
135
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
130
136
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -184,6 +190,7 @@ export declare const serverManager: import("@modern-js/plugin").AsyncManager<{
|
|
|
184
190
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
185
191
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
186
192
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
193
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
187
194
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
188
195
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
189
196
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -252,6 +259,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
252
259
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
253
260
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
254
261
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
262
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
255
263
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
256
264
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
257
265
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -310,6 +318,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
310
318
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
311
319
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
312
320
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
321
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
313
322
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
314
323
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
315
324
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -364,6 +373,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
364
373
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
365
374
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
366
375
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
376
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
367
377
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
368
378
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
369
379
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
@@ -422,6 +432,7 @@ export declare const createPlugin: (setup?: AsyncSetup<{
|
|
|
422
432
|
create: import("@modern-js/plugin").AsyncPipeline<ServerInitInput, InitExtension>;
|
|
423
433
|
prepareWebServer: import("@modern-js/plugin").AsyncPipeline<WebServerStartInput, Adapter>;
|
|
424
434
|
prepareApiServer: import("@modern-js/plugin").AsyncPipeline<APIServerStartInput, Adapter>;
|
|
435
|
+
onApiChange: import("@modern-js/plugin").AsyncPipeline<Change[], boolean>;
|
|
425
436
|
beforeDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
|
426
437
|
setupCompiler: import("@modern-js/plugin").ParallelWorkflow<Record<string, unknown>, any[]>;
|
|
427
438
|
afterDevServer: import("@modern-js/plugin").ParallelWorkflow<NormalizedConfig, any>;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.4.1-beta.0",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@modern-js/plugin": "^1.
|
|
32
|
-
"@modern-js/utils": "^1.7.
|
|
31
|
+
"@modern-js/plugin": "^1.4.2",
|
|
32
|
+
"@modern-js/utils": "^1.7.12"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@modern-js/core": "1.
|
|
36
|
-
"@modern-js/types": "1.5.
|
|
35
|
+
"@modern-js/core": "1.12.4",
|
|
36
|
+
"@modern-js/types": "1.5.6",
|
|
37
37
|
"@scripts/build": "0.0.0",
|
|
38
38
|
"@scripts/jest-config": "0.0.0",
|
|
39
39
|
"@types/jest": "^27",
|