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

Dynamic import syntax errors in 5.3 #17478

Closed
7 tasks done
cyanzhong opened this issue Jun 14, 2024 · 2 comments · Fixed by #17479
Closed
7 tasks done

Dynamic import syntax errors in 5.3 #17478

cyanzhong opened this issue Jun 14, 2024 · 2 comments · Fixed by #17479

Comments

@cyanzhong
Copy link

cyanzhong commented Jun 14, 2024

Describe the bug

There might be a dup closed issue but I suspect I've found more.

I am providing two examples, both from https://github.com/codemirror/language-data but simplified.

// Expected ',', got '[' (Note that you need plugins to import files that are not JavaScript)
function expectedCommaGotSquareBracket(dialect: string) {
  return import("./modules/sql").then(m => m.sql({dialect: (m as any)[dialect]}))
}

// Expected ident (Note that you need plugins to import files that are not JavaScript)
function expectedIdent() {
  return import("./modules/javascript").then(m => m.javascript({jsx: true}))
}

Both can be worked around by translating to async await forms, highly possible to be related to #14221.

Reproduction

...

Steps to reproduce

No response

System Info

System:
    OS: macOS 14.5
    CPU: (10) arm64 Apple M1 Max
    Memory: 8.01 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v20.12.2/bin/yarn
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    pnpm: 9.3.0 - ~/.nvm/versions/node/v20.12.2/bin/pnpm
  Browsers:
    Edge: 126.0.2592.56
    Safari: 17.5

Used Package Manager

yarn

Logs

No response

Validations

@bluwy
Copy link
Member

bluwy commented Jun 14, 2024

Thanks for the code examples. I figured out the bug. The sql({dialect: (m as any)[dialect] part, which has ({ .... } was tripping out the regex. Will fix this.

@mxschmitt
Copy link

Thank you! (this fixes also Playwright component testing)

@github-actions github-actions bot locked and limited conversation to collaborators Jul 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants