Skip to content

Commit b8d5d20

Browse files
authored
fix: reduce size of node_modules when adding ts-jest (#2309)
1 parent 0c555c2 commit b8d5d20

File tree

10 files changed

+602
-12371
lines changed

10 files changed

+602
-12371
lines changed

e2e/__helpers__/test-case/runtime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
writeFileSync,
2121
} from 'fs-extra'
2222
import { stringify as stringifyJson5 } from 'json5'
23-
import merge = require('lodash.merge')
23+
import merge = require('lodash/merge')
2424
import { join, relative, resolve, sep } from 'path'
2525

2626
import * as Paths from '../../../scripts/lib/paths'

package-lock.json

Lines changed: 586 additions & 12351 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"fast-json-stable-stringify": "2.x",
6464
"jest-util": "^26.1.0",
6565
"json5": "2.x",
66-
"lodash.memoize": "4.x",
66+
"lodash": "4.x",
6767
"make-error": "1.x",
6868
"mkdirp": "1.x",
6969
"semver": "7.x",
@@ -91,9 +91,7 @@
9191
"@types/fs-extra": "latest",
9292
"@types/js-yaml": "latest",
9393
"@types/json5": "latest",
94-
"@types/lodash.memoize": "4.x",
95-
"@types/lodash.merge": "4.x",
96-
"@types/lodash.set": "4.x",
94+
"@types/lodash": "4.x",
9795
"@types/micromatch": "4.x",
9896
"@types/mkdirp": "latest",
9997
"@types/node": "14.x",
@@ -117,8 +115,6 @@
117115
"jest": "26.x",
118116
"js-yaml": "latest",
119117
"lint-staged": "latest",
120-
"lodash.merge": "4.x",
121-
"lodash.set": "4.x",
122118
"npm-run-all": "latest",
123119
"prettier": "2.x",
124120
"source-map": "latest",

src/__serializers__/processed-source.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { safeDump } from 'js-yaml'
1+
import { dump } from 'js-yaml'
22

33
import ProcessedSource from '../__helpers__/processed-source'
44

@@ -11,7 +11,7 @@ export const print = (val: ProcessedSource, _: unknown, indent: (str: string) =>
1111
...(sourceMaps
1212
? [
1313
`===[ INLINE SOURCE MAPS ]${'='.repeat(55)}`,
14-
safeDump(sourceMaps, {
14+
dump(sourceMaps, {
1515
sortKeys: true,
1616
noRefs: true,
1717
noCompatMode: true,

src/cli/config/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { TsJestPresetDescriptor, defaults, jsWIthBabel, jsWithTs } from '../help
1616
* @internal
1717
*/
1818
export const run: CliCommand = async (args: Arguments /* , logger: Logger */) => {
19-
const file = args._[0] || 'jest.config.js'
19+
const file = args._[0]?.toString() ?? 'jest.config.js'
2020
const filePath = join(process.cwd(), file)
2121
const name = basename(file)
2222
const isPackage = name === 'package.json'

src/cli/config/migrate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { JestPresetNames, TsJestPresetDescriptor, allPresets, defaults } from '.
1515
*/
1616
export const run: CliCommand = async (args: Arguments /* , logger: Logger*/) => {
1717
const nullLogger = createLogger({ targets: [] })
18-
const file = args._[0]
18+
const file = args._[0]?.toString()
1919
const filePath = resolve(process.cwd(), file)
2020
const footNotes: string[] = []
2121
if (!existsSync(filePath)) {

src/compiler/__snapshots__/language-service.spec.ts.snap

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ exports[`Language service allowJs option should compile js file for allowJs true
88
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1hbGxvdy1qcy5qcyIsIm1hcHBpbmdzIjoiOztBQUFBLGtCQUFlLEVBQUUsQ0FBQSIsIm5hbWVzIjpbXSwic291cmNlcyI6WyJ0ZXN0LWFsbG93LWpzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IDQyIl0sInZlcnNpb24iOjN9
99
===[ INLINE SOURCE MAPS ]=======================================================
1010
file: test-allow-js.js
11-
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
11+
mappings: ;;AAAA,kBAAe,EAAE,CAAA
1212
names: []
1313
sources:
1414
- test-allow-js.js
@@ -26,7 +26,7 @@ exports[`Language service allowJs option should compile js file for allowJs true
2626
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1hbGxvdy1qcy5qcyIsIm1hcHBpbmdzIjoiOztBQUFBLGtCQUFlLEVBQUUsQ0FBQSIsIm5hbWVzIjpbXSwic291cmNlcyI6WyJ0ZXN0LWFsbG93LWpzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IDQyIl0sInZlcnNpb24iOjN9
2727
===[ INLINE SOURCE MAPS ]=======================================================
2828
file: test-allow-js.js
29-
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
29+
mappings: ;;AAAA,kBAAe,EAAE,CAAA
3030
names: []
3131
sources:
3232
- test-allow-js.js
@@ -139,7 +139,7 @@ exports[`Language service jsx option should compile tsx file for jsx preserve 1`
139139
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1qc3gudHN4IiwibWFwcGluZ3MiOiI7QUFDUSxJQUFNLEdBQUcsR0FBRztJQUNWLE9BQU8sRUFBRSxJQUFJLEdBQUcsQ0FBQTtBQUNsQixDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsidGVzdC1qc3gudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICAgICAgICBjb25zdCBBcHAgPSAoKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIDw+VGVzdDwvPlxuICAgICAgICB9XG4gICAgICAiXSwidmVyc2lvbiI6M30=
140140
===[ INLINE SOURCE MAPS ]=======================================================
141141
file: test-jsx.tsx
142-
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA'
142+
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA
143143
names: []
144144
sources:
145145
- test-jsx.tsx
@@ -163,7 +163,7 @@ exports[`Language service jsx option should compile tsx file for other jsx optio
163163
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1qc3gudHN4IiwibWFwcGluZ3MiOiI7QUFDUSxJQUFNLEdBQUcsR0FBRztJQUNWLE9BQU8saURBQVMsQ0FBQTtBQUNsQixDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsidGVzdC1qc3gudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICAgICAgICBjb25zdCBBcHAgPSAoKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIDw+VGVzdDwvPlxuICAgICAgICB9XG4gICAgICAiXSwidmVyc2lvbiI6M30=
164164
===[ INLINE SOURCE MAPS ]=======================================================
165165
file: test-jsx.tsx
166-
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA'
166+
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA
167167
names: []
168168
sources:
169169
- test-jsx.tsx

src/compiler/__snapshots__/transpiler.spec.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ exports[`Transpiler jsx option should compile tsx file for jsx preserve 1`] = `
1313
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLnRzeCIsIm1hcHBpbmdzIjoiO0FBQ1EsSUFBTSxHQUFHLEdBQUc7SUFDVixPQUFPLEVBQUUsSUFBSSxHQUFHLENBQUE7QUFDbEIsQ0FBQyxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby50c3giXSwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgICAgIGNvbnN0IEFwcCA9ICgpID0+IHtcbiAgICAgICAgICByZXR1cm4gPD5UZXN0PC8+XG4gICAgICAgIH1cbiAgICAgICJdLCJ2ZXJzaW9uIjozfQ==
1414
===[ INLINE SOURCE MAPS ]=======================================================
1515
file: foo.tsx
16-
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA'
16+
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA
1717
names: []
1818
sources:
1919
- foo.tsx
@@ -37,7 +37,7 @@ exports[`Transpiler jsx option should compile tsx file for other jsx options 1`]
3737
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLnRzeCIsIm1hcHBpbmdzIjoiO0FBQ1EsSUFBTSxHQUFHLEdBQUc7SUFDVixPQUFPLGlEQUFTLENBQUE7QUFDbEIsQ0FBQyxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby50c3giXSwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgICAgIGNvbnN0IEFwcCA9ICgpID0+IHtcbiAgICAgICAgICByZXR1cm4gPD5UZXN0PC8+XG4gICAgICAgIH1cbiAgICAgICJdLCJ2ZXJzaW9uIjozfQ==
3838
===[ INLINE SOURCE MAPS ]=======================================================
3939
file: foo.tsx
40-
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA'
40+
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA
4141
names: []
4242
sources:
4343
- foo.tsx
@@ -60,7 +60,7 @@ exports[`Transpiler should compile js file for allowJs true 1`] = `
6060
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLmpzIiwibWFwcGluZ3MiOiI7O0FBQUEsa0JBQWUsRUFBRSxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCA0MiJdLCJ2ZXJzaW9uIjozfQ==
6161
===[ INLINE SOURCE MAPS ]=======================================================
6262
file: foo.js
63-
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
63+
mappings: ;;AAAA,kBAAe,EAAE,CAAA
6464
names: []
6565
sources:
6666
- foo.js

src/compiler/language-service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { LogContexts, Logger, LogLevels } from 'bs-logger'
22
import { existsSync, readFileSync, writeFile } from 'fs'
33
import { basename, normalize, relative, join } from 'path'
4-
import memoize = require('lodash.memoize')
4+
import memoize = require('lodash/memoize')
55
import mkdirp = require('mkdirp')
66
import type * as _ts from 'typescript'
77

src/utils/backports.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { testing } from 'bs-logger'
2-
import set = require('lodash.set')
2+
import set = require('lodash/set')
33
import { inspect } from 'util'
44

55
import { backportJestConfig } from './backports'

0 commit comments

Comments
 (0)