@promoboxx/react-scripts-vite 0.1.7 → 0.1.10
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/dist/jest/babelTransform.d.ts +2 -0
- package/dist/jest/babelTransform.js +31 -0
- package/dist/jest/pathsToModuleNameMapper.d.ts +6 -0
- package/dist/jest/pathsToModuleNameMapper.js +49 -0
- package/dist/jestConfig.d.ts +1 -1
- package/dist/jestConfig.js +25 -8
- package/dist/readTypescriptConfig.d.ts +3 -0
- package/dist/readTypescriptConfig.js +16 -0
- package/package.json +11 -2
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// https://github.com/facebook/create-react-app/blob/08dc7ab0f520f680b678556edeb702a5791af20e/packages/react-scripts/config/jest/babelTransform.js
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
var babel_jest_1 = __importDefault(require("babel-jest"));
|
|
8
|
+
// const hasJsxRuntime = (() => {
|
|
9
|
+
// if (process.env.DISABLE_NEW_JSX_TRANSFORM === 'true') {
|
|
10
|
+
// return false;
|
|
11
|
+
// }
|
|
12
|
+
// try {
|
|
13
|
+
// require.resolve('react/jsx-runtime');
|
|
14
|
+
// return true;
|
|
15
|
+
// } catch (e) {
|
|
16
|
+
// return false;
|
|
17
|
+
// }
|
|
18
|
+
// })();
|
|
19
|
+
if (babel_jest_1.default.createTransformer == null) {
|
|
20
|
+
throw new Error('createTransformer is undefined');
|
|
21
|
+
}
|
|
22
|
+
exports.default = babel_jest_1.default.createTransformer({
|
|
23
|
+
presets: [
|
|
24
|
+
['@babel/preset-env', { targets: { node: 'current' } }],
|
|
25
|
+
['@babel/preset-typescript'],
|
|
26
|
+
['@babel/preset-react', { runtime: 'automatic' }],
|
|
27
|
+
],
|
|
28
|
+
babelrc: false,
|
|
29
|
+
configFile: false,
|
|
30
|
+
});
|
|
31
|
+
//# sourceMappingURL=babelTransform.js.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Config } from '@jest/types';
|
|
2
|
+
declare type JestPathMapping = Config.InitialOptions['moduleNameMapper'];
|
|
3
|
+
export declare const pathsToModuleNameMapper: (mapping: import("typescript").MapLike<string[]>, { prefix }?: {
|
|
4
|
+
prefix: string;
|
|
5
|
+
}) => JestPathMapping;
|
|
6
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// https://github.com/kulshekhar/ts-jest/blob/42ff5e469fb5d315b92e85eee105e5a040949c01/src/config/paths-to-module-name-mapper.ts
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.pathsToModuleNameMapper = void 0;
|
|
5
|
+
// we don't need to escape all chars, so commented out is the real one
|
|
6
|
+
// const escapeRegex = (str: string) => str.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')
|
|
7
|
+
var escapeRegex = function (str) { return str.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'); };
|
|
8
|
+
// const logger = rootLogger.child({ [LogContexts.namespace]: 'path-mapper' })
|
|
9
|
+
var pathsToModuleNameMapper = function (mapping, _a) {
|
|
10
|
+
var _b = _a === void 0 ? Object.create(null) : _a, _c = _b.prefix, prefix = _c === void 0 ? '' : _c;
|
|
11
|
+
var jestMap = {};
|
|
12
|
+
for (var _i = 0, _d = Object.keys(mapping); _i < _d.length; _i++) {
|
|
13
|
+
var fromPath = _d[_i];
|
|
14
|
+
var pattern = void 0;
|
|
15
|
+
var toPaths = mapping[fromPath];
|
|
16
|
+
// check that we have only one target path
|
|
17
|
+
if (toPaths.length === 0) {
|
|
18
|
+
// logger.warn(interpolate(Errors.NotMappingPathWithEmptyMap, { path: fromPath }))
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
21
|
+
// split with '*'
|
|
22
|
+
var segments = fromPath.split(/\*/g);
|
|
23
|
+
if (segments.length === 1) {
|
|
24
|
+
var paths = toPaths.map(function (target) {
|
|
25
|
+
var enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? prefix + "/" : prefix;
|
|
26
|
+
return "" + enrichedPrefix + target;
|
|
27
|
+
});
|
|
28
|
+
pattern = "^" + escapeRegex(fromPath) + "$";
|
|
29
|
+
jestMap[pattern] = paths.length === 1 ? paths[0] : paths;
|
|
30
|
+
}
|
|
31
|
+
else if (segments.length === 2) {
|
|
32
|
+
var paths = toPaths.map(function (target) {
|
|
33
|
+
var enrichedTarget = target.startsWith('./') && prefix !== ''
|
|
34
|
+
? target.substring(target.indexOf('/') + 1)
|
|
35
|
+
: target;
|
|
36
|
+
var enrichedPrefix = prefix !== '' && !prefix.endsWith('/') ? prefix + "/" : prefix;
|
|
37
|
+
return "" + enrichedPrefix + enrichedTarget.replace(/\*/g, '$1');
|
|
38
|
+
});
|
|
39
|
+
pattern = "^" + escapeRegex(segments[0]) + "(.*)" + escapeRegex(segments[1]) + "$";
|
|
40
|
+
jestMap[pattern] = paths.length === 1 ? paths[0] : paths;
|
|
41
|
+
}
|
|
42
|
+
else {
|
|
43
|
+
// logger.warn(interpolate(Errors.NotMappingMultiStarPath, { path: fromPath }))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return jestMap;
|
|
47
|
+
};
|
|
48
|
+
exports.pathsToModuleNameMapper = pathsToModuleNameMapper;
|
|
49
|
+
//# sourceMappingURL=pathsToModuleNameMapper.js.map
|
package/dist/jestConfig.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ declare const jestConfig: {
|
|
|
7
7
|
'^react-native$': string;
|
|
8
8
|
'^.+\\.module\\.(css|sass|scss)$': string;
|
|
9
9
|
};
|
|
10
|
-
preset: string;
|
|
11
10
|
resetMocks: boolean;
|
|
12
11
|
roots: string[];
|
|
13
12
|
setupFiles: string[];
|
|
@@ -16,6 +15,7 @@ declare const jestConfig: {
|
|
|
16
15
|
testMatch: string[];
|
|
17
16
|
testRunner: string;
|
|
18
17
|
transform: {
|
|
18
|
+
'\\.[jt]sx?$': string;
|
|
19
19
|
'^.+\\.css$': string;
|
|
20
20
|
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': string;
|
|
21
21
|
};
|
package/dist/jestConfig.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
2
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
var pathsToModuleNameMapper_1 = require("./jest/pathsToModuleNameMapper");
|
|
18
|
+
var readTypescriptConfig_1 = __importDefault(require("./readTypescriptConfig"));
|
|
19
|
+
var typescriptConfig = readTypescriptConfig_1.default();
|
|
3
20
|
var jestConfig = {
|
|
4
21
|
// All imported modules in your tests should be mocked automatically
|
|
5
22
|
// automock: false,
|
|
@@ -63,10 +80,9 @@ var jestConfig = {
|
|
|
63
80
|
'd.ts',
|
|
64
81
|
],
|
|
65
82
|
// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
|
|
66
|
-
moduleNameMapper: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
},
|
|
83
|
+
moduleNameMapper: __assign(__assign({}, pathsToModuleNameMapper_1.pathsToModuleNameMapper(typescriptConfig.options.paths || {}, {
|
|
84
|
+
prefix: '<rootDir>/',
|
|
85
|
+
})), { '^react-native$': 'react-native-web', '^.+\\.module\\.(css|sass|scss)$': 'identity-obj-proxy' }),
|
|
70
86
|
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
|
|
71
87
|
// modulePathIgnorePatterns: [],
|
|
72
88
|
// Activates notifications for test results
|
|
@@ -74,7 +90,7 @@ var jestConfig = {
|
|
|
74
90
|
// An enum that specifies notification mode. Requires { notify: true }
|
|
75
91
|
// notifyMode: "failure-change",
|
|
76
92
|
// A preset that is used as a base for Jest's configuration
|
|
77
|
-
preset: 'ts-jest/presets/js-with-ts',
|
|
93
|
+
// preset: 'ts-jest/presets/js-with-ts',
|
|
78
94
|
// Run tests from one or more projects
|
|
79
95
|
// projects: undefined,
|
|
80
96
|
// Use this configuration option to add custom reporters to Jest
|
|
@@ -96,7 +112,7 @@ var jestConfig = {
|
|
|
96
112
|
// The paths to modules that run some code to configure or set up the testing environment before each test
|
|
97
113
|
setupFiles: [require.resolve('react-app-polyfill/jsdom')],
|
|
98
114
|
// A list of paths to modules that run some code to configure or set up the testing framework before each test
|
|
99
|
-
setupFilesAfterEnv: ['src/setupTests.ts'],
|
|
115
|
+
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
|
|
100
116
|
// The number of seconds after which a test is considered as slow and reported as such in the results.
|
|
101
117
|
// slowTestThreshold: 5,
|
|
102
118
|
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
|
|
@@ -128,8 +144,9 @@ var jestConfig = {
|
|
|
128
144
|
// timers: "real",
|
|
129
145
|
// A map from regular expressions to paths to transformers
|
|
130
146
|
transform: {
|
|
131
|
-
'
|
|
132
|
-
'
|
|
147
|
+
'\\.[jt]sx?$': require.resolve('./jest/babelTransform'),
|
|
148
|
+
'^.+\\.css$': require.resolve('./jest/cssTransform'),
|
|
149
|
+
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': require.resolve('./jest/fileTransform'),
|
|
133
150
|
},
|
|
134
151
|
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
|
|
135
152
|
transformIgnorePatterns: [
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var existingConfig;
|
|
4
|
+
function readTypescriptConfig() {
|
|
5
|
+
if (existingConfig == null) {
|
|
6
|
+
var typescriptCompilerPath = require.resolve('typescript');
|
|
7
|
+
var typescript = require(typescriptCompilerPath);
|
|
8
|
+
existingConfig = typescript.getParsedCommandLineOfConfigFile('./tsconfig.json', undefined, typescript.sys);
|
|
9
|
+
}
|
|
10
|
+
if (existingConfig == null) {
|
|
11
|
+
throw new Error('could not read tsconfig.json');
|
|
12
|
+
}
|
|
13
|
+
return existingConfig;
|
|
14
|
+
}
|
|
15
|
+
exports.default = readTypescriptConfig;
|
|
16
|
+
//# sourceMappingURL=readTypescriptConfig.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@promoboxx/react-scripts-vite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -16,13 +16,16 @@
|
|
|
16
16
|
"typescript": "^4.3.5"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
+
"@babel/preset-env": "^7.15.0",
|
|
20
|
+
"@babel/preset-react": "^7.14.5",
|
|
21
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
19
22
|
"@vitejs/plugin-react-refresh": "^1.3.6",
|
|
23
|
+
"babel-jest": "^27.0.6",
|
|
20
24
|
"eslint": "^7.32.0",
|
|
21
25
|
"jest": "^27.0.6",
|
|
22
26
|
"jest-circus": "^27.0.6",
|
|
23
27
|
"jest-watch-typeahead": "^0.6.4",
|
|
24
28
|
"react-app-polyfill": "^2.0.0",
|
|
25
|
-
"ts-jest": "^27.0.5",
|
|
26
29
|
"vite": "^2.5.0",
|
|
27
30
|
"vite-plugin-checker": "^0.3.4",
|
|
28
31
|
"vite-plugin-env-compatible": "^1.1.0",
|
|
@@ -33,12 +36,18 @@
|
|
|
33
36
|
"files": [
|
|
34
37
|
"dist/index.d.ts",
|
|
35
38
|
"dist/index.js",
|
|
39
|
+
"dist/jest/babelTransform.d.ts",
|
|
40
|
+
"dist/jest/babelTransform.js",
|
|
36
41
|
"dist/jestConfig.d.ts",
|
|
37
42
|
"dist/jestConfig.js",
|
|
38
43
|
"dist/jest/cssTransform.d.ts",
|
|
39
44
|
"dist/jest/cssTransform.js",
|
|
40
45
|
"dist/jest/fileTransform.d.ts",
|
|
41
46
|
"dist/jest/fileTransform.js",
|
|
47
|
+
"dist/jest/pathsToModuleNameMapper.d.ts",
|
|
48
|
+
"dist/jest/pathsToModuleNameMapper.js",
|
|
49
|
+
"dist/readTypescriptConfig.d.ts",
|
|
50
|
+
"dist/readTypescriptConfig.js",
|
|
42
51
|
"dist/viteConfig.d.ts",
|
|
43
52
|
"dist/viteConfig.js"
|
|
44
53
|
]
|