From 30fd331bf1be413cab2191a90f3592ae8718d171 Mon Sep 17 00:00:00 2001 From: "Alex Lam S.L" Date: Wed, 5 Jun 2024 03:55:16 +0300 Subject: [PATCH] workaround `node` & `npm` issues (#5825) - upgrade GitHub Actions dependencies - workaround `sucrase` issues --- .github/workflows/build.yml | 2 +- .github/workflows/ci.yml | 4 ++-- .github/workflows/ufuzz.yml | 2 +- test/jetstream.js | 5 ++++- test/release/install.sh | 3 ++- test/release/sucrase.sh | 37 ++++++++++++++++++++++++++++--------- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5f92e7e4c67..19443ef7d16 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: OPTIONS: ${{ matrix.options }} SCRIPT: ${{ matrix.script }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Perform uglify, build & test shell: bash run: | diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0e49efca03b..7570b0f0f23 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,8 +17,8 @@ jobs: TYPE: ${{ matrix.script }} UGLIFY_GITHUB_LAG: 10000 steps: - - uses: actions/checkout@v3 - - uses: actions/cache@v3 + - uses: actions/checkout@v4 + - uses: actions/cache@v4 with: path: tmp key: tmp ${{ matrix.script }} diff --git a/.github/workflows/ufuzz.yml b/.github/workflows/ufuzz.yml index 43b6ed55479..47cd3143b7b 100644 --- a/.github/workflows/ufuzz.yml +++ b/.github/workflows/ufuzz.yml @@ -32,7 +32,7 @@ jobs: env: NODE: ${{ matrix.node }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Perform fuzzing shell: bash run: | diff --git a/test/jetstream.js b/test/jetstream.js index f5d91a13758..efd342cf8cf 100644 --- a/test/jetstream.js +++ b/test/jetstream.js @@ -63,7 +63,10 @@ if (typeof phantom == "undefined") { function npm(args, done) { args.push("--loglevel=error"); - child_process.spawn(cmd, args, { stdio: [ "ignore", 1, 2 ] }).on("exit", done); + child_process.spawn(cmd, args, { + shell: true, + stdio: [ "ignore", 1, 2 ], + }).on("exit", done); } (function install() { diff --git a/test/release/install.sh b/test/release/install.sh index 955fcf3ea8d..2fb9b919370 100755 --- a/test/release/install.sh +++ b/test/release/install.sh @@ -50,7 +50,8 @@ node --version npm config set audit false npm config set fund false npm config set loglevel error -npm config set optional false +npm config set omit optional || true +npm config set optional false || true npm config set save false npm config set strict-ssl false npm config set update-notifier false diff --git a/test/release/sucrase.sh b/test/release/sucrase.sh index 07b0aa8064a..b5dc94e1a27 100755 --- a/test/release/sucrase.sh +++ b/test/release/sucrase.sh @@ -35,18 +35,27 @@ npm_install() { done } +workaround() { + FILE="$1" + echo 'Monkey patching' $FILE + CODE=`cat $FILE` + sed -E 's/for ?\((var [^;{]+;)/\1for\(;/g' > $FILE < { @@ -57,11 +66,11 @@ rm -rf tmp/sucrase \ - () => buildIntegration("./integrations/webpack-loader"), - () => buildIntegration("./integrations/webpack-object-rest-spread-plugin"), - () => buildWebsite(), -@@ -66,3 +59,0 @@ async function buildSucrase(): Promise { +@@ -62,3 +55,0 @@ async function buildSucrase(): Promise { - // Also add in .d.ts files from tsc, which only need to be compiled once. - await run(\`\${TSC} --project ./src --outDir ./dist-types\`); -- await mergeDirectoryContents("./dist-types/src", "./dist"); -@@ -70 +61 @@ async function buildSucrase(): Promise { +- await mergeDirectoryContents("./dist-types/src", "./dist/types"); +@@ -66 +57 @@ async function buildSucrase(): Promise { - await run("yarn link"); + await run("npm link"); --- a/src/identifyShadowedGlobals.ts @@ -70,28 +79,38 @@ rm -rf tmp/sucrase \ +export { identifyShadowedGlobals as HACK }; --- a/src/parser/tokenizer/state.ts +++ b/src/parser/tokenizer/state.ts -@@ -100,0 +101 @@ export default class State { +@@ -106,0 +107 @@ export default class State { +export { State as HACK }; --- a/src/transformers/JSXTransformer.ts +++ b/src/transformers/JSXTransformer.ts -@@ -253,0 +254 @@ export default class JSXTransformer extends Transformer { +@@ -560,0 +561 @@ export default class JSXTransformer extends Transformer { +export { JSXTransformer as HACK }; --- a/src/util/getClassInfo.ts +++ b/src/util/getClassInfo.ts -@@ -164,0 +165 @@ export default function getClassInfo( +@@ -195,0 +196 @@ export default function getClassInfo( +export { getClassInfo as HACK }; --- a/src/util/getDeclarationInfo.ts +++ b/src/util/getDeclarationInfo.ts @@ -40,0 +41 @@ export default function getDeclarationInfo(tokens: TokenProcessor): DeclarationI +export { getDeclarationInfo as HACK }; +--- a/src/util/getImportExportSpecifierInfo.ts ++++ b/src/util/getImportExportSpecifierInfo.ts +@@ -87,0 +88 @@ export default function getImportExportSpecifierInfo( ++export { getImportExportSpecifierInfo as HACK }; --- a/src/util/getJSXPragmaInfo.ts +++ b/src/util/getJSXPragmaInfo.ts @@ -14,0 +15 @@ export default function getJSXPragmaInfo(options: Options): JSXPragmaInfo { +export { getJSXPragmaInfo as HACK }; +--- a/test/source-maps-test.ts ++++ b/test/source-maps-test.ts +@@ -26,0 +27 @@ var _a = require('./a'); var _a2 = _interopRequireDefault(_a); ++delete result.sourceMap.ignoreList; EOF ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi npm_install esbuild-wasm@0.8.56 \ && minify_in_situ "src" \ +&& workaround src/parser/plugins/typescript.ts\ +&& workaround src/transformers/CJSImportTransformer.ts\ && rm -rf node_modules \ && npm_install \ && npm run clean \