Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[experimental] yarn pnp #7726

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
module.name_mapper='^pretty-format$' -> '<PROJECT_ROOT>/packages/pretty-format/src/index.js'
module.name_mapper='^types/\(.*\)$' -> '<PROJECT_ROOT>/types/\1.js'
module.name_mapper='\(jest-[^/]*\)' -> '<PROJECT_ROOT>/packages/\1/src/index.js'
module.resolver=<PROJECT_ROOT>/.pnp.js
include_warnings=true
emoji=true

Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
/e2e/transform/*/node_modules

/node_modules
/.pnp.js
/.pnp

/packages/*/build/
/packages/*/build-es5/
Expand Down
15 changes: 10 additions & 5 deletions e2e/runJest.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,16 @@ export default function runJest(

const env = {...process.env, FORCE_COLOR: 0};
if (options.nodePath) env['NODE_PATH'] = options.nodePath;
const result = spawnSync(JEST_PATH, args || [], {
cwd: dir,
env,
reject: false,
});
const result = spawnSync(
JEST_PATH,
// TODO this is ugly and a problem for e2e tests related to config/resolution
['--resolver', require.resolve('jest-pnp-resolver'), ...(args || [])],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah... no. Not sure how to properly deal with it, though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to be clear, I did not intend for this to be merged in this or some similar form 馃槃 this PR is just to share what I've done and what the problems are so we can possibly get back to this when there are good solutions for them :)

{
cwd: dir,
env,
reject: false,
},
);

// For compat with cross-spawn
result.status = result.code;
Expand Down
2 changes: 1 addition & 1 deletion examples/react-native/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = {
preset: 'react-native',
preset: require.resolve('react-native/jest-preset.json'),
transform: {
'^.+\\.js$': require.resolve('react-native/jest/preprocessor.js'),
},
Expand Down
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ module.exports = {
'website/.*',
'e2e/runtime-internal-module-registry/__mocks__',
],
projects: ['<rootDir>', '<rootDir>/examples/*/'],
projects: ['<rootDir>'], // TODO examples
resolver: require.resolve('jest-pnp-resolver'),
setupFilesAfterEnv: ['<rootDir>/testSetupFile.js'],
snapshotSerializers: [
'<rootDir>/packages/pretty-format/build/plugins/ConvertAnsi.js',
'jest-snapshot-serializer-raw',
require.resolve('jest-snapshot-serializer-raw'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can land this on master

],
testEnvironment: './packages/jest-environment-node',
testPathIgnorePatterns: [
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-transform-strict-mode": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should go on master

"@babel/preset-env": "^7.1.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
Expand All @@ -26,6 +27,7 @@
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-relay": "~0.0.19",
"estraverse": "^4.2.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

"execa": "^1.0.0",
"flow-bin": "^0.91.0",
"glob": "^7.1.1",
Expand All @@ -35,6 +37,7 @@
"istanbul-lib-coverage": "^2.0.2",
"jasmine-reporters": "^2.2.0",
"jest-junit": "^6.0.1",
"jest-pnp-resolver": "^1.0.2",
"jest-silent-reporter": "^0.1.1",
"jest-snapshot-serializer-raw": "^1.1.0",
"jquery": "^3.2.1",
Expand All @@ -48,11 +51,14 @@
"mkdirp": "^0.5.1",
"mocha": "^5.0.1",
"mock-fs": "^4.4.1",
"pnp-webpack-plugin": "^1.2.1",
"prettier": "^1.16.1",
"prettylint": "^1.0.0",
"progress": "^2.0.0",
"promise": "^8.0.2",
"readable-stream": "^3.0.3",
"realpath-native": "^1.0.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for the integration test? if so, should land on master

"request": "^2.88.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if it's for fetchSupporters, it should go in website/package.json

"resolve": "^1.4.0",
"rimraf": "^2.6.2",
"slash": "^2.0.0",
Expand Down Expand Up @@ -84,6 +90,9 @@
"typecheck": "flow check --include-warnings",
"watch": "yarn build && node ./scripts/watch.js"
},
"installConfig": {
"pnp": true
},
"workspaces": {
"packages": [
"packages/*",
Expand Down
3 changes: 2 additions & 1 deletion packages/jest-config/src/normalize.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ const setupPreset = (
let preset;
const presetPath = replaceRootDirInPath(options.rootDir, optionsPreset);
const presetModule = Resolver.findNodeModule(
presetPath.startsWith('.')
// TODO test and document absolute path support
path.isAbsolute(presetPath) || presetPath.startsWith('.')
? presetPath
: path.join(presetPath, PRESET_NAME),
{
Expand Down
10 changes: 8 additions & 2 deletions scripts/browserBuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*/
'use strict';

const path = require('path');
const webpack = require('webpack');
const camelCase = require('camelcase');
const path = require('path');
const rimraf = require('rimraf');

const webpack = require('webpack');
const PnpWebpackPlugin = require(`pnp-webpack-plugin`);

const babelEs5Options = {
// Dont load other config files
babelrc: false,
Expand Down Expand Up @@ -57,13 +59,17 @@ function browserBuild(pkgName, entryPath, destination) {
],
},
resolve: {
plugins: [PnpWebpackPlugin],
alias: {
chalk: path.resolve(
__dirname,
'../packages/expect/build/fakeChalk.js'
),
},
},
resolveLoader: {
plugins: [PnpWebpackPlugin.moduleLoader(module)],
},
node: {
fs: 'empty',
},
Expand Down
21 changes: 19 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
"@babel/helper-module-transforms" "^7.1.0"
"@babel/helper-plugin-utils" "^7.0.0"

"@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.2.0":
"@babel/plugin-transform-modules-commonjs@^7.0.0", "@babel/plugin-transform-modules-commonjs@^7.1.0", "@babel/plugin-transform-modules-commonjs@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.2.0.tgz#c4f1933f5991d5145e9cfad1dfd848ea1727f404"
integrity sha512-V6y0uaUQrQPXUrmj+hgnks8va2L0zcZymeU7TtWEgdRLNkceafKXEduv7QzgQAE4lT+suwooG9dC7LFhdRAbVQ==
Expand Down Expand Up @@ -7452,6 +7452,11 @@ jest-mock@^23.2.0:
resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-23.2.0.tgz#ad1c60f29e8719d47c26e1138098b6d18b261134"
integrity sha1-rRxg8p6HGdR8JuETgJi20YsmETQ=

jest-pnp-resolver@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.0.2.tgz#470384ae9ea31f72136db52618aa4010ff23b715"
integrity sha512-H2DvUlwdMedNGv4FOliPDnxani6ATWy70xe2eckGJgkLoMaWzRPqpSlc5ShqX0Ltk5OhRQvPQY2LLZPOpgcc7g==

jest-regex-util@^23.3.0:
version "23.3.0"
resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-23.3.0.tgz#5f86729547c2785c4002ceaa8f849fe8ca471bc5"
Expand Down Expand Up @@ -10076,6 +10081,13 @@ pn@^1.1.0:
resolved "https://registry.yarnpkg.com/pn/-/pn-1.1.0.tgz#e2f4cef0e219f463c179ab37463e4e1ecdccbafb"
integrity sha512-2qHaIQr2VLRFoxe2nASzsV6ef4yOOH+Fi9FBOVH6cqeSgUnoyySPZkxzLuzd+RYOQTRpROA0ztTMqxROKSb/nA==

pnp-webpack-plugin@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/pnp-webpack-plugin/-/pnp-webpack-plugin-1.2.1.tgz#cd9d698df2a6fcf7255093c1c9511adf65b9421b"
integrity sha512-W6GctK7K2qQiVR+gYSv/Gyt6jwwIH4vwdviFqx+Y2jAtVf5eZyYIDf5Ac2NCDMBiX5yWscBLZElPTsyA1UtVVA==
dependencies:
ts-pnp "^1.0.0"

portfinder@^1.0.17:
version "1.0.20"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.20.tgz#bea68632e54b2e13ab7b0c4775e9b41bf270e44a"
Expand Down Expand Up @@ -11236,7 +11248,7 @@ request-promise-native@^1.0.5:
stealthy-require "^1.1.0"
tough-cookie ">=2.3.3"

request@^2.53.0, request@^2.87.0:
request@^2.53.0, request@^2.87.0, request@^2.88.0:
version "2.88.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.88.0.tgz#9c2fca4f7d35b592efe57c7f0a55e81052124fef"
integrity sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==
Expand Down Expand Up @@ -12648,6 +12660,11 @@ truncate-html@^1.0.1:
"@types/cheerio" "^0.22.8"
cheerio "0.22.0"

ts-pnp@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ts-pnp/-/ts-pnp-1.0.0.tgz#44a3a9e8c13fcb711bcda75d7b576c21af120c9d"
integrity sha512-qgwM7eBrxFvZSXLtSvjf3c2mXwJOOGD49VlE+KocUGX95DuMdLc/psZHBnPpZL5b2NU7VtQGHRCWF3cNfe5kxQ==

tslib@^1.8.0, tslib@^1.9.0:
version "1.9.3"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286"
Expand Down