From d838e458f48d1312eea98f083f73854ea8599d62 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 30 Nov 2021 14:11:45 -0800 Subject: [PATCH 01/13] Attempt to load native binaries before wasm --- packages/next/build/swc/index.js | 68 ++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 975490a4c5e8aad..16b8f124f94c7ba 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -1,21 +1,46 @@ import { platform, arch } from 'os' import { platformArchTriples } from '@napi-rs/triples' -import Log from '../output/log' +import * as Log from '../output/log' const ArchName = arch() const PlatformName = platform() const triples = platformArchTriples[PlatformName][ArchName] || [] async function loadBindings() { - return (await loadWasm()) || loadNative() + let bindings = loadNative() + if (bindings) { + return bindings + } + + bindings = await loadWasm() + if (bindings) { + return bindings + } + + logLoadFailure() +} + +function loadBindingsSync() { + let bindings = loadNative() + if (bindings) { + return bindings + } + + logLoadFailure() +} + +function logLoadFailure() { + Log.error( + `Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc` + ) + process.exit(1) } async function loadWasm() { - // Try to load wasm bindings - for (let specifier of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { + for (let pkg of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { try { - let bindings = await import(specifier) - if (specifier === '@next/swc-wasm-web') { + let bindings = await import(pkg) + if (pkg === '@next/swc-wasm-web') { bindings = await bindings.default() } return { @@ -34,30 +59,22 @@ async function loadWasm() { function loadNative() { let bindings - let loadError for (const triple of triples) { try { bindings = require(`@next/swc/native/next-swc.${triple.platformArchABI}.node`) Log.info('Using locally built binary of @next/swc') break - } catch (e) { - if (e?.code !== 'MODULE_NOT_FOUND') { - loadError = e - } - } + } catch (e) {} } if (!bindings) { for (const triple of triples) { + let pkg = `@next/swc-${triple.platformArchABI}` try { - bindings = require(`@next/swc-${triple.platformArchABI}`) + bindings = require(pkg) break - } catch (e) { - if (e?.code !== 'MODULE_NOT_FOUND') { - loadError = e - } - } + } catch (e) {} } } @@ -118,15 +135,6 @@ function loadNative() { }, } } - - if (loadError) { - console.error(loadError) - } - - Log.error( - `Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc` - ) - process.exit(1) } function toBuffer(t) { @@ -139,7 +147,7 @@ export async function transform(src, options) { } export function transformSync(src, options) { - let bindings = loadNative() + let bindings = loadBindingsSync() return bindings.transformSync(src, options) } @@ -149,11 +157,11 @@ export async function minify(src, options) { } export function minifySync(src, options) { - let bindings = loadNative() + let bindings = loadBindingsSync() return bindings.minifySync(src, options) } export async function bundle(options) { - let bindings = loadNative() + let bindings = loadBindingsSync() return bindings.bundle(toBuffer(options)) } From e00e9538f00891f5a55573353a31fef04232647f Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 30 Nov 2021 18:14:15 -0800 Subject: [PATCH 02/13] Log attempts to load binaries if none are found --- packages/next/build/swc/index.js | 58 +++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 13 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 16b8f124f94c7ba..83200354f66a6b9 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -7,29 +7,39 @@ const PlatformName = platform() const triples = platformArchTriples[PlatformName][ArchName] || [] async function loadBindings() { - let bindings = loadNative() - if (bindings) { - return bindings + let attempts = [] + try { + return loadNative() + } catch (a) { + attempts = attempts.concat(a) } - bindings = await loadWasm() - if (bindings) { + try { + let bindings = await loadWasm() return bindings + } catch (a) { + attempts = attempts.concat(a) } - logLoadFailure() + logLoadFailure(attempts) } function loadBindingsSync() { - let bindings = loadNative() - if (bindings) { - return bindings + let attempts = [] + try { + return loadNative() + } catch (a) { + attempts = attempts.concat(a) } - logLoadFailure() + logLoadFailure(attempts) } -function logLoadFailure() { +function logLoadFailure(attempts) { + for (let attempt of attempts) { + Log.info(attempt) + } + Log.error( `Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc` ) @@ -37,6 +47,7 @@ function logLoadFailure() { } async function loadWasm() { + let attempts = [] for (let pkg of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { try { let bindings = await import(pkg) @@ -53,12 +64,23 @@ async function loadWasm() { return Promise.resolve(bindings.minifySync(src.toString(), options)) }, } - } catch (e) {} + } catch (e) { + if (e?.code === 'ERR_MODULE_NOT_FOUND') { + attempts.push(`Attempted to load ${pkg}, but it was not installed`) + } else { + attempts.push( + `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}` + ) + } + } } + + throw attempts } function loadNative() { let bindings + let attempts = [] for (const triple of triples) { try { @@ -74,7 +96,15 @@ function loadNative() { try { bindings = require(pkg) break - } catch (e) {} + } catch (e) { + if (e?.code === 'MODULE_NOT_FOUND') { + attempts.push(`Attempted to load ${pkg}, but it was not installed`) + } else { + attempts.push( + `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}` + ) + } + } } } @@ -135,6 +165,8 @@ function loadNative() { }, } } + + throw attempts } function toBuffer(t) { From f393275e6b3576b97348a86c06ffe18b7471785d Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 30 Nov 2021 18:53:39 -0800 Subject: [PATCH 03/13] Disable wasm loading for now --- packages/next/build/swc/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 83200354f66a6b9..d1be03d2359ad98 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -14,12 +14,13 @@ async function loadBindings() { attempts = attempts.concat(a) } - try { - let bindings = await loadWasm() - return bindings - } catch (a) { - attempts = attempts.concat(a) - } + // TODO: reenable once working + // try { + // let bindings = await loadWasm() + // return bindings + // } catch (a) { + // attempts = attempts.concat(a) + // } logLoadFailure(attempts) } From 5437b3b8cc8e983084081716d9afc4cc2b496aee Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 30 Nov 2021 18:56:58 -0800 Subject: [PATCH 04/13] Add platform/arch to error message --- packages/next/build/swc/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index d1be03d2359ad98..02e906634aa5d1b 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -42,7 +42,7 @@ function logLoadFailure(attempts) { } Log.error( - `Failed to load SWC binary, see more info here: https://nextjs.org/docs/messages/failed-loading-swc` + `Failed to load SWC binary for ${PlatformName}/${ArchName}, see more info here: https://nextjs.org/docs/messages/failed-loading-swc` ) process.exit(1) } From a09e90b4140159c3a1ec264737a8dc84ce2fdd6f Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Tue, 30 Nov 2021 18:59:02 -0800 Subject: [PATCH 05/13] Fix lint --- packages/next/build/swc/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 02e906634aa5d1b..4b2cf8ea9cf2f49 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -47,6 +47,7 @@ function logLoadFailure(attempts) { process.exit(1) } +// eslint-disable-next-line async function loadWasm() { let attempts = [] for (let pkg of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { From bb20191b723bc461963a87873a852e7819d7ce98 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Thu, 2 Dec 2021 09:59:47 -0800 Subject: [PATCH 06/13] Enable wasm loading again --- packages/next/build/swc/index.js | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 800786effeb0733..04d1f240d339040 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -14,13 +14,12 @@ async function loadBindings() { attempts = attempts.concat(a) } - // TODO: reenable once working - // try { - // let bindings = await loadWasm() - // return bindings - // } catch (a) { - // attempts = attempts.concat(a) - // } + try { + let bindings = await loadWasm() + return bindings + } catch (a) { + attempts = attempts.concat(a) + } logLoadFailure(attempts) } @@ -68,13 +67,14 @@ async function loadWasm() { }, } } catch (e) { - if (e?.code === 'ERR_MODULE_NOT_FOUND') { - attempts.push(`Attempted to load ${pkg}, but it was not installed`) - } else { - attempts.push( - `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}` - ) - } + // Do not report attempts to load wasm when it is still experimental + // if (e?.code === 'ERR_MODULE_NOT_FOUND') { + // attempts.push(`Attempted to load ${pkg}, but it was not installed`) + // } else { + // attempts.push( + // `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}` + // ) + // } } } From 73b772aa150f854a4e8c3f879b17ef02b50b03c6 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Thu, 2 Dec 2021 14:28:06 -0800 Subject: [PATCH 07/13] wasm test wip --- .github/workflows/build_test_deploy.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 1ae728400430bd5..78a49ded04becac 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -631,6 +631,25 @@ jobs: - run: cd packages/next-swc && cargo test if: ${{ steps.docs-change.outputs.DOCS_CHANGE != 'docs only change' }} + test-wasm: + name: Test the wasm build + runs-on: ubuntu-18.04 + #needs: build-wasm + + steps: + - uses: actions/cache@v2 + id: restore-build + with: + path: ./* + key: ${{ github.sha }} + + # - uses: actions/download-artifact@v2 + # with: + # name: wasm-binaries + # path: packages/next-swc/crates/wasm + + - run: ls ./node_modules/@next + # Build binaries for publishing build-native: needs: build From c1d0b02e7689317003a7eb2b522530dac14be47e Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Fri, 3 Dec 2021 11:13:29 -0800 Subject: [PATCH 08/13] Test wasm build against production fixture --- .github/workflows/build_test_deploy.yml | 34 +++++++++++++++---- scripts/setup-wasm.mjs | 21 ++++++++++++ .../integration/production/test/index.test.js | 10 ++++-- 3 files changed, 56 insertions(+), 9 deletions(-) create mode 100644 scripts/setup-wasm.mjs diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 78a49ded04becac..a22ba010261d62b 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -634,21 +634,41 @@ jobs: test-wasm: name: Test the wasm build runs-on: ubuntu-18.04 - #needs: build-wasm + needs: [build, build-native-dev, build-wasm] steps: - uses: actions/cache@v2 + if: ${{needs.build.outputs.docsChange != 'docs only change'}} id: restore-build with: path: ./* key: ${{ github.sha }} - # - uses: actions/download-artifact@v2 - # with: - # name: wasm-binaries - # path: packages/next-swc/crates/wasm + - uses: actions/download-artifact@v2 + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + with: + name: wasm-binaries + path: packages/next-swc/crates/wasm + + - uses: actions/download-artifact@v2 + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + with: + name: next-swc-dev-binary + path: packages/next-swc/native + + # node version needs to be 16+ to use --no-addons option + - name: Setup node + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + uses: actions/setup-node@v2 + with: + node-version: 16 + check-latest: true - - run: ls ./node_modules/@next + - run: node ./scripts/setup-wasm.mjs + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + + - run: TEST_WASM=true yarn testonly test/integration/production/test/index.test.js + if: ${{needs.build.outputs.docsChange != 'docs only change'}} # Build binaries for publishing build-native: @@ -1142,7 +1162,7 @@ jobs: build-wasm: needs: build - if: ${{ needs.build.outputs.isRelease == 'true' }} + # if: ${{ needs.build.outputs.isRelease == 'true' }} strategy: matrix: target: [web, nodejs] diff --git a/scripts/setup-wasm.mjs b/scripts/setup-wasm.mjs new file mode 100644 index 000000000000000..720cd8930163860 --- /dev/null +++ b/scripts/setup-wasm.mjs @@ -0,0 +1,21 @@ +import path from 'path' +import { readFile, writeFile } from 'fs/promises' +import { copy } from 'fs-extra' +;(async function () { + let wasmDir = path.join(process.cwd(), 'packages/next-swc/crates/wasm') + let wasmTarget = 'nodejs' + let wasmPkg = JSON.parse( + await readFile(path.join(wasmDir, `pkg-${wasmTarget}/package.json`)) + ) + wasmPkg.name = `@next/swc-wasm-${wasmTarget}` + + await writeFile( + path.join(wasmDir, `pkg-${wasmTarget}/package.json`), + JSON.stringify(wasmPkg, null, 2) + ) + + await copy( + path.join(wasmDir, `pkg-${wasmTarget}`), + path.join(process.cwd(), `node_modules/@next/swc-wasm-${wasmTarget}`) + ) +})() diff --git a/test/integration/production/test/index.test.js b/test/integration/production/test/index.test.js index 4c887a89ab97558..04a28433f9f037e 100644 --- a/test/integration/production/test/index.test.js +++ b/test/integration/production/test/index.test.js @@ -38,10 +38,16 @@ const context = {} describe('Production Usage', () => { let output = '' beforeAll(async () => { - const result = await nextBuild(appDir, undefined, { + let opts = { stderr: true, stdout: true, - }) + } + if (process.env.TEST_WASM) { + opts.env = { + NODE_OPTIONS: '--no-addons', + } + } + const result = await nextBuild(appDir, undefined, opts) appPort = await findPort() context.appPort = appPort From 31c638885beecbe8ed1b544b193f52190dd88586 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Fri, 3 Dec 2021 12:25:45 -0800 Subject: [PATCH 09/13] Memoize loadWasm and loadNative --- packages/next/build/swc/index.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index 04d1f240d339040..a911120766ec857 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -6,6 +6,9 @@ const ArchName = arch() const PlatformName = platform() const triples = platformArchTriples[PlatformName][ArchName] || [] +let nativeBindings +let wasmBindings + async function loadBindings() { let attempts = [] try { @@ -48,6 +51,10 @@ function logLoadFailure(attempts) { // eslint-disable-next-line async function loadWasm() { + if (wasmBindings) { + return wasmBindings + } + let attempts = [] for (let pkg of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { try { @@ -55,7 +62,8 @@ async function loadWasm() { if (pkg === '@next/swc-wasm-web') { bindings = await bindings.default() } - return { + Log.info('Using experimental wasm build of next-swc') + wasmBindings = { isWasm: true, transform(src, options) { return Promise.resolve( @@ -66,6 +74,7 @@ async function loadWasm() { return Promise.resolve(bindings.minifySync(src.toString(), options)) }, } + return wasmBindings } catch (e) { // Do not report attempts to load wasm when it is still experimental // if (e?.code === 'ERR_MODULE_NOT_FOUND') { @@ -82,6 +91,10 @@ async function loadWasm() { } function loadNative() { + if (nativeBindings) { + return nativeBindings + } + let bindings let attempts = [] @@ -112,7 +125,7 @@ function loadNative() { } if (bindings) { - return { + nativeBindings = { isWasm: false, transform(src, options) { const isModule = @@ -168,6 +181,7 @@ function loadNative() { return bindings.bundle(toBuffer(options)) }, } + return nativeBindings } throw attempts From cf4f0db974b53fdbd6aef2ba3f01814e393ce4a7 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Fri, 3 Dec 2021 15:01:58 -0800 Subject: [PATCH 10/13] Setup playwright --- .github/workflows/build_test_deploy.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index a22ba010261d62b..a68f75d9d2bda94 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -664,6 +664,9 @@ jobs: node-version: 16 check-latest: true + - run: npm i -g playwright-chromium@1.14.1 && npx playwright install-deps + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + - run: node ./scripts/setup-wasm.mjs if: ${{needs.build.outputs.docsChange != 'docs only change'}} From 73a0ce65879d49dcb65dc43b3190f8d147c1d057 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Fri, 3 Dec 2021 17:46:24 -0800 Subject: [PATCH 11/13] Try run-tests.js --- .github/workflows/build_test_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index a68f75d9d2bda94..d0c2af1ca741e45 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -670,7 +670,7 @@ jobs: - run: node ./scripts/setup-wasm.mjs if: ${{needs.build.outputs.docsChange != 'docs only change'}} - - run: TEST_WASM=true yarn testonly test/integration/production/test/index.test.js + - run: TEST_WASM=true xvfb-run node run-tests.js test/integration/production/test/index.test.js if: ${{needs.build.outputs.docsChange != 'docs only change'}} # Build binaries for publishing From 78505dc3f9753c5e5666e28ed9b26c5f5394037b Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Mon, 6 Dec 2021 11:04:07 -0800 Subject: [PATCH 12/13] Cleanup --- packages/next/build/swc/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/packages/next/build/swc/index.js b/packages/next/build/swc/index.js index a911120766ec857..74014aee82ffd4a 100644 --- a/packages/next/build/swc/index.js +++ b/packages/next/build/swc/index.js @@ -49,14 +49,13 @@ function logLoadFailure(attempts) { process.exit(1) } -// eslint-disable-next-line async function loadWasm() { if (wasmBindings) { return wasmBindings } let attempts = [] - for (let pkg of ['@next/swc-wasm-web', '@next/swc-wasm-nodejs']) { + for (let pkg of ['@next/swc-wasm-nodejs', '@next/swc-wasm-web']) { try { let bindings = await import(pkg) if (pkg === '@next/swc-wasm-web') { From 6ab251620f6a231039cff82b4ca80e9857694fd1 Mon Sep 17 00:00:00 2001 From: Maia Teegarden Date: Mon, 6 Dec 2021 11:26:09 -0800 Subject: [PATCH 13/13] Add dev wasm build --- .github/workflows/build_test_deploy.yml | 72 +++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_test_deploy.yml b/.github/workflows/build_test_deploy.yml index 0fa1b4e450415a1..35f425d4f2d01e4 100644 --- a/.github/workflows/build_test_deploy.yml +++ b/.github/workflows/build_test_deploy.yml @@ -718,7 +718,7 @@ jobs: test-wasm: name: Test the wasm build runs-on: ubuntu-18.04 - needs: [build, build-native-dev, build-wasm] + needs: [build, build-native-dev, build-wasm-dev] steps: - uses: actions/cache@v2 @@ -731,8 +731,10 @@ jobs: - uses: actions/download-artifact@v2 if: ${{needs.build.outputs.docsChange != 'docs only change'}} with: - name: wasm-binaries - path: packages/next-swc/crates/wasm + name: wasm-dev-binary + path: packages/next-swc/crates/wasm/pkg-nodejs + + - run: ls packages/next-swc/crates/wasm - uses: actions/download-artifact@v2 if: ${{needs.build.outputs.docsChange != 'docs only change'}} @@ -1249,7 +1251,7 @@ jobs: build-wasm: needs: build - # if: ${{ needs.build.outputs.isRelease == 'true' }} + if: ${{ needs.build.outputs.isRelease == 'true' }} strategy: matrix: target: [web, nodejs] @@ -1297,4 +1299,64 @@ jobs: name: wasm-binaries path: packages/next-swc/crates/wasm/pkg-* - - run: ls packages/next-swc/crates/wasm + build-wasm-dev: + needs: build + runs-on: ubuntu-latest + steps: + - uses: actions/cache@v2 + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + id: restore-build + with: + path: ./* + key: ${{ github.sha }}-${{ github.run_number }}-${{ github.run_attempt }} + + - name: Setup node + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + uses: actions/setup-node@v2 + with: + node-version: 14 + + - name: Install Rust + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly-2021-11-15 + override: true + target: wasm32-unknown-unknown + + - name: Cache + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + uses: actions/cache@v2 + with: + path: | + ~/.cargo/ + **/target/ + key: ${{ runner.os }}-publish-integration + + - name: Cache wasm binary + if: ${{needs.build.outputs.docsChange != 'docs only change'}} + id: binary-cache + uses: actions/cache@v2 + with: + path: packages/next-swc/crates/wasm/pkg-nodejs + key: dev-wasm-next-swc-nightly-2021-11-15-${{ hashFiles('.github/workflows/build_test_deploy.yml', 'packages/next-swc/**') }} + + - name: Install wasm-pack + if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Build + if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + run: (wasm-pack build packages/next-swc/crates/wasm --dev --scope=next --target nodejs) + + - name: Add target to folder name + if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + run: mv packages/next-swc/crates/wasm/pkg packages/next-swc/crates/wasm/pkg-nodejs + + - name: Upload artifact + if: ${{needs.build.outputs.docsChange != 'docs only change' && steps.binary-cache.outputs.cache-hit != 'true'}} + uses: actions/upload-artifact@v2 + with: + name: wasm-dev-binary + path: packages/next-swc/crates/wasm/pkg-nodejs