-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add yarn v2 pnp support to default webpack processor (#17335)
- Loading branch information
1 parent
ba1c85b
commit 74ada11
Showing
19 changed files
with
305 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import fs from 'fs-extra' | ||
import os from 'os' | ||
import path from 'path' | ||
import cp from 'child_process' | ||
import util from 'util' | ||
import e2e from '../support/helpers/e2e' | ||
import Fixtures from '../support/helpers/fixtures' | ||
|
||
const exec = async (cmd, ...args) => { | ||
console.log(`Running "${cmd}"...`) | ||
const ret = await util.promisify(cp.exec)(cmd, ...args) | ||
.catch((err) => { | ||
console.error('Error:', err) | ||
|
||
return err | ||
}) | ||
|
||
console.log('stdout:', ret.stdout) | ||
ret.stderr && console.log('stderr:', ret.stderr) | ||
|
||
return ret | ||
} | ||
|
||
const fixtureDir = Fixtures.path('projects/yarn-v2-pnp') | ||
const cypressCli = path.join(__dirname, '../../../../cli/bin/cypress') | ||
|
||
describe('e2e yarn v2', () => { | ||
let projectDir | ||
|
||
beforeEach(async function () { | ||
this.timeout(240000) | ||
|
||
// copy yarn-v2 to tmpdir so node_modules resolution won't fall back to project root | ||
projectDir = path.join(os.tmpdir(), `cy-yarn-v2-pnp-${Date.now()}`) | ||
console.log(`projectDir`, projectDir) | ||
|
||
await fs.mkdir(projectDir) | ||
await fs.copy(fixtureDir, projectDir) | ||
|
||
const projectExec = (cmd) => exec(cmd, { cwd: projectDir }) | ||
|
||
await projectExec('yarn') | ||
}) | ||
|
||
e2e.it('can compile plugin and test specs', { | ||
snapshot: false, | ||
command: 'yarn', | ||
browser: 'electron', | ||
onRun: async (run) => { | ||
await run({ | ||
args: `node ${cypressCli} run --dev --project=./`.split(' '), | ||
spawnOpts: { | ||
cwd: projectDir, | ||
shell: true, | ||
}, | ||
}) | ||
}, | ||
}) | ||
}) |
2 changes: 2 additions & 0 deletions
2
packages/server/test/support/fixtures/projects/yarn-v2-pnp/.gitignore
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,2 @@ | ||
.yarn | ||
.pnp.js |
1 change: 1 addition & 0 deletions
1
packages/server/test/support/fixtures/projects/yarn-v2-pnp/.yarnrc.yml
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 @@ | ||
yarnPath: "./yarn-berry.cjs" |
1 change: 1 addition & 0 deletions
1
packages/server/test/support/fixtures/projects/yarn-v2-pnp/cypress.json
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 @@ | ||
{} |
7 changes: 7 additions & 0 deletions
7
packages/server/test/support/fixtures/projects/yarn-v2-pnp/cypress/integration/index.ts
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,7 @@ | ||
import * as head from 'lodash/head' | ||
|
||
describe('yarn-v2-pnp', () => { | ||
it('can load package from pnp runtime', () => { | ||
expect(head([1, 2, 3])).to.equal(1) | ||
}) | ||
}) |
9 changes: 9 additions & 0 deletions
9
packages/server/test/support/fixtures/projects/yarn-v2-pnp/cypress/plugins/index.ts
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,9 @@ | ||
import * as head from 'lodash/head' | ||
|
||
// Default Cypress plugin function | ||
export default (on, config) => { | ||
// make sure plugin can access dependencies | ||
head([1, 2, 3]) | ||
|
||
return config | ||
} |
11 changes: 11 additions & 0 deletions
11
packages/server/test/support/fixtures/projects/yarn-v2-pnp/package.json
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 @@ | ||
{ | ||
"name": "yarn-v2-pnp", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"lodash": "^4.17.21" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.2.4" | ||
}, | ||
"license": "MIT" | ||
} |
9 changes: 9 additions & 0 deletions
9
packages/server/test/support/fixtures/projects/yarn-v2-pnp/tsconfig.json
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,9 @@ | ||
{ | ||
"compilerOptions": { | ||
"target": "es5", | ||
"lib": ["es5", "dom"], | ||
"allowJs": true, | ||
"moduleResolution": "node" | ||
}, | ||
"include": ["**/*.ts"] | ||
} |
55 changes: 55 additions & 0 deletions
55
packages/server/test/support/fixtures/projects/yarn-v2-pnp/yarn-berry.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
packages/server/test/support/fixtures/projects/yarn-v2-pnp/yarn.lock
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,42 @@ | ||
# This file is generated by running "yarn install" inside your project. | ||
# Manual changes might be lost - proceed with caution! | ||
|
||
__metadata: | ||
version: 4 | ||
cacheKey: 7 | ||
|
||
"lodash@npm:^4.17.21": | ||
version: 4.17.21 | ||
resolution: "lodash@npm:4.17.21" | ||
checksum: 4983720b9abca930a4a46f18db163d7dad8dd00dbed6db0cc7b499b33b717cce69f80928b27bbb1ff2cbd3b19d251ee90669a8b5ea466072ca81c2ebe91e7468 | ||
languageName: node | ||
linkType: hard | ||
|
||
typescript@^4.2.4: | ||
version: 4.3.5 | ||
resolution: "typescript@npm:4.3.5" | ||
bin: | ||
tsc: bin/tsc | ||
tsserver: bin/tsserver | ||
checksum: d9a8e78d72dd19896e6bfa73ab2a0fcea6eca2700d1d6e7c33f67a970af54a3e0fed8f715a8c4e6a0ff7fc0995067b394b2003518ab0aa84cd396377e54b760c | ||
languageName: node | ||
linkType: hard | ||
|
||
"typescript@patch:typescript@^4.2.4#builtin<compat/typescript>": | ||
version: 4.3.5 | ||
resolution: "typescript@patch:typescript@npm%3A4.3.5#builtin<compat/typescript>::version=4.3.5&hash=ddfc1b" | ||
bin: | ||
tsc: bin/tsc | ||
tsserver: bin/tsserver | ||
checksum: 7f0b8343f71ecac18095be1476b398aca420ab60dc207cc1efe078f381eef5527b80a518297720257114cdbda65612f8839e4b63e85dc95e67ac5cbbade8bdf0 | ||
languageName: node | ||
linkType: hard | ||
|
||
"yarn-v2-pnp@workspace:.": | ||
version: 0.0.0-use.local | ||
resolution: "yarn-v2-pnp@workspace:." | ||
dependencies: | ||
lodash: ^4.17.21 | ||
typescript: ^4.2.4 | ||
languageName: unknown | ||
linkType: soft |
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
Oops, something went wrong.
74ada11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
74ada11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
74ada11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AppVeyor has built the
win32 ia32
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally:
74ada11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.
Run this command to install the pre-release locally: