developit / microbundle

📦 Zero-configuration bundler for tiny modules.
https://npm.im/microbundle
MIT License
8.06k stars 361 forks source link

Cannot read property 'value' of undefined #873

Open make-github-pseudonymous-again opened 3 years ago

make-github-pseudonymous-again commented 3 years ago

I am getting some interestingly erroneous builds for code relying on AsyncIterable and AsyncIterator. Steps to reproduce:

git clone https://github.com/async-abstraction/tape
cd tape
yarn
yarn test # This works fine
sed 's/[/][s][r][c][/][i][n][d][e][x][.][j][s]/\/dist\/index.modern.js/g' -i test/src/*.js
yarn test # Works fine too
git reset --hard HEAD
sed 's/[/][s][r][c][/][i][n][d][e][x][.][j][s]/\/dist\/index.module.js/g' -i test/src/*.js
yarn test # BROKEN (Cannot read property 'value' of undefined)
git reset --hard HEAD
sed 's/[/][s][r][c][/][i][n][d][e][x][.][j][s]/\/dist\/index.cjs/g' -i test/src/*.js
yarn test # BROKEN (Cannot read property 'value' of undefined)
make-github-pseudonymous-again commented 3 years ago

Any idea if #565 or https://github.com/developit/microbundle/pull/707#pullrequestreview-472310599 is related?

make-github-pseudonymous-again commented 3 years ago

I see here that babel-plugin-transform-async-to-promises does not support async generators. Is this plugin still used? Is the logic to transpile async generators missing?

make-github-pseudonymous-again commented 2 years ago

Still getting the error. I managed to write a GitHub worflow to automate testing all builds of async-abstraction/tape. You can see the error here.

make-github-pseudonymous-again commented 2 years ago

I created a minimal bug reproduction repository at https://github.com/bisectifiate/microbundle-async-generator with a workflow that automates testing of the source and the built bundles.

make-github-pseudonymous-again commented 2 years ago

I managed to get @async-abstraction/tape to work by replacing a bunch of for await ... syntax by await iterator.next() syntax, but that's not all that is needed. I hit some issues with switch statements, similar to #505, most notably non-working fall-through logic. I also hit my head on while ((await f()) !== x);. Will update the minimal bug reproduction.

EDIT: I updated https://github.com/bisectifiate/microbundle-async-generator with the one-liner while ... await example. I could not reproduce the switch fall-through