feat: Bundle cy.origin() dependencies at runtime (#25626)

Co-authored-by: cypress-bot[bot] <2f0651858c6e38e0+cypress-bot[bot]@users.noreply.github.com>
Co-authored-by: Ryan Manuel <ryanm@cypress.io>
This commit is contained in:
Chris Breiding
2023-02-13 11:59:29 -05:00
committed by GitHub
parent 2bfeb5302c
commit 41512c416a
46 changed files with 3309 additions and 1200 deletions

View File

@@ -41,6 +41,7 @@ const getDependencyPathsToKeep = async (buildAppDir) => {
'packages/server/lib/plugins/child/require_async_child.js',
'packages/server/lib/plugins/child/register_ts_node.js',
'packages/rewriter/lib/threads/worker.js',
'node_modules/@cypress/webpack-batteries-included-preprocessor/index.js',
'node_modules/webpack/lib/webpack.js',
'node_modules/webpack-dev-server/lib/Server.js',
'node_modules/html-webpack-plugin-4/index.js',
@@ -83,6 +84,7 @@ const getDependencyPathsToKeep = async (buildAppDir) => {
'pnpapi',
'@swc/core',
'emitter',
'ts-loader',
],
})
@@ -128,10 +130,12 @@ const createServerEntryPointBundle = async (buildAppDir) => {
],
})
// eslint-disable-next-line no-console
console.log(`copying server entry point bundle from ${path.join(workingDir, 'index.js')} to ${path.join(buildAppDir, 'packages', 'server', 'index.js')}`)
await fs.copy(path.join(workingDir, 'index.js'), path.join(buildAppDir, 'packages', 'server', 'index.js'))
// eslint-disable-next-line no-console
console.log(`compiling server entry point bundle to ${path.join(buildAppDir, 'packages', 'server', 'index.jsc')}`)
// Use bytenode to compile the entry point bundle. This will save time on the v8 compile step and ensure the integrity of the entry point
@@ -165,6 +169,7 @@ const buildEntryPointAndCleanup = async (buildAppDir) => {
...serverEntryPointBundleDependencies,
]
// eslint-disable-next-line no-console
console.log(`potentially removing ${potentiallyRemovedDependencies.length} dependencies`)
// 4. Remove all dependencies that are in the snapshot but not in the list of kept dependencies from the binary