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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update next-swc handling for PR stats #50876

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions .github/actions/next-stats-action/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const mainRepoDir = path.join(workDir, 'main-repo')
const diffRepoDir = path.join(workDir, 'diff-repo')
const statsAppDir = path.join(workDir, 'stats-app')
const diffingDir = path.join(workDir, 'diff')
const yarnEnvValues = {
YARN_CACHE_FOLDER: path.join(workDir, 'yarn-cache'),
}
const allowedConfigLocations = [
'./',
'.stats-app',
Expand All @@ -25,6 +22,5 @@ module.exports = {
mainRepoDir,
diffRepoDir,
statsAppDir,
yarnEnvValues,
allowedConfigLocations,
}
5 changes: 3 additions & 2 deletions .github/actions/next-stats-action/src/prepare/repo-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ module.exports = (actionInfo) => {
}
const pkgData = require(pkgDataPath)
const { name } = pkgData

pkgDatas.set(name, {
pkgDataPath,
pkg,
Expand All @@ -103,7 +104,7 @@ module.exports = (actionInfo) => {
if (!pkgData.files) {
pkgData.files = []
}
pkgData.files.push('native/*')
pkgData.files.push('native')
require('console').log(
'using swc binaries: ',
await exec(`ls ${path.join(path.dirname(pkgDataPath), 'native')}`)
Expand All @@ -124,7 +125,7 @@ module.exports = (actionInfo) => {
pkgData.dependencies['@next/swc'] =
pkgDatas.get('@next/swc').packedPkgPath
} else {
pkgData.files.push('native/*')
pkgData.files.push('native')
}
}
}
Expand Down
25 changes: 5 additions & 20 deletions .github/actions/next-stats-action/src/run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const logger = require('../util/logger')
const getDirSize = require('./get-dir-size')
const collectStats = require('./collect-stats')
const collectDiffs = require('./collect-diffs')
const { statsAppDir, diffRepoDir, yarnEnvValues } = require('../constants')
const { statsAppDir, diffRepoDir } = require('../constants')

async function runConfigs(
configs = [],
Expand Down Expand Up @@ -59,13 +59,7 @@ async function runConfigs(

const buildStart = Date.now()
console.log(
await exec(
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
false,
{
env: yarnEnvValues,
}
)
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false)
)
curStats.General.buildDuration = Date.now() - buildStart

Expand Down Expand Up @@ -160,13 +154,7 @@ async function runConfigs(

const secondBuildStart = Date.now()
console.log(
await exec(
`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`,
false,
{
env: yarnEnvValues,
}
)
await exec(`cd ${statsAppDir} && ${statsConfig.appBuildCommand}`, false)
)
curStats.General.buildDurationCached = Date.now() - secondBuildStart
}
Expand Down Expand Up @@ -203,14 +191,11 @@ async function linkPkgs(pkgDir = '', pkgPaths) {
}
await fs.writeFile(pkgJsonPath, JSON.stringify(pkgData, null, 2), 'utf8')

await fs.remove(yarnEnvValues.YARN_CACHE_FOLDER)
await exec(
`cd ${pkgDir} && pnpm install --strict-peer-dependencies=false`,
false,
{
env: yarnEnvValues,
}
false
)
await exec(`cd ${pkgDir} && find node_modules | grep swc`)
ijjk marked this conversation as resolved.
Show resolved Hide resolved
}

module.exports = runConfigs
1 change: 1 addition & 0 deletions .github/workflows/pull_request_stats.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ env:
NEXT_SKIP_NATIVE_POSTINSTALL: 1
TEST_TIMINGS_TOKEN: ${{ secrets.TEST_TIMINGS_TOKEN }}
NEXT_TEST_JOB: 1
NEXT_DISABLE_SWC_WASM: 1

jobs:
build:
Expand Down
13 changes: 8 additions & 5 deletions packages/next/src/build/swc/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,13 @@ export async function loadBindings(): Promise<any> {
}

let attempts: any[] = []
const shouldLoadWasmFallbackFirst = triples.some(
(triple: any) =>
!!triple?.raw && knownDefaultWasmFallbackTriples.includes(triple.raw)
)
const disableWasmFallback = process.env.NEXT_DISABLE_SWC_WASM
const shouldLoadWasmFallbackFirst =
!disableWasmFallback &&
triples.some(
(triple: any) =>
!!triple?.raw && knownDefaultWasmFallbackTriples.includes(triple.raw)
)

if (shouldLoadWasmFallbackFirst) {
const fallbackBindings = await tryLoadWasmWithFallback(
Expand All @@ -117,7 +120,7 @@ export async function loadBindings(): Promise<any> {
}

// For these platforms we already tried to load wasm and failed, skip reattempt
if (!shouldLoadWasmFallbackFirst) {
if (!shouldLoadWasmFallbackFirst && !disableWasmFallback) {
const fallbackBindings = await tryLoadWasmWithFallback(
attempts,
isCustomTurbopack
Expand Down