@modern-js/plugin-express 1.0.1 → 1.1.3
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 +55 -9
- package/dist/js/modern/cli/index.js +9 -2
- package/dist/js/modern/plugin.js +2 -1
- package/dist/js/node/cli/index.js +9 -2
- package/dist/js/node/plugin.js +2 -1
- package/dist/types/cli/index.d.ts +3 -0
- package/package.json +14 -14
- package/src/cli/index.ts +14 -2
- package/src/plugin.ts +2 -1
- package/tests/lambdaMode.test.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,17 +1,63 @@
|
|
|
1
1
|
# @modern-js/plugin-express
|
|
2
2
|
|
|
3
|
-
## 1.
|
|
3
|
+
## 1.1.3
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
- Updated dependencies [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
7
|
+
- 39e8137d: fix: support prefix array & webpack loader should read requestCreator & adjust runtime path to relative
|
|
8
|
+
- Updated dependencies [085a6a58]
|
|
9
|
+
- Updated dependencies [085a6a58]
|
|
10
|
+
- Updated dependencies [085a6a58]
|
|
11
|
+
- Updated dependencies [d280ea33]
|
|
12
|
+
- Updated dependencies [d4fcc73a]
|
|
13
|
+
- Updated dependencies [085a6a58]
|
|
14
|
+
- Updated dependencies [ed1f6b12]
|
|
15
|
+
- Updated dependencies [a5ebbb00]
|
|
16
|
+
- Updated dependencies [085a6a58]
|
|
17
|
+
- @modern-js/core@1.1.3
|
|
18
|
+
- @modern-js/server-plugin@1.1.2
|
|
19
|
+
- @modern-js/utils@1.1.3
|
|
20
|
+
|
|
21
|
+
## 1.1.2
|
|
22
|
+
|
|
23
|
+
### Patch Changes
|
|
24
|
+
|
|
25
|
+
- 0fa83663: support more .env files
|
|
26
|
+
- Updated dependencies [6f7fe574]
|
|
27
|
+
- Updated dependencies [0fa83663]
|
|
28
|
+
- Updated dependencies [f594fbc8]
|
|
29
|
+
- @modern-js/core@1.1.2
|
|
30
|
+
- @modern-js/adapter-helpers@1.1.1
|
|
31
|
+
- @modern-js/bff-runtime@1.1.1
|
|
32
|
+
- @modern-js/bff-utils@1.1.1
|
|
33
|
+
- @modern-js/server-plugin@1.1.1
|
|
34
|
+
- @modern-js/utils@1.1.2
|
|
35
|
+
|
|
36
|
+
## 1.1.1
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- 6ffd1a50: Refactor to base on farrow-pipeline
|
|
41
|
+
- Updated dependencies [687c92c7]
|
|
42
|
+
- Updated dependencies [c0fc0700]
|
|
43
|
+
- @modern-js/core@1.1.1
|
|
44
|
+
- @modern-js/utils@1.1.1
|
|
45
|
+
|
|
46
|
+
## 1.1.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- 96119db2: Relese v1.1.0
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Updated dependencies [96119db2]
|
|
55
|
+
- @modern-js/core@1.1.0
|
|
56
|
+
- @modern-js/adapter-helpers@1.1.0
|
|
57
|
+
- @modern-js/bff-runtime@1.1.0
|
|
58
|
+
- @modern-js/bff-utils@1.1.0
|
|
59
|
+
- @modern-js/server-plugin@1.1.0
|
|
60
|
+
- @modern-js/utils@1.1.0
|
|
15
61
|
|
|
16
62
|
## 1.0.0
|
|
17
63
|
|
|
@@ -8,17 +8,23 @@ export default createPlugin(() => {
|
|
|
8
8
|
config() {
|
|
9
9
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
10
10
|
const appContext = useAppContext();
|
|
11
|
+
const {
|
|
12
|
+
appDirectory
|
|
13
|
+
} = appContext;
|
|
11
14
|
bffExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'server');
|
|
15
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
16
|
+
|
|
17
|
+
const relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
12
18
|
return {
|
|
13
19
|
source: {
|
|
14
20
|
alias: {
|
|
15
|
-
'@modern-js/runtime/server':
|
|
21
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
};
|
|
19
25
|
},
|
|
20
26
|
|
|
21
|
-
modifyEntryImports() {
|
|
27
|
+
modifyEntryImports(input) {
|
|
22
28
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
23
29
|
const {
|
|
24
30
|
appDirectory
|
|
@@ -42,6 +48,7 @@ export default createPlugin(() => {
|
|
|
42
48
|
...pluginRuntime
|
|
43
49
|
}
|
|
44
50
|
`);
|
|
51
|
+
return input;
|
|
45
52
|
}
|
|
46
53
|
|
|
47
54
|
};
|
package/dist/js/modern/plugin.js
CHANGED
|
@@ -11,7 +11,7 @@ const debug = createDebugger('express');
|
|
|
11
11
|
|
|
12
12
|
const findAppModule = async apiDir => {
|
|
13
13
|
const exts = ['.ts', '.js'];
|
|
14
|
-
const paths = exts.map(ext => path.
|
|
14
|
+
const paths = exts.map(ext => path.resolve(apiDir, `app${ext}`));
|
|
15
15
|
|
|
16
16
|
for (const filename of paths) {
|
|
17
17
|
if (await fs.pathExists(filename)) {
|
|
@@ -62,6 +62,7 @@ export default createPlugin(() => ({
|
|
|
62
62
|
app = await findAppModule(apiDir);
|
|
63
63
|
|
|
64
64
|
if (!app || !app.use) {
|
|
65
|
+
console.warn('There is not api/app.ts.');
|
|
65
66
|
app = express();
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -22,17 +22,23 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
22
22
|
config() {
|
|
23
23
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
24
24
|
const appContext = (0, _core.useAppContext)();
|
|
25
|
+
const {
|
|
26
|
+
appDirectory
|
|
27
|
+
} = appContext;
|
|
25
28
|
bffExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'server');
|
|
29
|
+
const serverRuntimePath = bffExportsUtils.getPath(); // Look up one level, because the artifacts after build have dist directories
|
|
30
|
+
|
|
31
|
+
const relativeRuntimePath = path.join('../', path.relative(appDirectory, serverRuntimePath));
|
|
26
32
|
return {
|
|
27
33
|
source: {
|
|
28
34
|
alias: {
|
|
29
|
-
'@modern-js/runtime/server':
|
|
35
|
+
'@modern-js/runtime/server': relativeRuntimePath
|
|
30
36
|
}
|
|
31
37
|
}
|
|
32
38
|
};
|
|
33
39
|
},
|
|
34
40
|
|
|
35
|
-
modifyEntryImports() {
|
|
41
|
+
modifyEntryImports(input) {
|
|
36
42
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
37
43
|
const {
|
|
38
44
|
appDirectory
|
|
@@ -56,6 +62,7 @@ var _default = (0, _core.createPlugin)(() => {
|
|
|
56
62
|
...pluginRuntime
|
|
57
63
|
}
|
|
58
64
|
`);
|
|
65
|
+
return input;
|
|
59
66
|
}
|
|
60
67
|
|
|
61
68
|
};
|
package/dist/js/node/plugin.js
CHANGED
|
@@ -33,7 +33,7 @@ const debug = (0, _utils.createDebugger)('express');
|
|
|
33
33
|
|
|
34
34
|
const findAppModule = async apiDir => {
|
|
35
35
|
const exts = ['.ts', '.js'];
|
|
36
|
-
const paths = exts.map(ext => path.
|
|
36
|
+
const paths = exts.map(ext => path.resolve(apiDir, `app${ext}`));
|
|
37
37
|
|
|
38
38
|
for (const filename of paths) {
|
|
39
39
|
if (await _utils.fs.pathExists(filename)) {
|
|
@@ -84,6 +84,7 @@ var _default = (0, _serverPlugin.createPlugin)(() => ({
|
|
|
84
84
|
app = await findAppModule(apiDir);
|
|
85
85
|
|
|
86
86
|
if (!app || !app.use) {
|
|
87
|
+
console.warn('There is not api/app.ts.');
|
|
87
88
|
app = (0, _express.default)();
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
declare const _default: import("@modern-js/core").AsyncPlugin<Partial<import("@modern-js/core").Progresses2Threads<{
|
|
2
2
|
config: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
3
|
+
resolvedConfig: import("@modern-js/core").AsyncWaterfall<{
|
|
4
|
+
resolved: import("@modern-js/core").NormalizedConfig;
|
|
5
|
+
}>;
|
|
3
6
|
validateSchema: import("@modern-js/core").ParallelWorkflow<void, unknown>;
|
|
4
7
|
prepare: import("@modern-js/core").AsyncWorkflow<void, void>;
|
|
5
8
|
commands: import("@modern-js/core").AsyncWorkflow<{
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.1.3",
|
|
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
|
"dependencies": {
|
|
31
31
|
"@babel/runtime": "^7.15.3",
|
|
32
|
-
"@modern-js/adapter-helpers": "^1.
|
|
33
|
-
"@modern-js/utils": "^1.
|
|
32
|
+
"@modern-js/adapter-helpers": "^1.1.1",
|
|
33
|
+
"@modern-js/utils": "^1.1.3",
|
|
34
34
|
"cookie-parser": "^1.4.5",
|
|
35
35
|
"finalhandler": "^1.1.2",
|
|
36
36
|
"formidable": "^1.2.2",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"express": "^4.17.1",
|
|
41
|
-
"@modern-js/server-utils": "^1.
|
|
42
|
-
"@modern-js/bff-runtime": "^1.
|
|
41
|
+
"@modern-js/server-utils": "^1.1.2",
|
|
42
|
+
"@modern-js/bff-runtime": "^1.1.1",
|
|
43
43
|
"@types/cookie-parser": "^1.4.2",
|
|
44
44
|
"@types/express": "^4.17.13",
|
|
45
45
|
"@types/finalhandler": "^1.1.1",
|
|
@@ -50,11 +50,11 @@
|
|
|
50
50
|
"@types/type-is": "^1.6.3",
|
|
51
51
|
"supertest": "^6.1.6",
|
|
52
52
|
"typescript": "^4",
|
|
53
|
-
"@modern-js/bff-utils": "^1.
|
|
54
|
-
"@modern-js/core": "^1.
|
|
55
|
-
"@modern-js/server-plugin": "^1.
|
|
56
|
-
"@modern-js/plugin-testing": "^1.
|
|
57
|
-
"@modern-js/module-tools": "^1.
|
|
53
|
+
"@modern-js/bff-utils": "^1.1.1",
|
|
54
|
+
"@modern-js/core": "^1.1.3",
|
|
55
|
+
"@modern-js/server-plugin": "^1.1.2",
|
|
56
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
|
57
|
+
"@modern-js/module-tools": "^1.1.1"
|
|
58
58
|
},
|
|
59
59
|
"modernConfig": {
|
|
60
60
|
"output": {
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
|
-
"@modern-js/bff-utils": "^1.
|
|
66
|
-
"@modern-js/core": "^1.
|
|
67
|
-
"@modern-js/server-plugin": "^1.
|
|
68
|
-
"@modern-js/bff-runtime": "^1.
|
|
65
|
+
"@modern-js/bff-utils": "^1.1.1",
|
|
66
|
+
"@modern-js/core": "^1.1.3",
|
|
67
|
+
"@modern-js/server-plugin": "^1.1.2",
|
|
68
|
+
"@modern-js/bff-runtime": "^1.1.1",
|
|
69
69
|
"express": "^4.17.1"
|
|
70
70
|
},
|
|
71
71
|
"publishConfig": {
|
package/src/cli/index.ts
CHANGED
|
@@ -11,18 +11,29 @@ export default createPlugin(
|
|
|
11
11
|
config() {
|
|
12
12
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
13
13
|
const appContext = useAppContext();
|
|
14
|
+
const { appDirectory } = appContext;
|
|
14
15
|
bffExportsUtils = createRuntimeExportsUtils(
|
|
15
16
|
appContext.internalDirectory,
|
|
16
17
|
'server',
|
|
17
18
|
);
|
|
18
19
|
|
|
20
|
+
const serverRuntimePath = bffExportsUtils.getPath();
|
|
21
|
+
|
|
22
|
+
// Look up one level, because the artifacts after build have dist directories
|
|
23
|
+
const relativeRuntimePath = path.join(
|
|
24
|
+
'../',
|
|
25
|
+
path.relative(appDirectory, serverRuntimePath),
|
|
26
|
+
);
|
|
27
|
+
|
|
19
28
|
return {
|
|
20
29
|
source: {
|
|
21
|
-
alias: {
|
|
30
|
+
alias: {
|
|
31
|
+
'@modern-js/runtime/server': relativeRuntimePath,
|
|
32
|
+
},
|
|
22
33
|
},
|
|
23
34
|
};
|
|
24
35
|
},
|
|
25
|
-
modifyEntryImports() {
|
|
36
|
+
modifyEntryImports(input) {
|
|
26
37
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
27
38
|
const { appDirectory } = useAppContext();
|
|
28
39
|
const runtimePath = require.resolve(`@modern-js/runtime`, {
|
|
@@ -56,6 +67,7 @@ export default createPlugin(
|
|
|
56
67
|
...pluginRuntime
|
|
57
68
|
}
|
|
58
69
|
`);
|
|
70
|
+
return input;
|
|
59
71
|
},
|
|
60
72
|
};
|
|
61
73
|
},
|
package/src/plugin.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type Mode = 'function' | 'framework';
|
|
|
19
19
|
|
|
20
20
|
const findAppModule = async (apiDir: string) => {
|
|
21
21
|
const exts = ['.ts', '.js'];
|
|
22
|
-
const paths = exts.map(ext => path.
|
|
22
|
+
const paths = exts.map(ext => path.resolve(apiDir, `app${ext}`));
|
|
23
23
|
|
|
24
24
|
for (const filename of paths) {
|
|
25
25
|
if (await fs.pathExists(filename)) {
|
|
@@ -67,6 +67,7 @@ export default createPlugin(
|
|
|
67
67
|
app = await findAppModule(apiDir);
|
|
68
68
|
|
|
69
69
|
if (!app || !app.use) {
|
|
70
|
+
console.warn('There is not api/app.ts.');
|
|
70
71
|
app = express();
|
|
71
72
|
}
|
|
72
73
|
initApp(app);
|