Skip to content

Bundle everything into the npm module #1260

Open

Description

@kddnewton

See this issue: #1232 for details.

I'm not entirely sure how to solve this, but I know it will involve adding a prepublishOnly step to the package.json that's going to use bundler to dump all of the necessary files into the package somehow.

Activity

  1. JounQin commented on Jul 23, 2022

    @JounQin
    Member

    Is that possible to compile Ruby as WASM?

  2. kddnewton commented on Jul 23, 2022

    @kddnewton
    MemberAuthor
  3. JounQin commented on Jul 23, 2022

    @JounQin
    Member

    Why not try it out right now?

    https://www.ruby-lang.org/en/news/2022/04/03/ruby-3-2-0-preview1-released/

    Is there anything preventing us?

    When it's already compiled into WASM, no ruby runtime is required.

  4. kddnewton commented on Jul 26, 2022

    @kddnewton
    MemberAuthor

    Right... I don't know what I was talking about. I will try this!

  5. JounQin commented on Jul 26, 2022

    @JounQin
    Member

    Besides, in case of handling asynchronous due to WASM, you can try https://github.com/un-ts/synckit to turn it synchronously again!

  6. kddnewton commented on Aug 5, 2022

    @kddnewton
    MemberAuthor

    So this now works in https://github.com/ruby-syntax-tree/node-syntax-tree. Except that it doesn't support RBS yet, because it's very difficult to compile non-bundled native extensions: https://twitter.com/kateinoigakukun/status/1555202638064799750?s=20&t=9wXaP7QoPngehSIujvUGFw.

    The other difficulty is that loading WASM requires an async call, so we still are blocked on that. Fortunately that's changing in v3 of prettier prettier/prettier#13142.

    I think the answer for now is going to be waiting for prettier v3 and waiting on/working on support for non-bundled native extensions for WASI.

  7. JounQin commented on Aug 5, 2022

    @JounQin
    Member

    Besides, in case of handling asynchronous due to WASM, you can try https://github.com/un-ts/synckit to turn it synchronously again!

    @kddnewton Did you tried this one? Of course waiting for prettier@v3 is another solution. 😅

  8. kddnewton commented on Aug 5, 2022

    @kddnewton
    MemberAuthor

    @JounQin I did! I couldn't get it to work. To be honest I'm not sure what I was doing wrong, but it would just hang no matter what I tried.

  9. JounQin commented on Aug 5, 2022

    @JounQin
    Member

    @JounQin I did! I couldn't get it to work. To be honest I'm not sure what I was doing wrong, but it would just hang no matter what I tried.

    @kddnewton Can you provide a branch so I can offer some help?

    At least you can try SYNCKIT_TIMEOUT env to see what's wrong.

    And the problem may be fixed by un-ts/synckit#94

  10. kddnewton commented on Aug 10, 2022

    @kddnewton
    MemberAuthor
  11. JounQin commented on Aug 10, 2022

    @JounQin
    Member

    I haven't looked into details yet, but the root issue could be

    23f2089#diff-598b75d6dc772eb13aa7141f35bb93046ae26c58a97e8647ecf7f74aec8ae93fR2

    It does not need/should be called immediately

    - const parseSync = createSyncFn(require.resolve("./worker"))();
    + const parseSync = createSyncFn(require.resolve("./worker"));

    I'll clone and check quickly.

  12. kddnewton commented on Aug 10, 2022

    @kddnewton
    MemberAuthor

    Nice, now I'm just getting some cloning errors.

  13. kddnewton commented on Aug 10, 2022

    @kddnewton
    MemberAuthor

    Okay @JounQin we're back to hanging now

  14. JounQin commented on Aug 10, 2022

    @JounQin
    Member

    Nice, now I'm just getting some cloning errors.

    See

    You must make sure, the result is serializable by Structured Clone Algorithm


    Besides, you'd better upgrade to synckit@0.8.2 which propagates sync errors from worker, it'll handle some unexpected sync errors.

  15. JounQin commented on Aug 10, 2022

    @JounQin
    Member

    @kddnewton

    f1d1937#diff-a19812fe5175f5ae8fccdf2c9400b66ea4408f519c4208fded5ae4c3365cac4dR1

    - const { runAsWorker } = require("synckit/lib/index.cjs");
    + const { runAsWorker } = require("synckit");
  16. 3 remaining items

  17. kddnewton commented on Sep 19, 2022

    @kddnewton
    MemberAuthor

    Yes please! If you could help me get https://github.com/ruby-syntax-tree/node-syntax-tree to compile the RBS plugin as well - which is the only blocker, then I could ship this using the WASM code and it would be totally good to go.

  18. kddnewton commented on Oct 18, 2022

    @kddnewton
    MemberAuthor

    Moving this issue over to node-syntax-tree here: ruby-syntax-tree/node-syntax-tree#43.

  19. JounQin commented on Nov 20, 2023

    @JounQin
    Member

    I saw ruby-syntax-tree/node-syntax-tree#43 is marked as completed, but https://github.com/ruby-syntax-tree/node-syntax-tree itself is archived, is this supported already? @kddnewton

  20. kddnewton commented on Nov 20, 2023

    @kddnewton
    MemberAuthor

    Not really - I'm just giving up on that possibility to be honest. The issue is RBS compilation into WASM. If someone figures that out, we can make it happen. But at the same time I'm working on replacing the backend of syntax tree to use prism, so we'll be using a different form of compilation for that.

  21. JounQin commented on Nov 20, 2023

    @JounQin
    Member

    I'd like to give it a try when I'm free. Can you assign this issue to me and reopen it?

    Reference https://ruby.github.io/ruby.wasm

  22. kddnewton commented on Nov 21, 2023

    @kddnewton
    MemberAuthor

    Done

  23. kddnewton commented on Jan 29, 2024

    @kddnewton
    MemberAuthor

    @alan-pie I'm not sure what you mean. This is an enhancement, the plugin itself functions just fine.

  24. JounQin commented on Jan 30, 2024

    @JounQin
    Member

    There're 3 options, dropping is the worst, I'm going to add this feature while I'm focusing on other projects these days.

    Plaese be patient, or even better, join to help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions