Skip to content

Commit

Permalink
workaround node & npm issues (#5825)
Browse files Browse the repository at this point in the history
- upgrade GitHub Actions dependencies
- workaround `sucrase` issues
  • Loading branch information
alexlamsl authored Jun 5, 2024
1 parent f0ca9cf commit 30fd331
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ufuzz.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
env:
NODE: ${{ matrix.node }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Perform fuzzing
shell: bash
run: |
Expand Down
5 changes: 4 additions & 1 deletion test/jetstream.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
3 changes: 2 additions & 1 deletion test/release/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 28 additions & 9 deletions test/release/sucrase.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
$CODE
EOF
}

rm -rf tmp/sucrase \
&& git clone https://github.com/alangpierce/sucrase.git tmp/sucrase \
&& cd tmp/sucrase \
&& rm -rf .git/hooks \
&& git checkout 38b66f3009feb76750a799deea211adcc83574f1 \
&& git checkout 7284b3733aa114b3f4f5371e36ff5a4704ec860e \
&& patch -l -p1 <<EOF
--- a/package.json
+++ b/package.json
@@ -25 +24,0 @@
- "prepublishOnly": "yarn clean && yarn build",
@@ -65 +63,0 @@
- "test262-harness": "^6.5.0",
@@ -69 +67,0 @@
- "test262-harness": "^10.0.0",
--- a/script/build.ts
+++ b/script/build.ts
@@ -16 +15,0 @@ async function main(): Promise<void> {
Expand All @@ -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<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.
- await run(\`\${TSC} --project ./src --outDir ./dist-types\`);
- await mergeDirectoryContents("./dist-types/src", "./dist");
@@ -70 +61 @@ async function buildSucrase(): Promise<void> {
- await mergeDirectoryContents("./dist-types/src", "./dist/types");
@@ -66 +57 @@ async function buildSucrase(): Promise<void> {
- await run("yarn link");
+ await run("npm link");
--- a/src/identifyShadowedGlobals.ts
Expand All @@ -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 \
Expand Down

0 comments on commit 30fd331

Please sign in to comment.