Skip to content

Use empty export list instead of unused export #4

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

Merged
merged 1 commit into from
May 30, 2019
Merged

Use empty export list instead of unused export #4

merged 1 commit into from
May 30, 2019

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