Skip to content

Commit

Permalink
require package.json in seperate file
Browse files Browse the repository at this point in the history
  • Loading branch information
ychi committed Jun 27, 2020
1 parent 0919547 commit a512723
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions packages/babel-jest/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import * as path from 'path';
import * as fs from 'graceful-fs';
import type {
TransformOptions as JestTransformOptions,
Transformer,
SyncTransformer,
} from '@jest/transform';
import type {Config} from '@jest/types';
import {
Expand All @@ -29,7 +29,7 @@ const jestPresetPath = require.resolve('babel-preset-jest');
const babelIstanbulPlugin = require.resolve('babel-plugin-istanbul');

// Narrow down the types
interface BabelJestTransformer extends Transformer {
interface BabelJestTransformer extends SyncTransformer {
canInstrument: true;
}
interface BabelJestTransformOptions extends TransformOptions {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-repl/src/cli/repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const evalCommand: repl.REPLEval = (
) => {
let result;
try {
if (transformer) {
if (transformer && transformer.process) {
const transformResult = transformer.process(
cmd,
jestGlobalConfig.replname || 'jest.js',
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-transform/src/ScriptTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import type {
} from './types';
import shouldInstrument from './shouldInstrument';
import handlePotentialSyntaxError from './enhanceUnexpectedTokenMessage';
import VERSION from './version';

type ProjectCache = {
configString: string;
Expand All @@ -42,8 +43,6 @@ type ProjectCache = {
transformedFiles: Map<string, TransformResult>;
};

// Use `require` to avoid TS rootDir
const {version: VERSION} = require('../package.json');

// This data structure is used to avoid recalculating some data every time that
// we need to transform a file. Since ScriptTransformer is instantiated for each
Expand Down
2 changes: 2 additions & 0 deletions packages/jest-transform/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export {default as shouldInstrument} from './shouldInstrument';
export type {
CacheKeyOptions,
Transformer,
SyncTransformer,
AsyncTransformer,
ShouldInstrumentOptions,
Options as TransformationOptions,
TransformOptions,
Expand Down
4 changes: 4 additions & 0 deletions packages/jest-transform/src/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Use `require` to avoid TS rootDir
const {version: VERSION} = require('../package.json');

export default VERSION;
4 changes: 2 additions & 2 deletions packages/jest-transform/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "build"
"outDir": "build",
"rootDir": "src",
},
"references": [
{"path": "../jest-haste-map"},
{"path": "../jest-regex-util"},
{"path": "../jest-types"},
{"path": "../jest-util"}
],
"include": ["src/**/*", "package.json"],
}

0 comments on commit a512723

Please sign in to comment.