workaround node & npm issues (#5825)

- upgrade GitHub Actions dependencies
- workaround `sucrase` issues
This commit is contained in:
Alex Lam S.L
2024-06-05 03:55:16 +03:00
committed by GitHub
parent f0ca9cfbe6
commit 30fd331bf1
6 changed files with 38 additions and 15 deletions

View File

@@ -50,7 +50,7 @@ jobs:
OPTIONS: ${{ matrix.options }} OPTIONS: ${{ matrix.options }}
SCRIPT: ${{ matrix.script }} SCRIPT: ${{ matrix.script }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Perform uglify, build & test - name: Perform uglify, build & test
shell: bash shell: bash
run: | run: |

View File

@@ -17,8 +17,8 @@ jobs:
TYPE: ${{ matrix.script }} TYPE: ${{ matrix.script }}
UGLIFY_GITHUB_LAG: 10000 UGLIFY_GITHUB_LAG: 10000
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- uses: actions/cache@v3 - uses: actions/cache@v4
with: with:
path: tmp path: tmp
key: tmp ${{ matrix.script }} key: tmp ${{ matrix.script }}

View File

@@ -32,7 +32,7 @@ jobs:
env: env:
NODE: ${{ matrix.node }} NODE: ${{ matrix.node }}
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Perform fuzzing - name: Perform fuzzing
shell: bash shell: bash
run: | run: |

View File

@@ -63,7 +63,10 @@ if (typeof phantom == "undefined") {
function npm(args, done) { function npm(args, done) {
args.push("--loglevel=error"); 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() { (function install() {

View File

@@ -50,7 +50,8 @@ node --version
npm config set audit false npm config set audit false
npm config set fund false npm config set fund false
npm config set loglevel error 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 save false
npm config set strict-ssl false npm config set strict-ssl false
npm config set update-notifier false npm config set update-notifier false

View File

@@ -35,18 +35,27 @@ npm_install() {
done done
} }
workaround() {
FILE="$1"
echo 'Monkey patching' $FILE
CODE=`cat $FILE`
sed -E 's/for ?\((var [^;{]+;)/\1for\(;/g' > $FILE <<EOF
$CODE
EOF
}
rm -rf tmp/sucrase \ rm -rf tmp/sucrase \
&& git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \ && git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \
&& cd tmp/sucrase \ && cd tmp/sucrase \
&& rm -rf .git/hooks \ && rm -rf .git/hooks \
&& git checkout 38b66f3009feb76750a799deea211adcc83574f1 \ && git checkout 7284b3733aa114b3f4f5371e36ff5a4704ec860e \
&& patch -l -p1 <<EOF && patch -l -p1 <<EOF
--- a/package.json --- a/package.json
+++ b/package.json +++ b/package.json
@@ -25 +24,0 @@ @@ -25 +24,0 @@
- "prepublishOnly": "yarn clean && yarn build", - "prepublishOnly": "yarn clean && yarn build",
@@ -65 +63,0 @@ @@ -69 +67,0 @@
- "test262-harness": "^6.5.0", - "test262-harness": "^10.0.0",
--- a/script/build.ts --- a/script/build.ts
+++ b/script/build.ts +++ b/script/build.ts
@@ -16 +15,0 @@ async function main(): Promise<void> { @@ -16 +15,0 @@ async function main(): Promise<void> {
@@ -57,11 +66,11 @@ rm -rf tmp/sucrase \
- () => buildIntegration("./integrations/webpack-loader"), - () => buildIntegration("./integrations/webpack-loader"),
- () => buildIntegration("./integrations/webpack-object-rest-spread-plugin"), - () => buildIntegration("./integrations/webpack-object-rest-spread-plugin"),
- () => buildWebsite(), - () => buildWebsite(),
@@ -66,3 +59,0 @@ async function buildSucrase(): Promise<void> { @@ -62,3 +55,0 @@ async function buildSucrase(): Promise<void> {
- // Also add in .d.ts files from tsc, which only need to be compiled once. - // Also add in .d.ts files from tsc, which only need to be compiled once.
- await run(\`\${TSC} --project ./src --outDir ./dist-types\`); - await run(\`\${TSC} --project ./src --outDir ./dist-types\`);
- await mergeDirectoryContents("./dist-types/src", "./dist"); - await mergeDirectoryContents("./dist-types/src", "./dist/types");
@@ -70 +61 @@ async function buildSucrase(): Promise<void> { @@ -66 +57 @@ async function buildSucrase(): Promise<void> {
- await run("yarn link"); - await run("yarn link");
+ await run("npm link"); + await run("npm link");
--- a/src/identifyShadowedGlobals.ts --- a/src/identifyShadowedGlobals.ts
@@ -70,28 +79,38 @@ rm -rf tmp/sucrase \
+export { identifyShadowedGlobals as HACK }; +export { identifyShadowedGlobals as HACK };
--- a/src/parser/tokenizer/state.ts --- a/src/parser/tokenizer/state.ts
+++ b/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 }; +export { State as HACK };
--- a/src/transformers/JSXTransformer.ts --- a/src/transformers/JSXTransformer.ts
+++ b/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 }; +export { JSXTransformer as HACK };
--- a/src/util/getClassInfo.ts --- a/src/util/getClassInfo.ts
+++ b/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 }; +export { getClassInfo as HACK };
--- a/src/util/getDeclarationInfo.ts --- a/src/util/getDeclarationInfo.ts
+++ b/src/util/getDeclarationInfo.ts +++ b/src/util/getDeclarationInfo.ts
@@ -40,0 +41 @@ export default function getDeclarationInfo(tokens: TokenProcessor): DeclarationI @@ -40,0 +41 @@ export default function getDeclarationInfo(tokens: TokenProcessor): DeclarationI
+export { getDeclarationInfo as HACK }; +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 --- a/src/util/getJSXPragmaInfo.ts
+++ b/src/util/getJSXPragmaInfo.ts +++ b/src/util/getJSXPragmaInfo.ts
@@ -14,0 +15 @@ export default function getJSXPragmaInfo(options: Options): JSXPragmaInfo { @@ -14,0 +15 @@ export default function getJSXPragmaInfo(options: Options): JSXPragmaInfo {
+export { getJSXPragmaInfo as HACK }; +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 EOF
ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi ERR=$?; if [ "$ERR" != "0" ]; then echo "Error: $ERR"; exit $ERR; fi
npm_install esbuild-wasm@0.8.56 \ npm_install esbuild-wasm@0.8.56 \
&& minify_in_situ "src" \ && minify_in_situ "src" \
&& workaround src/parser/plugins/typescript.ts\
&& workaround src/transformers/CJSImportTransformer.ts\
&& rm -rf node_modules \ && rm -rf node_modules \
&& npm_install \ && npm_install \
&& npm run clean \ && npm run clean \