Skip to content

Commit

Permalink
fix: reduce size of node_modules when adding ts-jest (#2309)
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl authored Jan 29, 2021
1 parent 0c555c2 commit b8d5d20
Show file tree
Hide file tree
Showing 10 changed files with 602 additions and 12,371 deletions.
2 changes: 1 addition & 1 deletion e2e/__helpers__/test-case/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
writeFileSync,
} from 'fs-extra'
import { stringify as stringifyJson5 } from 'json5'
import merge = require('lodash.merge')
import merge = require('lodash/merge')
import { join, relative, resolve, sep } from 'path'

import * as Paths from '../../../scripts/lib/paths'
Expand Down
12,937 changes: 586 additions & 12,351 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"fast-json-stable-stringify": "2.x",
"jest-util": "^26.1.0",
"json5": "2.x",
"lodash.memoize": "4.x",
"lodash": "4.x",
"make-error": "1.x",
"mkdirp": "1.x",
"semver": "7.x",
Expand Down Expand Up @@ -91,9 +91,7 @@
"@types/fs-extra": "latest",
"@types/js-yaml": "latest",
"@types/json5": "latest",
"@types/lodash.memoize": "4.x",
"@types/lodash.merge": "4.x",
"@types/lodash.set": "4.x",
"@types/lodash": "4.x",
"@types/micromatch": "4.x",
"@types/mkdirp": "latest",
"@types/node": "14.x",
Expand All @@ -117,8 +115,6 @@
"jest": "26.x",
"js-yaml": "latest",
"lint-staged": "latest",
"lodash.merge": "4.x",
"lodash.set": "4.x",
"npm-run-all": "latest",
"prettier": "2.x",
"source-map": "latest",
Expand Down
4 changes: 2 additions & 2 deletions src/__serializers__/processed-source.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { safeDump } from 'js-yaml'
import { dump } from 'js-yaml'

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

