mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-29 19:41:16 -05:00
fix: ensure cypress in cypress uses prod dependencies from the snapshot (#25164)
This commit is contained in:
@@ -103,6 +103,7 @@ jobs:
|
||||
git stash push -- ${{ env.SNAPSHOT_FILES }}
|
||||
git reset --hard
|
||||
git checkout ${{ env.BRANCH_NAME }}
|
||||
git pull origin ${{ env.BRANCH_NAME }}
|
||||
git merge --squash -Xtheirs stash
|
||||
## Update available and a PR doesn't already exist
|
||||
- name: Checkout new branch
|
||||
|
||||
@@ -2,23 +2,35 @@ import { hookRequire } from '@packages/server/hook-require'
|
||||
|
||||
hookRequire({ forceTypeScript: false })
|
||||
|
||||
// Important!!! Ensure to import the prod dependencies (i.e. things that will be executing from the inner Cypress of Cypress in Cypress)
|
||||
// from ./prod-dependencies.ts as this is pre-loaded in the v8 snapshot via ./v8-snapshot-entry.ts. Otherwise, these dependencies
|
||||
// will not properly be marked as loaded in the v8 snapshot and may be reloaded when referenced from within the snapshot itself.
|
||||
import {
|
||||
getOperationName,
|
||||
Response,
|
||||
makeGraphQLServer,
|
||||
clearCtx,
|
||||
DataContext,
|
||||
globalPubSub,
|
||||
setCtx,
|
||||
buildSchema,
|
||||
execute,
|
||||
ExecutionResult,
|
||||
GraphQLError,
|
||||
parse,
|
||||
} from './prod-dependencies'
|
||||
|
||||
import path from 'path'
|
||||
import execa from 'execa'
|
||||
|
||||
import type { CyTaskResult, OpenGlobalModeOptions, RemoteGraphQLInterceptor, ResetOptionsResult, WithCtxInjected, WithCtxOptions } from '../support/e2e'
|
||||
import { fixtureDirs } from '@tooling/system-tests'
|
||||
// import type { CloudExecuteRemote } from '@packages/data-context/src/sources'
|
||||
import { makeGraphQLServer } from '@packages/graphql/src/makeGraphQLServer'
|
||||
import { clearCtx, DataContext, globalPubSub, setCtx } from '@packages/data-context'
|
||||
import * as inspector from 'inspector'
|
||||
import sinonChai from '@cypress/sinon-chai'
|
||||
import sinon from 'sinon'
|
||||
import fs from 'fs-extra'
|
||||
import { buildSchema, execute, ExecutionResult, GraphQLError, parse } from 'graphql'
|
||||
import { Response } from 'cross-fetch'
|
||||
|
||||
import { CloudQuery } from '@packages/graphql/test/stubCloudTypes'
|
||||
import { getOperationName } from '@urql/core'
|
||||
import pDefer from 'p-defer'
|
||||
|
||||
const pkg = require('@packages/root')
|
||||
@@ -90,7 +102,7 @@ async function makeE2ETasks () {
|
||||
// require'd from @packages/server & @tooling/system-tests so we don't import
|
||||
// types which would pollute strict type checking
|
||||
const argUtils = require('@packages/server/lib/util/args')
|
||||
const { makeDataContext } = require('@packages/server/lib/makeDataContext')
|
||||
const { makeDataContext } = require('./prod-dependencies')
|
||||
const Fixtures = require('@tooling/system-tests') as FixturesShape
|
||||
const { scaffoldCommonNodeModules, scaffoldProjectNodeModules } = require('@tooling/system-tests/lib/dep-installer')
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
export { makeGraphQLServer } from '@packages/graphql/src/makeGraphQLServer'
|
||||
|
||||
export { clearCtx, DataContext, globalPubSub, setCtx } from '@packages/data-context'
|
||||
|
||||
export { buildSchema, execute, ExecutionResult, GraphQLError, parse } from 'graphql'
|
||||
|
||||
export { Response } from 'cross-fetch'
|
||||
|
||||
export { getOperationName } from '@urql/core'
|
||||
|
||||
export const makeDataContext = require('@packages/server/lib/makeDataContext').makeDataContext
|
||||
@@ -0,0 +1 @@
|
||||
import './prod-dependencies'
|
||||
+5
-3
@@ -46,6 +46,7 @@
|
||||
"./packages/config/node_modules/@babel/traverse/lib/path/introspection.js",
|
||||
"./packages/data-context/node_modules/debug/src/node.js",
|
||||
"./packages/data-context/node_modules/minimatch/minimatch.js",
|
||||
"./packages/data-context/src/DataContext.ts",
|
||||
"./packages/graphql/node_modules/debug/src/node.js",
|
||||
"./packages/https-proxy/lib/ca.js",
|
||||
"./packages/net-stubbing/node_modules/debug/src/node.js",
|
||||
@@ -654,7 +655,6 @@
|
||||
"./packages/data-context/node_modules/readdirp/index.js",
|
||||
"./packages/data-context/node_modules/supports-color/index.js",
|
||||
"./packages/data-context/src/DataActions.ts",
|
||||
"./packages/data-context/src/DataContext.ts",
|
||||
"./packages/data-context/src/actions/DataEmitterActions.ts",
|
||||
"./packages/data-context/src/actions/EventCollectorActions.ts",
|
||||
"./packages/data-context/src/actions/MigrationActions.ts",
|
||||
@@ -871,7 +871,7 @@
|
||||
"./packages/server/lib/util/fs.ts",
|
||||
"./packages/server/lib/util/glob.js",
|
||||
"./packages/server/lib/util/proxy.ts",
|
||||
"./packages/server/lib/util/resourceTypeAndCredentialManager.ts",
|
||||
"./packages/server/lib/util/requestedWithAndCredentialManager.ts",
|
||||
"./packages/server/lib/util/socket_allowed.ts",
|
||||
"./packages/server/lib/util/stream_buffer.ts",
|
||||
"./packages/server/lib/video_capture.ts",
|
||||
@@ -953,7 +953,8 @@
|
||||
"./packages/socket/node_modules/socket.io/node_modules/engine.io/lib/transports/polling.js",
|
||||
"./packages/socket/node_modules/socket.io/node_modules/engine.io/lib/transports/websocket.js",
|
||||
"./packages/ts/register.js",
|
||||
"./packages/types/index.js"
|
||||
"./packages/types/index.js",
|
||||
"./tooling/v8-snapshot/dist/setup/v8-snapshot-entry-cy-in-cy.js"
|
||||
],
|
||||
"healthy": [
|
||||
"./node_modules/@babel/code-frame/lib/index.js",
|
||||
@@ -3607,6 +3608,7 @@
|
||||
"./packages/extension/index.js",
|
||||
"./packages/extension/lib/extension.js",
|
||||
"./packages/extension/lib/util.js",
|
||||
"./packages/frontend-shared/cypress/e2e/v8-snapshot-entry.ts",
|
||||
"./packages/graphql/node_modules/chalk/source/templates.js",
|
||||
"./packages/graphql/node_modules/chalk/source/util.js",
|
||||
"./packages/graphql/node_modules/debug/node_modules/ms/index.js",
|
||||
|
||||
@@ -3,5 +3,5 @@ process.env.DEBUG = process.env.DEBUG ?? 'cypress:snapgen:info'
|
||||
const { setupV8Snapshots } = require('../dist/setup')
|
||||
|
||||
if (!['1', 'true'].includes(process.env.DISABLE_SNAPSHOT_REQUIRE)) {
|
||||
setupV8Snapshots()
|
||||
setupV8Snapshots({ supportCypressInCypress: true })
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ const platformString = process.platform
|
||||
const snapshotCacheBaseDir = path.resolve(__dirname, '..', '..', 'cache')
|
||||
|
||||
const projectBaseDir = path.join(__dirname, '..', '..', '..', '..')
|
||||
const appEntryFile = require.resolve('@packages/server/v8-snapshot-entry')
|
||||
|
||||
const cypressAppSnapshotDir = (cypressAppPath?: string) => {
|
||||
const electronPackageDir = path.join(projectBaseDir, 'packages', 'electron')
|
||||
@@ -74,10 +73,12 @@ export function createConfig ({
|
||||
env = 'prod',
|
||||
cypressAppPath,
|
||||
integrityCheckSource,
|
||||
supportCypressInCypress,
|
||||
}: {
|
||||
env?: 'dev' | 'prod'
|
||||
cypressAppPath?: string
|
||||
integrityCheckSource: string | undefined
|
||||
supportCypressInCypress?: boolean
|
||||
}): SnapshotConfig {
|
||||
/**
|
||||
* If true only node_module dependencies are included in the snapshot. Otherwise app files are included as well
|
||||
@@ -86,6 +87,7 @@ export function createConfig ({
|
||||
*/
|
||||
const nodeModulesOnly = env === 'dev'
|
||||
const minify = !process.env.V8_SNAPSHOT_DISABLE_MINIFY && env === 'prod'
|
||||
const appEntryFile = supportCypressInCypress ? require.resolve('./v8-snapshot-entry-cy-in-cy') : require.resolve('./v8-snapshot-entry')
|
||||
|
||||
const snapshotCacheDir = getSnapshotCacheDir()
|
||||
|
||||
|
||||
@@ -5,10 +5,10 @@ import minimist from 'minimist'
|
||||
import { generateEntry } from './generate-entry'
|
||||
import { installSnapshot } from './install-snapshot'
|
||||
|
||||
const setupV8Snapshots = async ({ cypressAppPath, integrityCheckSource }: { cypressAppPath?: string, integrityCheckSource?: string} = {}) => {
|
||||
const setupV8Snapshots = async ({ cypressAppPath, integrityCheckSource, supportCypressInCypress }: { cypressAppPath?: string, integrityCheckSource?: string, supportCypressInCypress?: boolean} = {}) => {
|
||||
try {
|
||||
const args = minimist(process.argv.slice(2))
|
||||
const config = createConfig({ env: args.env, cypressAppPath, integrityCheckSource })
|
||||
const config = createConfig({ env: args.env, cypressAppPath, integrityCheckSource, supportCypressInCypress })
|
||||
|
||||
await consolidateDeps(config)
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
import '@packages/server/v8-snapshot-entry'
|
||||
import '@packages/frontend-shared/cypress/e2e/v8-snapshot-entry'
|
||||
@@ -0,0 +1 @@
|
||||
import '@packages/server/v8-snapshot-entry'
|
||||
Reference in New Issue
Block a user