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

Deno Support #87

Closed
wants to merge 28 commits into from
Closed

Conversation

KnorpelSenf
Copy link
Contributor

Deno Support

This is an attempt to migrate the module to Deno, and to use dnt to build a Node module from the code again.

So far, this is very much not usable. There are a number of challenges that are hard to solve. If anyone has an idea how to tackle them, please comment below. Until then, this PR will peacefully rot here for a while in draft state.

Pending Tasks

  • This requires --unstable to be used, because we have dependencies via esm.sh which use the Node compat libs internally. See Deno support #85 for alternatives that could work around this.
  • The imported socket.io client has no type safety.
  • It's hard to believe, but there seems to be no way to upload files via FormData without reading them into memory first. A possible workaround would be to implement the multipart/form-data protocol in JS and then upload this stream. But who really wants to do that?
  • The Node module is created via dnt which means that the emitted code requires Node>=16.
  • The tests are not migrated yet. They should use the Deno test API. This is not hard, just a little bit of effort, but given the above things, I did not bother yet.
  • I did not try out any of this yet. But at least it compiles for both runtimes :)
  • The README file is outdated now

Further Notes

This PR completely removes all Node config, and migrates to Deno tooling. As a result, this PR has a huge diff. However, most commits are not that interesting actually. The complete diff of code changes can be seen in 3064ff6.

Development works like this:

  • deno task check - perform typechecking
  • deno task build - build Node module from Deno code
  • deno task test && deno task test-integration - run tests
  • deno fmt - format source code
  • deno lint lint source code

Closes #85.

@KnorpelSenf
Copy link
Contributor Author

This proves to be too difficult to justify the effort. It seems like socket.io actually ships Deno support now (see socketio/socket.io#3600 (comment)), however, Deno also ships support for npm packages soon. This is still a bit experimental, but with the --unstable flag, one can do this:

import CloudConvert from 'npm:cloudconvert'

const cloudConvert = new CloudConvert('api_key');

let job = await cloudConvert.jobs.create({
    tasks: {
        'import-my-file': {
            operation: 'import/url',
            url: 'https://my-url'
        },
        'convert-my-file': {
            operation: 'convert',
            input: 'import-my-file',
            output_format: 'pdf',
            some_other_option: 'value'
        },
        'export-my-file': {
            operation: 'export/url',
            input: 'convert-my-file'
        }
    }
});

Hence, I will close this.

@KnorpelSenf KnorpelSenf mentioned this pull request Sep 25, 2022
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.

Deno support
1 participant