Expand All @@ -11,7 +11,7 @@ export const print = (val: ProcessedSource, _: unknown, indent: (str: string) =>
...(sourceMaps
? [
`===[ INLINE SOURCE MAPS ]${'='.repeat(55)}`,
safeDump(sourceMaps, {
dump(sourceMaps, {
sortKeys: true,
noRefs: true,
noCompatMode: true,
Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { TsJestPresetDescriptor, defaults, jsWIthBabel, jsWithTs } from '../help
* @internal
*/
export const run: CliCommand = async (args: Arguments /* , logger: Logger */) => {
const file = args._[0] || 'jest.config.js'
const file = args._[0]?.toString() ?? 'jest.config.js'
const filePath = join(process.cwd(), file)
const name = basename(file)
const isPackage = name === 'package.json'
Expand Down
2 changes: 1 addition & 1 deletion src/cli/config/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { JestPresetNames, TsJestPresetDescriptor, allPresets, defaults } from '.
*/
export const run: CliCommand = async (args: Arguments /* , logger: Logger*/) => {
const nullLogger = createLogger({ targets: [] })
const file = args._[0]
const file = args._[0]?.toString()
const filePath = resolve(process.cwd(), file)
const footNotes: string[] = []
if (!existsSync(filePath)) {
Expand Down
8 changes: 4 additions & 4 deletions src/compiler/__snapshots__/language-service.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ exports[`Language service allowJs option should compile js file for allowJs true
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1hbGxvdy1qcy5qcyIsIm1hcHBpbmdzIjoiOztBQUFBLGtCQUFlLEVBQUUsQ0FBQSIsIm5hbWVzIjpbXSwic291cmNlcyI6WyJ0ZXN0LWFsbG93LWpzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IDQyIl0sInZlcnNpb24iOjN9
===[ INLINE SOURCE MAPS ]=======================================================
file: test-allow-js.js
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
mappings: ;;AAAA,kBAAe,EAAE,CAAA
names: []
sources:
- test-allow-js.js
Expand All @@ -26,7 +26,7 @@ exports[`Language service allowJs option should compile js file for allowJs true
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1hbGxvdy1qcy5qcyIsIm1hcHBpbmdzIjoiOztBQUFBLGtCQUFlLEVBQUUsQ0FBQSIsIm5hbWVzIjpbXSwic291cmNlcyI6WyJ0ZXN0LWFsbG93LWpzLmpzIl0sInNvdXJjZXNDb250ZW50IjpbImV4cG9ydCBkZWZhdWx0IDQyIl0sInZlcnNpb24iOjN9
===[ INLINE SOURCE MAPS ]=======================================================
file: test-allow-js.js
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
mappings: ;;AAAA,kBAAe,EAAE,CAAA
names: []
sources:
- test-allow-js.js
Expand Down Expand Up @@ -139,7 +139,7 @@ exports[`Language service jsx option should compile tsx file for jsx preserve 1`
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1qc3gudHN4IiwibWFwcGluZ3MiOiI7QUFDUSxJQUFNLEdBQUcsR0FBRztJQUNWLE9BQU8sRUFBRSxJQUFJLEdBQUcsQ0FBQTtBQUNsQixDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsidGVzdC1qc3gudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICAgICAgICBjb25zdCBBcHAgPSAoKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIDw+VGVzdDwvPlxuICAgICAgICB9XG4gICAgICAiXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: test-jsx.tsx
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA'
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA
names: []
sources:
- test-jsx.tsx
Expand All @@ -163,7 +163,7 @@ exports[`Language service jsx option should compile tsx file for other jsx optio
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoidGVzdC1qc3gudHN4IiwibWFwcGluZ3MiOiI7QUFDUSxJQUFNLEdBQUcsR0FBRztJQUNWLE9BQU8saURBQVMsQ0FBQTtBQUNsQixDQUFDLENBQUEiLCJuYW1lcyI6W10sInNvdXJjZXMiOlsidGVzdC1qc3gudHN4Il0sInNvdXJjZXNDb250ZW50IjpbIlxuICAgICAgICBjb25zdCBBcHAgPSAoKSA9PiB7XG4gICAgICAgICAgcmV0dXJuIDw+VGVzdDwvPlxuICAgICAgICB9XG4gICAgICAiXSwidmVyc2lvbiI6M30=
===[ INLINE SOURCE MAPS ]=======================================================
file: test-jsx.tsx
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA'
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA
names: []
sources:
- test-jsx.tsx
Expand Down
6 changes: 3 additions & 3 deletions src/compiler/__snapshots__/transpiler.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ exports[`Transpiler jsx option should compile tsx file for jsx preserve 1`] = `
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLnRzeCIsIm1hcHBpbmdzIjoiO0FBQ1EsSUFBTSxHQUFHLEdBQUc7SUFDVixPQUFPLEVBQUUsSUFBSSxHQUFHLENBQUE7QUFDbEIsQ0FBQyxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby50c3giXSwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgICAgIGNvbnN0IEFwcCA9ICgpID0+IHtcbiAgICAgICAgICByZXR1cm4gPD5UZXN0PC8+XG4gICAgICAgIH1cbiAgICAgICJdLCJ2ZXJzaW9uIjozfQ==
===[ INLINE SOURCE MAPS ]=======================================================
file: foo.tsx
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA'
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,EAAE,IAAI,GAAG,CAAA;AAClB,CAAC,CAAA
names: []
sources:
- foo.tsx
Expand All @@ -37,7 +37,7 @@ exports[`Transpiler jsx option should compile tsx file for other jsx options 1`]
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLnRzeCIsIm1hcHBpbmdzIjoiO0FBQ1EsSUFBTSxHQUFHLEdBQUc7SUFDVixPQUFPLGlEQUFTLENBQUE7QUFDbEIsQ0FBQyxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby50c3giXSwic291cmNlc0NvbnRlbnQiOlsiXG4gICAgICAgIGNvbnN0IEFwcCA9ICgpID0+IHtcbiAgICAgICAgICByZXR1cm4gPD5UZXN0PC8+XG4gICAgICAgIH1cbiAgICAgICJdLCJ2ZXJzaW9uIjozfQ==
===[ INLINE SOURCE MAPS ]=======================================================
file: foo.tsx
mappings: ';AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA'
mappings: ;AACQ,IAAM,GAAG,GAAG;IACV,OAAO,iDAAS,CAAA;AAClB,CAAC,CAAA
names: []
sources:
- foo.tsx
Expand All @@ -60,7 +60,7 @@ exports[`Transpiler should compile js file for allowJs true 1`] = `
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJmaWxlIjoiZm9vLmpzIiwibWFwcGluZ3MiOiI7O0FBQUEsa0JBQWUsRUFBRSxDQUFBIiwibmFtZXMiOltdLCJzb3VyY2VzIjpbImZvby5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgZGVmYXVsdCA0MiJdLCJ2ZXJzaW9uIjozfQ==
===[ INLINE SOURCE MAPS ]=======================================================
file: foo.js
mappings: ';;AAAA,kBAAe,EAAE,CAAA'
mappings: ;;AAAA,kBAAe,EAAE,CAAA
names: []
sources:
- foo.js
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/language-service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LogContexts, Logger, LogLevels } from 'bs-logger'
import { existsSync, readFileSync, writeFile } from 'fs'
import { basename, normalize, relative, join } from 'path'
import memoize = require('lodash.memoize')
import memoize = require('lodash/memoize')
import mkdirp = require('mkdirp')
import type * as _ts from 'typescript'

Expand Down
2 changes: 1 addition & 1 deletion src/utils/backports.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testing } from 'bs-logger'
import set = require('lodash.set')
import set = require('lodash/set')
import { inspect } from 'util'

import { backportJestConfig } from './backports'
Expand Down

0 comments on commit b8d5d20

Please sign in to comment.