-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: create new @jest/transform package
- Loading branch information
Showing
19 changed files
with
127 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
**/__mocks__/** | ||
**/__tests__/** | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"name": "@jest/transform", | ||
"version": "24.1.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/facebook/jest.git", | ||
"directory": "packages/jest-transform" | ||
}, | ||
"license": "MIT", | ||
"main": "build/index.js", | ||
"dependencies": { | ||
"@babel/core": "^7.1.0", | ||
"babel-plugin-istanbul": "^5.1.0", | ||
"chalk": "^2.0.1", | ||
"convert-source-map": "^1.4.0", | ||
"fast-json-stable-stringify": "^2.0.0", | ||
"graceful-fs": "^4.1.15", | ||
"jest-haste-map": "^24.0.0", | ||
"jest-regex-util": "^24.0.0", | ||
"jest-util": "^24.0.0", | ||
"micromatch": "^3.1.10", | ||
"realpath-native": "^1.1.0", | ||
"slash": "^2.0.0", | ||
"write-file-atomic": "2.4.1" | ||
}, | ||
"devDependencies": { | ||
"@types/babel__core": "^7.0.4", | ||
"@types/convert-source-map": "^1.5.1", | ||
"@types/graceful-fs": "^4.1.2", | ||
"@types/micromatch": "^3.1.0", | ||
"@types/write-file-atomic": "^2.1.1", | ||
"jest-config": "^24.1.0" | ||
}, | ||
"engines": { | ||
"node": ">= 6" | ||
}, | ||
"gitHead": "b16789230fd45056a7f2fa199bae06c7a1780deb" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions
36
packages/jest-transform/src/enhanceUnexpectedTokenMessage.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
|
||
// @flow | ||
|
||
import chalk from 'chalk'; | ||
|
||
const DOT = ' \u2022 '; | ||
|
||
export default function enhanceUnexpectedTokenMessage(e: Error) { | ||
e.stack = | ||
`${chalk.bold.red('Jest encountered an unexpected token')} | ||
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. | ||
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". | ||
Here's what you can do: | ||
${DOT}To have some of your "node_modules" files transformed, you can specify a custom ${chalk.bold( | ||
'"transformIgnorePatterns"', | ||
)} in your config. | ||
${DOT}If you need a custom transformation specify a ${chalk.bold( | ||
'"transform"', | ||
)} option in your config. | ||
${DOT}If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the ${chalk.bold( | ||
'"moduleNameMapper"', | ||
)} config option. | ||
You'll find more details and examples of these config options in the docs: | ||
${chalk.cyan('https://jestjs.io/docs/en/configuration.html')} | ||
${chalk.bold.red('Details:')} | ||
` + e.stack; | ||
|
||
return e; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
export {default as ScriptTransformer} from './ScriptTransformer'; | ||
export {default as shouldInstrument} from './shouldInstrument'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow | ||
*/ | ||
|
||
import type {Glob, Path} from 'types/Config'; | ||
|
||
// TODO: Pick from `GlobalConfig` | ||
export type Options = {| | ||
changedFiles: ?Set<Path>, | ||
collectCoverage: boolean, | ||
collectCoverageFrom: Array<Glob>, | ||
collectCoverageOnlyFrom: ?{[key: string]: boolean, __proto__: null}, | ||
extraGlobals?: Array<string>, | ||
isCoreModule?: boolean, | ||
isInternalModule?: boolean, | ||
|}; |