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

swc_bundler: does not support top level await import statements #1112

Closed
kitsonk opened this issue Sep 26, 2020 · 5 comments
Closed

swc_bundler: does not support top level await import statements #1112

kitsonk opened this issue Sep 26, 2020 · 5 comments
Assignees
Labels
Milestone

Comments

@kitsonk
Copy link
Contributor

kitsonk commented Sep 26, 2020

Describe the bug

swc_bundler does not appear to handle top level await import statements

Input code

example4.ts

const a = await import("./a.ts");

console.log(a);

a.ts

export const a = "a";

Expected behavior

A valid emit of some sort.

Actual, using the swc_bundler branch/PR:

❯ deno bundle example4.ts example4.bundle.js
Bundle file:///bundle-examples/example4.ts
error: failed to bundle

Version

Version: swc_bundler 0.7.4

Additional context

Working to integrate swc_bundler into Deno.

@kitsonk kitsonk added the C-bug label Sep 26, 2020
@kdy1 kdy1 added this to the v1.2.35 milestone Sep 27, 2020
@kdy1
Copy link
Member

kdy1 commented Sep 27, 2020

I fixed other issues but I have a question about this issue.

Is this an issue about dynamic import itself?

@kitsonk
Copy link
Contributor Author

kitsonk commented Sep 27, 2020

I don't know specifically, but it threw an error on what is legitimate code. I didn't dig deeper. If we aren't going to inline dynamic imports (current deno bundle does for most dynamic imports, but that is because it preserves the module structure in the bundle) then I would at least expect them to be preserved in the output.

@kdy1
Copy link
Member

kdy1 commented Sep 27, 2020

Got it, thanks for clarification.

kdy1 added a commit to kdy1/swc that referenced this issue Sep 27, 2020
@kdy1
Copy link
Member

kdy1 commented Sep 27, 2020

I checked that following .swcrc works.

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "dynamicImport": true
    },
    "target": "es2020"
  }
}

As you are using it from rust, you need to provide recent version of ecmascript to the parser via JscTarget. You also need TsConfig.dynamic_import to be true.

@kdy1 kdy1 closed this as completed Sep 27, 2020
@kdy1 kdy1 self-assigned this Sep 27, 2020
@swc-bot
Copy link
Collaborator

swc-bot commented Oct 26, 2022

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Oct 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

3 participants