@modern-js/plugin-testing 1.4.1 → 1.5.1
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/.eslintrc.js +4 -2
- package/CHANGELOG.md +78 -0
- package/dist/js/modern/cli/index.js +9 -8
- package/dist/js/node/cli/index.js +7 -6
- package/dist/js/treeshaking/cli/index.js +16 -15
- package/package.json +27 -35
- package/{type.d.ts → types/index.d.ts} +2 -2
- package/dist/js/modern/cli/resolver.js +0 -15
- package/dist/js/node/cli/resolver.js +0 -20
- package/dist/js/treeshaking/cli/resolver.js +0 -17
- package/dist/types/cli/resolver.d.ts +0 -1
- package/tests/.eslintrc.js +0 -6
- package/tests/index.test.ts +0 -7
- package/tests/merge-config.test.ts +0 -54
- package/tests/resolver.test.ts +0 -30
- package/tests/tsconfig.json +0 -13
package/.eslintrc.js
CHANGED
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,83 @@
|
|
1
1
|
# @modern-js/plugin-testing
|
2
2
|
|
3
|
+
## 1.5.1
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- 6c1438d2: fix: missing peer deps warnings
|
8
|
+
- 77519490: refactor(webpack): remove `@modern-js/core`
|
9
|
+
- 50f351b2: fix:
|
10
|
+
|
11
|
+
1. plugin-testing types
|
12
|
+
2. `tools.jest` not working when combined with bff testing
|
13
|
+
|
14
|
+
- Updated dependencies [2d155c4c]
|
15
|
+
- Updated dependencies [a0475f1a]
|
16
|
+
- Updated dependencies [123e432d]
|
17
|
+
- Updated dependencies [6c1438d2]
|
18
|
+
- Updated dependencies [e5a9b26d]
|
19
|
+
- Updated dependencies [0b26b93b]
|
20
|
+
- Updated dependencies [123e432d]
|
21
|
+
- Updated dependencies [f9f66ef9]
|
22
|
+
- Updated dependencies [71526621]
|
23
|
+
- Updated dependencies [77519490]
|
24
|
+
- Updated dependencies [592edabc]
|
25
|
+
- Updated dependencies [3578716a]
|
26
|
+
- Updated dependencies [895fa0ff]
|
27
|
+
- Updated dependencies [3d1fac2a]
|
28
|
+
- Updated dependencies [3578913e]
|
29
|
+
- Updated dependencies [50f351b2]
|
30
|
+
- Updated dependencies [1c3beab3]
|
31
|
+
- @modern-js/utils@1.6.0
|
32
|
+
- @modern-js/webpack@1.5.7
|
33
|
+
- @modern-js/testing@1.4.4
|
34
|
+
- @modern-js/bff-utils@1.2.4
|
35
|
+
- @modern-js/testing-plugin-bff@1.4.1
|
36
|
+
- @modern-js/runtime-core@1.4.3
|
37
|
+
|
38
|
+
## 1.5.0
|
39
|
+
|
40
|
+
### Minor Changes
|
41
|
+
|
42
|
+
- 3bf4f8b0: feat: support start api server only
|
43
|
+
|
44
|
+
### Patch Changes
|
45
|
+
|
46
|
+
- 04ae5262: chore: bump @modern-js/utils to v1.4.1 in dependencies
|
47
|
+
- 60f7d8bf: feat: add tests dir to npmignore
|
48
|
+
- Updated dependencies [b8599d09]
|
49
|
+
- Updated dependencies [6cffe99d]
|
50
|
+
- Updated dependencies [04ae5262]
|
51
|
+
- Updated dependencies [60f7d8bf]
|
52
|
+
- Updated dependencies [e4cec1ce]
|
53
|
+
- Updated dependencies [3bf4f8b0]
|
54
|
+
- @modern-js/utils@1.5.0
|
55
|
+
- @modern-js/webpack@1.5.5
|
56
|
+
- @modern-js/testing@1.4.3
|
57
|
+
- @modern-js/testing-plugin-bff@1.4.0
|
58
|
+
- @modern-js/runtime-core@1.4.2
|
59
|
+
- @modern-js/babel-compiler@1.2.3
|
60
|
+
|
61
|
+
## 1.4.2
|
62
|
+
|
63
|
+
### Patch Changes
|
64
|
+
|
65
|
+
- 77043407: feat: add default enhanced resolver
|
66
|
+
- Updated dependencies [485375ae]
|
67
|
+
- Updated dependencies [ec1b7367]
|
68
|
+
- Updated dependencies [77ff9754]
|
69
|
+
- Updated dependencies [d2d1d6b2]
|
70
|
+
- Updated dependencies [07a4887e]
|
71
|
+
- Updated dependencies [ea2ae711]
|
72
|
+
- Updated dependencies [77043407]
|
73
|
+
- Updated dependencies [17d0cc46]
|
74
|
+
- Updated dependencies [d2d1d6b2]
|
75
|
+
- @modern-js/runtime-core@1.4.1
|
76
|
+
- @modern-js/webpack@1.5.4
|
77
|
+
- @modern-js/utils@1.4.0
|
78
|
+
- @modern-js/testing@1.4.2
|
79
|
+
- @modern-js/testing-plugin-bff@1.3.1
|
80
|
+
|
3
81
|
## 1.4.1
|
4
82
|
|
5
83
|
### Patch Changes
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import path from 'path';
|
2
|
-
import {
|
3
|
-
import { jestConfigHook, getModuleNameMapper } from '@modern-js/testing';
|
2
|
+
import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
|
3
|
+
import { jestConfigHook, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
|
4
4
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
5
5
|
import TestingBffPlugin from '@modern-js/testing-plugin-bff';
|
6
6
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
@@ -27,8 +27,6 @@ export default (() => {
|
|
27
27
|
},
|
28
28
|
setup: api => {
|
29
29
|
let testingExportsUtils;
|
30
|
-
const appContext = api.useAppContext();
|
31
|
-
const userConfig = api.useResolvedConfigContext();
|
32
30
|
return {
|
33
31
|
commands: ({
|
34
32
|
program
|
@@ -43,6 +41,7 @@ export default (() => {
|
|
43
41
|
},
|
44
42
|
|
45
43
|
config() {
|
44
|
+
const appContext = api.useAppContext();
|
46
45
|
testingExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'testing');
|
47
46
|
return {
|
48
47
|
source: {
|
@@ -59,13 +58,15 @@ export default (() => {
|
|
59
58
|
},
|
60
59
|
|
61
60
|
jestConfig: async (utils, next) => {
|
62
|
-
const
|
61
|
+
const appContext = api.useAppContext();
|
62
|
+
const userConfig = api.useResolvedConfigContext();
|
63
|
+
const apiOnly = await isApiOnly(appContext.appDirectory);
|
63
64
|
|
64
|
-
if (
|
65
|
+
if (apiOnly) {
|
65
66
|
return next(utils);
|
66
67
|
}
|
67
68
|
|
68
|
-
const webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT);
|
69
|
+
const webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, userConfig);
|
69
70
|
const {
|
70
71
|
resolve: {
|
71
72
|
alias = {}
|
@@ -77,7 +78,7 @@ export default (() => {
|
|
77
78
|
},
|
78
79
|
moduleNameMapper: getModuleNameMapper(alias),
|
79
80
|
testEnvironment: 'jsdom',
|
80
|
-
resolver:
|
81
|
+
resolver: DEFAULT_RESOLVER_PATH
|
81
82
|
});
|
82
83
|
utils.setJestConfig({
|
83
84
|
rootDir: appContext.appDirectory || process.cwd(),
|
@@ -46,8 +46,6 @@ var _default = () => {
|
|
46
46
|
},
|
47
47
|
setup: api => {
|
48
48
|
let testingExportsUtils;
|
49
|
-
const appContext = api.useAppContext();
|
50
|
-
const userConfig = api.useResolvedConfigContext();
|
51
49
|
return {
|
52
50
|
commands: ({
|
53
51
|
program
|
@@ -62,6 +60,7 @@ var _default = () => {
|
|
62
60
|
},
|
63
61
|
|
64
62
|
config() {
|
63
|
+
const appContext = api.useAppContext();
|
65
64
|
testingExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, 'testing');
|
66
65
|
return {
|
67
66
|
source: {
|
@@ -79,13 +78,15 @@ var _default = () => {
|
|
79
78
|
},
|
80
79
|
|
81
80
|
jestConfig: async (utils, next) => {
|
82
|
-
const
|
81
|
+
const appContext = api.useAppContext();
|
82
|
+
const userConfig = api.useResolvedConfigContext();
|
83
|
+
const apiOnly = await (0, _utils.isApiOnly)(appContext.appDirectory);
|
83
84
|
|
84
|
-
if (
|
85
|
+
if (apiOnly) {
|
85
86
|
return next(utils);
|
86
87
|
}
|
87
88
|
|
88
|
-
const webpackConfig = (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.CLIENT);
|
89
|
+
const webpackConfig = (0, _webpack.getWebpackConfig)(_webpack.WebpackConfigTarget.CLIENT, appContext, userConfig);
|
89
90
|
const {
|
90
91
|
resolve: {
|
91
92
|
alias = {}
|
@@ -97,7 +98,7 @@ var _default = () => {
|
|
97
98
|
},
|
98
99
|
moduleNameMapper: (0, _testing.getModuleNameMapper)(alias),
|
99
100
|
testEnvironment: 'jsdom',
|
100
|
-
resolver:
|
101
|
+
resolver: _testing.DEFAULT_RESOLVER_PATH
|
101
102
|
});
|
102
103
|
utils.setJestConfig({
|
103
104
|
rootDir: appContext.appDirectory || process.cwd(),
|
@@ -7,8 +7,8 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
|
|
7
7
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
8
8
|
|
9
9
|
import path from 'path';
|
10
|
-
import {
|
11
|
-
import { jestConfigHook, getModuleNameMapper } from '@modern-js/testing';
|
10
|
+
import { PLUGIN_SCHEMAS, createRuntimeExportsUtils, isApiOnly } from '@modern-js/utils';
|
11
|
+
import { jestConfigHook, getModuleNameMapper, DEFAULT_RESOLVER_PATH } from '@modern-js/testing';
|
12
12
|
import { getWebpackConfig, WebpackConfigTarget } from '@modern-js/webpack';
|
13
13
|
import TestingBffPlugin from '@modern-js/testing-plugin-bff';
|
14
14
|
import { MODERNJS_CONFIG_KEY } from "../constant";
|
@@ -35,8 +35,6 @@ export default (function () {
|
|
35
35
|
},
|
36
36
|
setup: function setup(api) {
|
37
37
|
var testingExportsUtils;
|
38
|
-
var appContext = api.useAppContext();
|
39
|
-
var userConfig = api.useResolvedConfigContext();
|
40
38
|
return {
|
41
39
|
commands: function commands(_ref) {
|
42
40
|
var program = _ref.program;
|
@@ -60,6 +58,7 @@ export default (function () {
|
|
60
58
|
return PLUGIN_SCHEMAS['@modern-js/plugin-testing'];
|
61
59
|
},
|
62
60
|
config: function config() {
|
61
|
+
var appContext = api.useAppContext();
|
63
62
|
testingExportsUtils = createRuntimeExportsUtils(appContext.internalDirectory, 'testing');
|
64
63
|
return {
|
65
64
|
source: {
|
@@ -75,33 +74,35 @@ export default (function () {
|
|
75
74
|
},
|
76
75
|
jestConfig: function () {
|
77
76
|
var _jestConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(utils, next) {
|
78
|
-
var
|
77
|
+
var appContext, userConfig, apiOnly, webpackConfig, _webpackConfig$resolv, alias;
|
79
78
|
|
80
79
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
81
80
|
while (1) {
|
82
81
|
switch (_context2.prev = _context2.next) {
|
83
82
|
case 0:
|
84
|
-
|
85
|
-
|
83
|
+
appContext = api.useAppContext();
|
84
|
+
userConfig = api.useResolvedConfigContext();
|
85
|
+
_context2.next = 4;
|
86
|
+
return isApiOnly(appContext.appDirectory);
|
86
87
|
|
87
|
-
case
|
88
|
-
|
88
|
+
case 4:
|
89
|
+
apiOnly = _context2.sent;
|
89
90
|
|
90
|
-
if (
|
91
|
-
_context2.next =
|
91
|
+
if (!apiOnly) {
|
92
|
+
_context2.next = 7;
|
92
93
|
break;
|
93
94
|
}
|
94
95
|
|
95
96
|
return _context2.abrupt("return", next(utils));
|
96
97
|
|
97
|
-
case
|
98
|
-
webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT);
|
98
|
+
case 7:
|
99
|
+
webpackConfig = getWebpackConfig(WebpackConfigTarget.CLIENT, appContext, userConfig);
|
99
100
|
_webpackConfig$resolv = webpackConfig.resolve.alias, alias = _webpackConfig$resolv === void 0 ? {} : _webpackConfig$resolv;
|
100
101
|
utils.mergeJestConfig({
|
101
102
|
globals: _defineProperty({}, MODERNJS_CONFIG_KEY, userConfig),
|
102
103
|
moduleNameMapper: getModuleNameMapper(alias),
|
103
104
|
testEnvironment: 'jsdom',
|
104
|
-
resolver:
|
105
|
+
resolver: DEFAULT_RESOLVER_PATH
|
105
106
|
});
|
106
107
|
utils.setJestConfig({
|
107
108
|
rootDir: appContext.appDirectory || process.cwd(),
|
@@ -113,7 +114,7 @@ export default (function () {
|
|
113
114
|
mergeUserJestConfig(utils);
|
114
115
|
return _context2.abrupt("return", next(utils));
|
115
116
|
|
116
|
-
case
|
117
|
+
case 13:
|
117
118
|
case "end":
|
118
119
|
return _context2.stop();
|
119
120
|
}
|
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.
|
14
|
+
"version": "1.5.1",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -19,19 +19,18 @@
|
|
19
19
|
"jsnext:modern": "./dist/js/modern/index.js",
|
20
20
|
"exports": {
|
21
21
|
"./types": {
|
22
|
-
"jsnext:source": "./
|
23
|
-
"default": "./
|
22
|
+
"jsnext:source": "./types/index.d.ts",
|
23
|
+
"default": "./types/index.d.ts"
|
24
24
|
},
|
25
25
|
"./type": {
|
26
|
-
"jsnext:source": "./
|
27
|
-
"default": "./
|
26
|
+
"jsnext:source": "./types/index.d.ts",
|
27
|
+
"default": "./types/index.d.ts"
|
28
28
|
},
|
29
29
|
".": {
|
30
30
|
"node": {
|
31
31
|
"jsnext:source": "./src/runtime-testing/index.ts",
|
32
32
|
"import": "./dist/js/modern/runtime-testing/index.js",
|
33
|
-
"require": "./dist/js/node/runtime-testing/index.js"
|
34
|
-
"types": "./types/index.d.ts"
|
33
|
+
"require": "./dist/js/node/runtime-testing/index.js"
|
35
34
|
},
|
36
35
|
"default": "./dist/js/treeshaking/runtime-testing/index.js"
|
37
36
|
},
|
@@ -39,8 +38,7 @@
|
|
39
38
|
"jsnext:source": "./src/runtime-testing/index.ts",
|
40
39
|
"node": {
|
41
40
|
"import": "./dist/js/modern/runtime-testing/index.js",
|
42
|
-
"require": "./dist/js/node/runtime-testing/index.js"
|
43
|
-
"types": "./types/index.d.ts"
|
41
|
+
"require": "./dist/js/node/runtime-testing/index.js"
|
44
42
|
},
|
45
43
|
"default": "./dist/js/treeshaking/runtime-testing/index.js"
|
46
44
|
},
|
@@ -48,8 +46,7 @@
|
|
48
46
|
"jsnext:source": "./src/runtime-testing/base.ts",
|
49
47
|
"node": {
|
50
48
|
"import": "./dist/js/modern/runtime-testing/base.js",
|
51
|
-
"require": "./dist/js/node/runtime-testing/base.js"
|
52
|
-
"types": "./types/base.d.ts"
|
49
|
+
"require": "./dist/js/node/runtime-testing/base.js"
|
53
50
|
},
|
54
51
|
"default": "./dist/js/treeshaking/runtime-testing/base.js"
|
55
52
|
},
|
@@ -70,10 +67,10 @@
|
|
70
67
|
"./dist/types/runtime-testing/index.d.ts"
|
71
68
|
],
|
72
69
|
"type": [
|
73
|
-
"./
|
70
|
+
"./types/index.d.ts"
|
74
71
|
],
|
75
72
|
"types": [
|
76
|
-
"./
|
73
|
+
"./types/index.d.ts"
|
77
74
|
],
|
78
75
|
"runtime-base": [
|
79
76
|
"./dist/types/runtime-testing/base.d.ts"
|
@@ -81,41 +78,36 @@
|
|
81
78
|
}
|
82
79
|
},
|
83
80
|
"dependencies": {
|
81
|
+
"@babel/core": "7.16.7",
|
84
82
|
"@babel/preset-env": "^7.15.6",
|
85
83
|
"@babel/runtime": "^7",
|
86
|
-
"@modern-js/
|
87
|
-
"@modern-js/
|
88
|
-
"@modern-js/
|
89
|
-
"@modern-js/
|
84
|
+
"@modern-js-reduck/plugin-auto-actions": "^1.0.2",
|
85
|
+
"@modern-js-reduck/plugin-effects": "^1.0.2",
|
86
|
+
"@modern-js-reduck/plugin-immutable": "^1.0.1",
|
87
|
+
"@modern-js-reduck/store": "^1.0.3",
|
88
|
+
"@modern-js/babel-compiler": "^1.2.3",
|
89
|
+
"@modern-js/bff-utils": "^1.2.4",
|
90
|
+
"@modern-js/runtime-core": "^1.4.3",
|
91
|
+
"@modern-js/testing": "^1.4.4",
|
92
|
+
"@modern-js/testing-plugin-bff": "^1.4.1",
|
93
|
+
"@modern-js/utils": "^1.6.0",
|
94
|
+
"@modern-js/webpack": "^1.5.7",
|
90
95
|
"@testing-library/jest-dom": "^5.14.1",
|
91
96
|
"@testing-library/react": "^12.0.0",
|
92
|
-
"
|
93
|
-
"@modern-js/testing-plugin-bff": "^1.3.0"
|
94
|
-
},
|
95
|
-
"peerDependencies": {
|
96
|
-
"@modern-js-reduck/plugin-auto-actions": "^1.0.0",
|
97
|
-
"@modern-js-reduck/plugin-effects": "^1.0.0",
|
98
|
-
"@modern-js-reduck/plugin-immutable": "^1.0.0",
|
99
|
-
"@modern-js-reduck/store": "^1.0.0",
|
100
|
-
"@modern-js/runtime-core": "^1.4.0"
|
97
|
+
"@types/testing-library__jest-dom": "^5.14.3"
|
101
98
|
},
|
102
99
|
"devDependencies": {
|
103
|
-
"@modern-js
|
104
|
-
"@modern-js-reduck/plugin-effects": "^1.0.0",
|
105
|
-
"@modern-js-reduck/plugin-immutable": "^1.0.0",
|
106
|
-
"@modern-js-reduck/store": "^1.0.0",
|
100
|
+
"@modern-js/core": "1.9.0",
|
107
101
|
"@scripts/build": "0.0.0",
|
108
|
-
"@
|
109
|
-
"@modern-js/runtime-core": "1.4.0",
|
102
|
+
"@scripts/jest-config": "0.0.0",
|
110
103
|
"@types/jest": "^26",
|
111
104
|
"@types/node": "^14",
|
112
105
|
"@types/react": "^17",
|
113
106
|
"@types/react-dom": "^17",
|
107
|
+
"jest": "^27",
|
114
108
|
"react": "^17",
|
115
109
|
"react-dom": "^17",
|
116
|
-
"typescript": "^4"
|
117
|
-
"jest": "^27",
|
118
|
-
"@scripts/jest-config": "0.0.0"
|
110
|
+
"typescript": "^4"
|
119
111
|
},
|
120
112
|
"sideEffects": false,
|
121
113
|
"modernConfig": {},
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import "@testing-library/react"
|
2
2
|
import "@testing-library/jest-dom"
|
3
|
-
import "
|
3
|
+
import "../dist/types/runtime-testing"
|
4
4
|
|
5
5
|
declare module '@modern-js/runtime/testing' {
|
6
6
|
export * from '@testing-library/react';
|
7
|
-
export { renderApp, createStore, testBff } from '
|
7
|
+
export { renderApp, createStore, testBff } from '../dist/types/runtime-testing';
|
8
8
|
}
|
@@ -1,15 +0,0 @@
|
|
1
|
-
import enhanceResolve from 'enhanced-resolve';
|
2
|
-
const resolver = enhanceResolve.create.sync({
|
3
|
-
conditionNames: ['require', 'node', 'default'],
|
4
|
-
extensions: ['.js', '.json', '.node', '.ts', '.tsx']
|
5
|
-
});
|
6
|
-
|
7
|
-
const shouldResolveByEnhance = url => /^@[^/]+\/[^/]+\/.*/.test(url);
|
8
|
-
|
9
|
-
module.exports = function (request, options) {
|
10
|
-
if (shouldResolveByEnhance(request)) {
|
11
|
-
return resolver(options.basedir, request);
|
12
|
-
}
|
13
|
-
|
14
|
-
return options.defaultResolver(request, options);
|
15
|
-
};
|
@@ -1,20 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _enhancedResolve = _interopRequireDefault(require("enhanced-resolve"));
|
4
|
-
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
6
|
-
|
7
|
-
const resolver = _enhancedResolve.default.create.sync({
|
8
|
-
conditionNames: ['require', 'node', 'default'],
|
9
|
-
extensions: ['.js', '.json', '.node', '.ts', '.tsx']
|
10
|
-
});
|
11
|
-
|
12
|
-
const shouldResolveByEnhance = url => /^@[^/]+\/[^/]+\/.*/.test(url);
|
13
|
-
|
14
|
-
module.exports = function (request, options) {
|
15
|
-
if (shouldResolveByEnhance(request)) {
|
16
|
-
return resolver(options.basedir, request);
|
17
|
-
}
|
18
|
-
|
19
|
-
return options.defaultResolver(request, options);
|
20
|
-
};
|
@@ -1,17 +0,0 @@
|
|
1
|
-
import enhanceResolve from 'enhanced-resolve';
|
2
|
-
var resolver = enhanceResolve.create.sync({
|
3
|
-
conditionNames: ['require', 'node', 'default'],
|
4
|
-
extensions: ['.js', '.json', '.node', '.ts', '.tsx']
|
5
|
-
});
|
6
|
-
|
7
|
-
var shouldResolveByEnhance = function shouldResolveByEnhance(url) {
|
8
|
-
return /^@[^/]+\/[^/]+\/.*/.test(url);
|
9
|
-
};
|
10
|
-
|
11
|
-
module.exports = function (request, options) {
|
12
|
-
if (shouldResolveByEnhance(request)) {
|
13
|
-
return resolver(options.basedir, request);
|
14
|
-
}
|
15
|
-
|
16
|
-
return options.defaultResolver(request, options);
|
17
|
-
};
|
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
package/tests/.eslintrc.js
DELETED
package/tests/index.test.ts
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
import { mergeUserJestConfig } from '../src/cli';
|
2
|
-
|
3
|
-
describe('mergeUserJestConfig', () => {
|
4
|
-
test('mergeUserJestConfig support object', () => {
|
5
|
-
const testUtils: any = {
|
6
|
-
_jestConfig: {
|
7
|
-
a: 1,
|
8
|
-
},
|
9
|
-
get jestConfig() {
|
10
|
-
return this._jestConfig;
|
11
|
-
},
|
12
|
-
testConfig: {
|
13
|
-
jest: {
|
14
|
-
b: 1,
|
15
|
-
},
|
16
|
-
},
|
17
|
-
mergeJestConfig(config: Record<string, string>) {
|
18
|
-
Object.assign(this._jestConfig, config);
|
19
|
-
},
|
20
|
-
};
|
21
|
-
|
22
|
-
mergeUserJestConfig(testUtils);
|
23
|
-
|
24
|
-
expect(testUtils.jestConfig).toEqual({
|
25
|
-
a: 1,
|
26
|
-
b: 1,
|
27
|
-
});
|
28
|
-
});
|
29
|
-
|
30
|
-
test('mergeUserJestConfig support function', () => {
|
31
|
-
const testUtils: any = {
|
32
|
-
_jestConfig: {
|
33
|
-
a: 1,
|
34
|
-
},
|
35
|
-
get jestConfig() {
|
36
|
-
return this._jestConfig;
|
37
|
-
},
|
38
|
-
testConfig: {
|
39
|
-
jest: (jestConfig: Record<string, number>) => {
|
40
|
-
jestConfig.b = 1;
|
41
|
-
},
|
42
|
-
},
|
43
|
-
mergeJestConfig(config: Record<string, string>) {
|
44
|
-
Object.assign(this._jestConfig, config);
|
45
|
-
},
|
46
|
-
};
|
47
|
-
|
48
|
-
mergeUserJestConfig(testUtils);
|
49
|
-
expect(testUtils.jestConfig).toEqual({
|
50
|
-
a: 1,
|
51
|
-
b: 1,
|
52
|
-
});
|
53
|
-
});
|
54
|
-
});
|
package/tests/resolver.test.ts
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
import path from 'path';
|
2
|
-
import { fs } from '@modern-js/utils';
|
3
|
-
|
4
|
-
const resolver = require('../src/cli/resolver');
|
5
|
-
|
6
|
-
describe('plugin-testing', () => {
|
7
|
-
it('resolver', () => {
|
8
|
-
const moduleDir = path.join(
|
9
|
-
__dirname,
|
10
|
-
'node_modules/@modern-js/runtime/module',
|
11
|
-
);
|
12
|
-
fs.ensureDirSync(moduleDir);
|
13
|
-
fs.writeJSONSync(
|
14
|
-
path.join(moduleDir, 'package.json'),
|
15
|
-
{
|
16
|
-
name: '@modern-js/runtime/module',
|
17
|
-
main: './index.js',
|
18
|
-
},
|
19
|
-
'utf-8',
|
20
|
-
);
|
21
|
-
fs.writeFileSync(
|
22
|
-
path.join(moduleDir, 'index.js'),
|
23
|
-
'module.exports = "@modern-js/runtime/module"',
|
24
|
-
'utf-8',
|
25
|
-
);
|
26
|
-
expect(
|
27
|
-
resolver('@modern-js/runtime/module', { basedir: __dirname }),
|
28
|
-
).toContain('module');
|
29
|
-
});
|
30
|
-
});
|
package/tests/tsconfig.json
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"extends": "@modern-js/tsconfig/base",
|
3
|
-
"compilerOptions": {
|
4
|
-
"declaration": true,
|
5
|
-
"jsx": "preserve",
|
6
|
-
"baseUrl": "./",
|
7
|
-
"outDir": "./out",
|
8
|
-
"emitDeclarationOnly": true,
|
9
|
-
"isolatedModules": true,
|
10
|
-
"paths": {},
|
11
|
-
"types": ["node", "jest"]
|
12
|
-
}
|
13
|
-
}
|