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 bundle should support type checking worker scripts #8219

Closed
nekdolan opened this issue Nov 1, 2020 · 8 comments
Closed

deno bundle should support type checking worker scripts #8219

nekdolan opened this issue Nov 1, 2020 · 8 comments
Assignees
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) needs discussion this topic needs further discussion to determine what action to take

Comments

@nekdolan
Copy link

nekdolan commented Nov 1, 2020

When I try to bundle my worker.ts it raises an error

error: TS2339 [ERROR]: Property 'postMessage' does not exist on type 'Window & typeof globalThis'.
        self.postMessage(data);

Code

self.postMessage(data);

In Deno

deno 1.5.1
v8 8.7.220.3
typescript 4.0.3
@kitsonk
Copy link
Contributor

kitsonk commented Nov 1, 2020

We need to think about this more, but there are two workarounds.

> deno bundle --no-check

Or:

> deno bundle --config tsconfig.json

Where the tsconfig.json contains:

{
  "compilerOptions": {
    "lib": [ "deno.worker" ]
  }
}

@kitsonk kitsonk added cli related to cli/ dir needs investigation requires further investigation before determining if it is an issue or not labels Nov 1, 2020
@nekdolan
Copy link
Author

nekdolan commented Nov 2, 2020

Thanks @kitsonk deno bundle --no-check works

@kitsonk kitsonk added feat new feature (which has been agreed to/accepted) needs discussion this topic needs further discussion to determine what action to take and removed needs investigation requires further investigation before determining if it is an issue or not labels Nov 6, 2020
@kitsonk kitsonk changed the title Deno bundle can't compile worker files deno bundle should support type checking worker scripts Nov 6, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Nov 6, 2020

Actually, I realised I made a comment in the code.

// TODO(@kitsonk) support bundling for workers

Ultimately we just need to agree on how to deal with this. @ry @bartlomieju thoughts?

@nayeemrmn
Copy link
Collaborator

This is basically #6753 (deno cache --worker), the flag would be shared like similar ones are.

@kitsonk
Copy link
Contributor

kitsonk commented Nov 6, 2020

@nayeemrmn you are right as usual... deno bundle --worker is what it should be, nothing to debate... I forgot we had agreed that for deno cache.

@kitsonk kitsonk removed the needs discussion this topic needs further discussion to determine what action to take label Nov 6, 2020
@kitsonk kitsonk self-assigned this Nov 6, 2020
@kitsonk
Copy link
Contributor

kitsonk commented Nov 6, 2020

Actually based on #8089 there is clearly things to discuss...

@kitsonk kitsonk added the needs discussion this topic needs further discussion to determine what action to take label Nov 6, 2020
@nekdolan
Copy link
Author

nekdolan commented Nov 6, 2020

I'm not sure how it could be done without the proposed/reverted flag --worker . I can understand that cache could work without it but how would you keep the linkage when you bundle them, given that you don't know where or how the scripts will be deployed? Would it just keep a relative link to the bundled worker in the script? Would that work on a normal webpage? Not being able to give a name to the bundled worker file would also be an issue.

@lucacasonato
Copy link
Member

deno bundle was removed in Deno 2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli related to cli/ dir feat new feature (which has been agreed to/accepted) needs discussion this topic needs further discussion to determine what action to take
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants