diff --git a/scripts/binary/binary-cleanup.js b/scripts/binary/binary-cleanup.js index 31a48b6c5b56..8cd8b1a9008a 100644 --- a/scripts/binary/binary-cleanup.js +++ b/scripts/binary/binary-cleanup.js @@ -52,7 +52,7 @@ const getDependencyPathsToKeep = async (buildAppDir) => { require.resolve('webpack-dev-server', { paths: [buildAppDir] }), require.resolve('html-webpack-plugin-4', { paths: [buildAppDir] }), require.resolve('html-webpack-plugin-5', { paths: [buildAppDir] }), - // This is a dynamic import swizzle that needs to happen in the reporter + // These involve dynamic requires that are not resolved by esbuild. They need to be kept in the binary. require.resolve('mocha-7.0.1', { paths: [buildAppDir] }), // These dependencies are completely dynamic using the pattern `require(`./${name}`)` and will not be pulled in by esbuild but still need to be kept in the binary. ...['ibmi', @@ -125,9 +125,11 @@ const cleanup = async (buildAppDir) => { // 3. Remove all dependencies that are in the snapshot but not in the list of kept dependencies from the binary await Promise.all(potentiallyRemovedDependencies.map(async (dependency) => { - // marionette-client requires all of its dependencies in a very non-standard dynamic way. We will keep anything in marionette-client - if (!keptDependencies.includes(dependency.slice(2)) && !dependency.includes('marionette-client')) { - await fs.remove(path.join(buildAppDir, dependency.replace(/.ts$/, '.js'))) + const typeScriptlessDependency = dependency.replace(/\.ts$/, '.js') + + // marionette-client and babel/runtime require all of their dependencies in a very non-standard dynamic way. We will keep anything in marionette-client and babel/runtime + if (!keptDependencies.includes(typeScriptlessDependency.slice(2)) && !typeScriptlessDependency.includes('marionette-client') && !typeScriptlessDependency.includes('@babel/runtime')) { + await fs.remove(path.join(buildAppDir, typeScriptlessDependency)) } }))