@modern-js/server-utils 1.0.0 → 1.1.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 +44 -0
- package/README.md +1 -4
- package/dist/js/modern/babel.js +5 -5
- package/dist/js/modern/gather.js +1 -1
- package/dist/js/modern/middleware.js +2 -9
- package/dist/js/node/babel.js +4 -4
- package/dist/js/node/gather.js +7 -5
- package/dist/js/node/middleware.js +2 -9
- package/dist/js/treeshaking/babel.js +5 -5
- package/dist/js/treeshaking/gather.js +1 -1
- package/dist/js/treeshaking/middleware.js +2 -9
- package/dist/types/middleware.d.ts +0 -2
- package/package.json +7 -7
- package/src/babel.ts +13 -11
- package/src/gather.ts +1 -1
- package/src/middleware.ts +0 -8
- package/tests/.eslintrc.js +6 -0
- package/tests/__snapshots__/babel.test.ts.snap +3 -1
- package/tests/babel.test.ts +6 -6
- package/tests/gather.test.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
1
|
# @modern-js/server-utils
|
|
2
2
|
|
|
3
|
+
## 1.1.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 085a6a58: refactor server plugin
|
|
8
|
+
- 085a6a58: refactor server plugin
|
|
9
|
+
- 085a6a58: refactor server conifg
|
|
10
|
+
- 085a6a58: support server runtime
|
|
11
|
+
- 085a6a58: feat: refactor server plugin
|
|
12
|
+
- Updated dependencies [085a6a58]
|
|
13
|
+
- Updated dependencies [085a6a58]
|
|
14
|
+
- Updated dependencies [085a6a58]
|
|
15
|
+
- Updated dependencies [d280ea33]
|
|
16
|
+
- Updated dependencies [085a6a58]
|
|
17
|
+
- Updated dependencies [085a6a58]
|
|
18
|
+
- @modern-js/utils@1.1.3
|
|
19
|
+
|
|
20
|
+
## 1.1.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- b011e0c5: fix(babel): declare
|
|
25
|
+
- 0fa83663: support more .env files
|
|
26
|
+
- Updated dependencies [b011e0c5]
|
|
27
|
+
- Updated dependencies [0fa83663]
|
|
28
|
+
- Updated dependencies [f594fbc8]
|
|
29
|
+
- Updated dependencies [395beb1e]
|
|
30
|
+
- @modern-js/babel-preset-lib@1.1.1
|
|
31
|
+
- @modern-js/plugin@1.1.2
|
|
32
|
+
- @modern-js/utils@1.1.2
|
|
33
|
+
|
|
34
|
+
## 1.1.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- 96119db2: Relese v1.1.0
|
|
39
|
+
|
|
40
|
+
### Patch Changes
|
|
41
|
+
|
|
42
|
+
- Updated dependencies [96119db2]
|
|
43
|
+
- @modern-js/babel-preset-lib@1.1.0
|
|
44
|
+
- @modern-js/plugin@1.1.0
|
|
45
|
+
- @modern-js/utils@1.1.0
|
|
46
|
+
|
|
3
47
|
## 1.0.0
|
|
4
48
|
|
|
5
49
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,10 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.
|
|
19
19
|
|
|
20
|
-
-
|
|
21
|
-
- [迈入现代 Web 开发](https://zhuanlan.zhihu.com/p/386607009)
|
|
22
|
-
- [现代 Web 开发者问卷调查报告](https://zhuanlan.zhihu.com/p/403206195)
|
|
23
|
-
- [字节跳动是如何落地微前端的](https://mp.weixin.qq.com/s/L9wbfNG5fTXF5bx7dcgj4Q)
|
|
20
|
+
- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)
|
|
24
21
|
|
|
25
22
|
## Getting Started
|
|
26
23
|
|
package/dist/js/modern/babel.js
CHANGED
|
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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
7
|
import { getBabelChain } from '@modern-js/babel-preset-lib';
|
|
8
|
-
import { applyOptionsChain, fs, getAlias
|
|
8
|
+
import { applyOptionsChain, fs, getAlias } from '@modern-js/utils';
|
|
9
9
|
import json5 from 'json5';
|
|
10
10
|
export * from '@babel/core';
|
|
11
11
|
export const readTsConfig = (tsconfigPath, noExistReturn = null) => {
|
|
@@ -65,14 +65,14 @@ export const resolveBabelConfig = (appDirectory, modernConfig, option // FIXME:
|
|
|
65
65
|
syntax: option.syntax
|
|
66
66
|
});
|
|
67
67
|
const envOptions = babelChain.preset('@babel/preset-env').options();
|
|
68
|
-
babelChain.preset('@babel/preset-env').use(
|
|
68
|
+
babelChain.preset('@babel/preset-env').use(require.resolve('@babel/preset-env'), [_objectSpread(_objectSpread({}, envOptions[0]), {}, {
|
|
69
69
|
loose: true
|
|
70
70
|
})]);
|
|
71
|
-
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(
|
|
72
|
-
babelChain.plugin('@babel/plugin-proposal-decorators').use(
|
|
71
|
+
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(require.resolve('babel-plugin-transform-typescript-metadata'), []);
|
|
72
|
+
babelChain.plugin('@babel/plugin-proposal-decorators').use(require.resolve('@babel/plugin-proposal-decorators'), [{
|
|
73
73
|
legacy: true
|
|
74
74
|
}]);
|
|
75
|
-
babelChain.plugin('@babel/plugin-proposal-class-properties').use(
|
|
75
|
+
babelChain.plugin('@babel/plugin-proposal-class-properties').use(require.resolve('@babel/plugin-proposal-class-properties'), [{
|
|
76
76
|
loose: true
|
|
77
77
|
}]);
|
|
78
78
|
|
package/dist/js/modern/gather.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export const createMiddlewareCollecter = () => {
|
|
2
2
|
const webMiddlewares = [];
|
|
3
3
|
const apiMiddlewares = [];
|
|
4
|
-
const ssrMiddlewares = [];
|
|
5
4
|
|
|
6
5
|
const addWebMiddleware = input => {
|
|
7
6
|
webMiddlewares.push(input);
|
|
@@ -11,21 +10,15 @@ export const createMiddlewareCollecter = () => {
|
|
|
11
10
|
apiMiddlewares.push(input);
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
const addSSRMiddleware = input => {
|
|
15
|
-
ssrMiddlewares.push(input);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
13
|
const getMiddlewares = () => ({
|
|
19
14
|
web: webMiddlewares,
|
|
20
|
-
api: apiMiddlewares
|
|
21
|
-
ssr: ssrMiddlewares
|
|
15
|
+
api: apiMiddlewares
|
|
22
16
|
});
|
|
23
17
|
|
|
24
18
|
return {
|
|
25
19
|
getMiddlewares,
|
|
26
20
|
addWebMiddleware,
|
|
27
|
-
addAPIMiddleware
|
|
28
|
-
addSSRMiddleware
|
|
21
|
+
addAPIMiddleware
|
|
29
22
|
};
|
|
30
23
|
};
|
|
31
24
|
export const hook = attacher => attacher;
|
package/dist/js/node/babel.js
CHANGED
|
@@ -106,14 +106,14 @@ const resolveBabelConfig = (appDirectory, modernConfig, option // FIXME: babel t
|
|
|
106
106
|
syntax: option.syntax
|
|
107
107
|
});
|
|
108
108
|
const envOptions = babelChain.preset('@babel/preset-env').options();
|
|
109
|
-
babelChain.preset('@babel/preset-env').use(
|
|
109
|
+
babelChain.preset('@babel/preset-env').use(require.resolve('@babel/preset-env'), [_objectSpread(_objectSpread({}, envOptions[0]), {}, {
|
|
110
110
|
loose: true
|
|
111
111
|
})]);
|
|
112
|
-
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(
|
|
113
|
-
babelChain.plugin('@babel/plugin-proposal-decorators').use(
|
|
112
|
+
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(require.resolve('babel-plugin-transform-typescript-metadata'), []);
|
|
113
|
+
babelChain.plugin('@babel/plugin-proposal-decorators').use(require.resolve('@babel/plugin-proposal-decorators'), [{
|
|
114
114
|
legacy: true
|
|
115
115
|
}]);
|
|
116
|
-
babelChain.plugin('@babel/plugin-proposal-class-properties').use(
|
|
116
|
+
babelChain.plugin('@babel/plugin-proposal-class-properties').use(require.resolve('@babel/plugin-proposal-class-properties'), [{
|
|
117
117
|
loose: true
|
|
118
118
|
}]);
|
|
119
119
|
|
package/dist/js/node/gather.js
CHANGED
|
@@ -5,12 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.gather = void 0;
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
9
|
|
|
10
10
|
var _middleware = require("./middleware");
|
|
11
11
|
|
|
12
12
|
var _requireModule = require("./requireModule");
|
|
13
13
|
|
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
+
|
|
14
16
|
const API_DIR_PATH = 'api';
|
|
15
17
|
const API_APP_NAME = '_app';
|
|
16
18
|
const SERVER_DIR_PATH = 'server';
|
|
@@ -23,13 +25,13 @@ const gather = pwd => {
|
|
|
23
25
|
addWebMiddleware
|
|
24
26
|
} = (0, _middleware.createMiddlewareCollecter)();
|
|
25
27
|
|
|
26
|
-
const apiPath =
|
|
28
|
+
const apiPath = _path.default.resolve(pwd, API_DIR_PATH);
|
|
27
29
|
|
|
28
|
-
const apiAppPath =
|
|
30
|
+
const apiAppPath = _path.default.resolve(apiPath, API_APP_NAME);
|
|
29
31
|
|
|
30
|
-
const serverPath =
|
|
32
|
+
const serverPath = _path.default.resolve(pwd, SERVER_DIR_PATH);
|
|
31
33
|
|
|
32
|
-
const webAppPath =
|
|
34
|
+
const webAppPath = _path.default.resolve(serverPath, WEB_APP_NAME);
|
|
33
35
|
|
|
34
36
|
const apiAttacher = (0, _requireModule.requireModule)(apiAppPath);
|
|
35
37
|
|
|
@@ -8,7 +8,6 @@ exports.hook = exports.createMiddlewareCollecter = void 0;
|
|
|
8
8
|
const createMiddlewareCollecter = () => {
|
|
9
9
|
const webMiddlewares = [];
|
|
10
10
|
const apiMiddlewares = [];
|
|
11
|
-
const ssrMiddlewares = [];
|
|
12
11
|
|
|
13
12
|
const addWebMiddleware = input => {
|
|
14
13
|
webMiddlewares.push(input);
|
|
@@ -18,21 +17,15 @@ const createMiddlewareCollecter = () => {
|
|
|
18
17
|
apiMiddlewares.push(input);
|
|
19
18
|
};
|
|
20
19
|
|
|
21
|
-
const addSSRMiddleware = input => {
|
|
22
|
-
ssrMiddlewares.push(input);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
20
|
const getMiddlewares = () => ({
|
|
26
21
|
web: webMiddlewares,
|
|
27
|
-
api: apiMiddlewares
|
|
28
|
-
ssr: ssrMiddlewares
|
|
22
|
+
api: apiMiddlewares
|
|
29
23
|
});
|
|
30
24
|
|
|
31
25
|
return {
|
|
32
26
|
getMiddlewares,
|
|
33
27
|
addWebMiddleware,
|
|
34
|
-
addAPIMiddleware
|
|
35
|
-
addSSRMiddleware
|
|
28
|
+
addAPIMiddleware
|
|
36
29
|
};
|
|
37
30
|
};
|
|
38
31
|
|
|
@@ -5,7 +5,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
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
7
|
import { getBabelChain } from '@modern-js/babel-preset-lib';
|
|
8
|
-
import { applyOptionsChain, fs, getAlias
|
|
8
|
+
import { applyOptionsChain, fs, getAlias } from '@modern-js/utils';
|
|
9
9
|
import json5 from 'json5';
|
|
10
10
|
export * from '@babel/core';
|
|
11
11
|
export var readTsConfig = function readTsConfig(tsconfigPath) {
|
|
@@ -61,14 +61,14 @@ export var resolveBabelConfig = function resolveBabelConfig(appDirectory, modern
|
|
|
61
61
|
syntax: option.syntax
|
|
62
62
|
});
|
|
63
63
|
var envOptions = babelChain.preset('@babel/preset-env').options();
|
|
64
|
-
babelChain.preset('@babel/preset-env').use(
|
|
64
|
+
babelChain.preset('@babel/preset-env').use(require.resolve('@babel/preset-env'), [_objectSpread(_objectSpread({}, envOptions[0]), {}, {
|
|
65
65
|
loose: true
|
|
66
66
|
})]);
|
|
67
|
-
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(
|
|
68
|
-
babelChain.plugin('@babel/plugin-proposal-decorators').use(
|
|
67
|
+
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(require.resolve('babel-plugin-transform-typescript-metadata'), []);
|
|
68
|
+
babelChain.plugin('@babel/plugin-proposal-decorators').use(require.resolve('@babel/plugin-proposal-decorators'), [{
|
|
69
69
|
legacy: true
|
|
70
70
|
}]);
|
|
71
|
-
babelChain.plugin('@babel/plugin-proposal-class-properties').use(
|
|
71
|
+
babelChain.plugin('@babel/plugin-proposal-class-properties').use(require.resolve('@babel/plugin-proposal-class-properties'), [{
|
|
72
72
|
loose: true
|
|
73
73
|
}]);
|
|
74
74
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export var createMiddlewareCollecter = function createMiddlewareCollecter() {
|
|
2
2
|
var webMiddlewares = [];
|
|
3
3
|
var apiMiddlewares = [];
|
|
4
|
-
var ssrMiddlewares = [];
|
|
5
4
|
|
|
6
5
|
var addWebMiddleware = function addWebMiddleware(input) {
|
|
7
6
|
webMiddlewares.push(input);
|
|
@@ -11,23 +10,17 @@ export var createMiddlewareCollecter = function createMiddlewareCollecter() {
|
|
|
11
10
|
apiMiddlewares.push(input);
|
|
12
11
|
};
|
|
13
12
|
|
|
14
|
-
var addSSRMiddleware = function addSSRMiddleware(input) {
|
|
15
|
-
ssrMiddlewares.push(input);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
13
|
var getMiddlewares = function getMiddlewares() {
|
|
19
14
|
return {
|
|
20
15
|
web: webMiddlewares,
|
|
21
|
-
api: apiMiddlewares
|
|
22
|
-
ssr: ssrMiddlewares
|
|
16
|
+
api: apiMiddlewares
|
|
23
17
|
};
|
|
24
18
|
};
|
|
25
19
|
|
|
26
20
|
return {
|
|
27
21
|
getMiddlewares: getMiddlewares,
|
|
28
22
|
addWebMiddleware: addWebMiddleware,
|
|
29
|
-
addAPIMiddleware: addAPIMiddleware
|
|
30
|
-
addSSRMiddleware: addSSRMiddleware
|
|
23
|
+
addAPIMiddleware: addAPIMiddleware
|
|
31
24
|
};
|
|
32
25
|
};
|
|
33
26
|
export var hook = function hook(attacher) {
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export declare type CollectMiddlewaresResult = {
|
|
2
2
|
web: any[];
|
|
3
3
|
api: any[];
|
|
4
|
-
ssr: any[];
|
|
5
4
|
};
|
|
6
5
|
export declare const createMiddlewareCollecter: () => {
|
|
7
6
|
getMiddlewares: () => CollectMiddlewaresResult;
|
|
8
7
|
addWebMiddleware: (input: any) => void;
|
|
9
8
|
addAPIMiddleware: (input: any) => void;
|
|
10
|
-
addSSRMiddleware: (input: any) => void;
|
|
11
9
|
};
|
|
12
10
|
export declare type AttacherOptions = {
|
|
13
11
|
addMiddleware: (...input: any[]) => void;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"modern",
|
|
12
12
|
"modern.js"
|
|
13
13
|
],
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.1.2",
|
|
15
15
|
"jsnext:source": "./src/index.ts",
|
|
16
16
|
"types": "./dist/types/index.d.ts",
|
|
17
17
|
"main": "./dist/js/node/index.js",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"@babel/preset-env": "^7.15.0",
|
|
35
35
|
"@babel/preset-typescript": "^7.15.0",
|
|
36
36
|
"@babel/runtime": "^7",
|
|
37
|
-
"@modern-js/babel-preset-lib": "^1.
|
|
38
|
-
"@modern-js/plugin": "^1.
|
|
39
|
-
"@modern-js/utils": "^1.
|
|
37
|
+
"@modern-js/babel-preset-lib": "^1.1.1",
|
|
38
|
+
"@modern-js/plugin": "^1.1.2",
|
|
39
|
+
"@modern-js/utils": "^1.1.3",
|
|
40
40
|
"babel-plugin-module-resolver": "^4.1.0",
|
|
41
41
|
"babel-plugin-transform-typescript-metadata": "^0.3.2",
|
|
42
42
|
"json5": "^2.2.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@modern-js/core": "^1.
|
|
45
|
+
"@modern-js/core": "^1.1.3",
|
|
46
46
|
"@types/babel__core": "^7.1.15",
|
|
47
47
|
"@types/jest": "^26",
|
|
48
48
|
"@types/node": "^14",
|
|
@@ -50,8 +50,8 @@
|
|
|
50
50
|
"@types/react-dom": "^17",
|
|
51
51
|
"ts-jest": "^27.0.4",
|
|
52
52
|
"typescript": "^4",
|
|
53
|
-
"@modern-js/plugin-testing": "^1.
|
|
54
|
-
"@modern-js/module-tools": "^1.
|
|
53
|
+
"@modern-js/plugin-testing": "^1.1.1",
|
|
54
|
+
"@modern-js/module-tools": "^1.1.1"
|
|
55
55
|
},
|
|
56
56
|
"sideEffects": false,
|
|
57
57
|
"publishConfig": {
|
package/src/babel.ts
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
ISyntaxOption,
|
|
5
5
|
} from '@modern-js/babel-preset-lib';
|
|
6
6
|
import { TransformOptions } from '@babel/core';
|
|
7
|
-
import { applyOptionsChain, fs, getAlias
|
|
7
|
+
import { applyOptionsChain, fs, getAlias } from '@modern-js/utils';
|
|
8
8
|
import type { NormalizedConfig } from '@modern-js/core';
|
|
9
9
|
import json5 from 'json5';
|
|
10
10
|
|
|
@@ -112,28 +112,30 @@ export const resolveBabelConfig = (
|
|
|
112
112
|
const envOptions = babelChain.preset('@babel/preset-env').options();
|
|
113
113
|
babelChain
|
|
114
114
|
.preset('@babel/preset-env')
|
|
115
|
-
.use(
|
|
115
|
+
.use(require.resolve('@babel/preset-env'), [
|
|
116
116
|
{
|
|
117
117
|
...envOptions[0],
|
|
118
118
|
loose: true,
|
|
119
119
|
},
|
|
120
120
|
]);
|
|
121
121
|
|
|
122
|
-
babelChain
|
|
123
|
-
.
|
|
124
|
-
|
|
122
|
+
babelChain.plugin('babel-plugin-transform-typescript-metadata').use(
|
|
123
|
+
require.resolve('babel-plugin-transform-typescript-metadata'),
|
|
124
|
+
|
|
125
|
+
[],
|
|
126
|
+
);
|
|
125
127
|
|
|
126
128
|
babelChain
|
|
127
129
|
.plugin('@babel/plugin-proposal-decorators')
|
|
128
|
-
.use(
|
|
130
|
+
.use(require.resolve('@babel/plugin-proposal-decorators'), [
|
|
129
131
|
{ legacy: true },
|
|
130
132
|
]);
|
|
131
133
|
|
|
132
|
-
babelChain
|
|
133
|
-
.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
babelChain.plugin('@babel/plugin-proposal-class-properties').use(
|
|
135
|
+
require.resolve('@babel/plugin-proposal-class-properties'),
|
|
136
|
+
|
|
137
|
+
[{ loose: true }],
|
|
138
|
+
);
|
|
137
139
|
|
|
138
140
|
const internalBabelConfig = { ...babelChain.toJSON() };
|
|
139
141
|
|
package/src/gather.ts
CHANGED
package/src/middleware.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
export type CollectMiddlewaresResult = {
|
|
2
2
|
web: any[];
|
|
3
3
|
api: any[];
|
|
4
|
-
ssr: any[];
|
|
5
4
|
};
|
|
6
5
|
|
|
7
6
|
export const createMiddlewareCollecter = () => {
|
|
8
7
|
const webMiddlewares: any[] = [];
|
|
9
8
|
const apiMiddlewares: any[] = [];
|
|
10
|
-
const ssrMiddlewares: any[] = [];
|
|
11
9
|
|
|
12
10
|
const addWebMiddleware = (input: any) => {
|
|
13
11
|
webMiddlewares.push(input);
|
|
@@ -17,20 +15,14 @@ export const createMiddlewareCollecter = () => {
|
|
|
17
15
|
apiMiddlewares.push(input);
|
|
18
16
|
};
|
|
19
17
|
|
|
20
|
-
const addSSRMiddleware = (input: any) => {
|
|
21
|
-
ssrMiddlewares.push(input);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
18
|
const getMiddlewares = (): CollectMiddlewaresResult => ({
|
|
25
19
|
web: webMiddlewares,
|
|
26
20
|
api: apiMiddlewares,
|
|
27
|
-
ssr: ssrMiddlewares,
|
|
28
21
|
});
|
|
29
22
|
return {
|
|
30
23
|
getMiddlewares,
|
|
31
24
|
addWebMiddleware,
|
|
32
25
|
addAPIMiddleware,
|
|
33
|
-
addSSRMiddleware,
|
|
34
26
|
};
|
|
35
27
|
};
|
|
36
28
|
|
|
@@ -66,7 +66,7 @@ Object {
|
|
|
66
66
|
"helpers": false,
|
|
67
67
|
"regenerator": true,
|
|
68
68
|
"useESModules": false,
|
|
69
|
-
"version": "7.
|
|
69
|
+
"version": "7.16.3",
|
|
70
70
|
},
|
|
71
71
|
],
|
|
72
72
|
Array [
|
|
@@ -163,8 +163,10 @@ Object {
|
|
|
163
163
|
Array [
|
|
164
164
|
"/@babel/preset-typescript/lib/index.js",
|
|
165
165
|
Object {
|
|
166
|
+
"allExtensions": true,
|
|
166
167
|
"allowDeclareFields": true,
|
|
167
168
|
"allowNamespaces": true,
|
|
169
|
+
"isTSX": true,
|
|
168
170
|
},
|
|
169
171
|
],
|
|
170
172
|
],
|
package/tests/babel.test.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import path from 'path';
|
|
2
2
|
import { defaults } from './helpers';
|
|
3
3
|
import { resolveBabelConfig } from '@/index';
|
|
4
4
|
|
|
@@ -20,7 +20,7 @@ describe('babel', () => {
|
|
|
20
20
|
expect.addSnapshotSerializer({
|
|
21
21
|
test: val =>
|
|
22
22
|
typeof val === 'string' &&
|
|
23
|
-
(val.includes('modern
|
|
23
|
+
(val.includes('modern.js') ||
|
|
24
24
|
val.includes('node_modules') ||
|
|
25
25
|
val.includes(root)),
|
|
26
26
|
print: val =>
|
|
@@ -28,10 +28,10 @@ describe('babel', () => {
|
|
|
28
28
|
typeof val === 'string'
|
|
29
29
|
? // eslint-disable-next-line no-nested-ternary
|
|
30
30
|
val.includes('node_modules')
|
|
31
|
-
? `"${val.replace(/.+node_modules/, '')}"`
|
|
32
|
-
: val.includes('modern
|
|
33
|
-
? `"${val.replace(/.+modern
|
|
34
|
-
: `"${val.replace(root, '')}"`
|
|
31
|
+
? `"${val.replace(/.+node_modules/, '').replace(/\\/g, '/')}"`
|
|
32
|
+
: val.includes('modern.js')
|
|
33
|
+
? `"${val.replace(/.+modern\.js/, '').replace(/\\/g, '/')}"`
|
|
34
|
+
: `"${val.replace(root, '').replace(/\\/g, '/')}"`
|
|
35
35
|
: (val as string),
|
|
36
36
|
});
|
|
37
37
|
|
package/tests/gather.test.ts
CHANGED