Skip to content

Conversation

MattiasBuelens
Copy link
Contributor

This way the file is still parsed as a module, even though it doesn't import or export anything. 😉

@jakearchibald jakearchibald merged commit b8f7f94 into jakearchibald:master May 30, 2019
@jakearchibald
Copy link
Owner

Nice. I was staying away from things that were 'meaningful' to JavaScript, but seems like this is removed from the output too.

@MattiasBuelens
Copy link
Contributor Author

It's... interesting. The input is a module, but the output could be parsed as a module or as a script. You might expect TypeScript to add export {} to the output to ensure it's unambiguously a module, see microsoft/TypeScript#28890. If that happened, then our workaround would turn our output into a module which means we would have to load it differently, e.g. with new Worker("...", { type: "module" }).

Let's hope TypeScript fixes the worker types first, so we can get rid of this workaround altogether. 😅

@jakearchibald
Copy link
Owner

If it happens the other way around, I guess exporting a type will still work.

@MattiasBuelens
Copy link
Contributor Author

I don't know. If a file contains only type exports, can that only be used as a module? Or should it also be usable as a script? 🤷‍♂

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.

2 participants