Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug when imported name contains assert #8

Merged
merged 1 commit into from
Jul 16, 2021
Merged

Conversation

riywo
Copy link
Contributor

@riywo riywo commented Jul 16, 2021

readToken checks after assert keyword, but it always true due to a bug.
This causes Unexpected token when the imported name contains assert.

fix preactjs/wmr#769

npm run test passes:

> [email protected] test
> mocha ./test/index.js

Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
ok 1 acorn-import-assertions should parse duplicated-key
ok 2 acorn-import-assertions should parse dynamic-import-async-expression
ok 3 acorn-import-assertions should parse dynamic-import-with-assert
ok 4 acorn-import-assertions should parse dynamic-import-without-assert
ok 5 acorn-import-assertions should parse export-statement-all-as-type
ok 6 acorn-import-assertions should parse export-statement-all-type
ok 7 acorn-import-assertions should parse export-statement-default-as-type
ok 8 acorn-import-assertions should parse export-statement-type
ok 9 acorn-import-assertions should parse export-statement-without-assertions
ok 10 acorn-import-assertions should parse keyword-in-ident
ok 11 acorn-import-assertions should parse keyword-without-space
ok 12 acorn-import-assertions should parse type
ok 13 acorn-import-assertions should parse unsupported-key
ok 14 acorn-import-assertions should parse unsupported-value
ok 15 acorn-import-assertions should parse without-assertions
# tests 15
# pass 15
# fail 0
1..15

Note: This is still not enough to cover import assert from "foo" yet.

`readToken` checks after `assert` keyword, but it always true due to a bug.
This causes `Unexpected token` when the imported name contains `assert`.
Copy link
Contributor

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Thank you so much for making a PR 🙌

@riywo
Copy link
Contributor Author

riywo commented Jul 16, 2021

Can anyone approve the workflow?

Copy link
Owner

@xtuc xtuc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

@xtuc xtuc merged commit 6627307 into xtuc:main Jul 16, 2021
@xtuc
Copy link
Owner

xtuc commented Jul 16, 2021

published [email protected] with the changes. i'll update in webpack

@xtuc
Copy link
Owner

xtuc commented Jul 16, 2021

Did more fixes in 5f4e814.

and released [email protected]

@riywo riywo deleted the fix-readtoken branch July 16, 2021 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unexpected token when wmr build with importing i18next
3 participants