-
Notifications
You must be signed in to change notification settings - Fork 741
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
We should error when a user tries to implement a durable object in a worker using the service-worker format #635
Comments
This was referenced Mar 18, 2022
caass
changed the title
We should error when trying durable objects from service-worker format
We should error when a user tries to implement a durable object in a worker using the service-worker format
Mar 18, 2022
threepointone
pushed a commit
that referenced
this issue
Mar 22, 2022
Durable Objects [require Module Workers](https://developers.cloudflare.com/workers/learning/migrating-to-module-workers/#advantages-of-migrating) to function, so we should error if we discover that a user is trying to use a durable object with a Service Worker. Closes #635
mrbbot
added a commit
that referenced
this issue
Oct 31, 2023
* Bump to `[email protected]` and `@microsoft/[email protected]` TypeScript 5 includes lots of goodies, and allows us to remove a bunch of `@ts-expect-error`s. * Set `"moduleResolution": "bundler"` in `tsconfig.json` This loosens some resolution rules in accordance with how bundlers like `esbuild` resolve modules. This also allows us to remove a bunch of `@ts-expect-error`s. * Remove import cycle in `src/plugins/r2` This probably wasn't a problem, but generally it's not great to have cyclic dependencies. For future reference, this was found with `npx madge --circular --extensions ts packages/miniflare/src`.
mrbbot
added a commit
that referenced
this issue
Nov 1, 2023
* Bump to `[email protected]` and `@microsoft/[email protected]` TypeScript 5 includes lots of goodies, and allows us to remove a bunch of `@ts-expect-error`s. * Set `"moduleResolution": "bundler"` in `tsconfig.json` This loosens some resolution rules in accordance with how bundlers like `esbuild` resolve modules. This also allows us to remove a bunch of `@ts-expect-error`s. * Remove import cycle in `src/plugins/r2` This probably wasn't a problem, but generally it's not great to have cyclic dependencies. For future reference, this was found with `npx madge --circular --extensions ts packages/miniflare/src`.
mrbbot
added a commit
that referenced
this issue
Nov 1, 2023
* Bump to `[email protected]` and `@microsoft/[email protected]` TypeScript 5 includes lots of goodies, and allows us to remove a bunch of `@ts-expect-error`s. * Set `"moduleResolution": "bundler"` in `tsconfig.json` This loosens some resolution rules in accordance with how bundlers like `esbuild` resolve modules. This also allows us to remove a bunch of `@ts-expect-error`s. * Remove import cycle in `src/plugins/r2` This probably wasn't a problem, but generally it's not great to have cyclic dependencies. For future reference, this was found with `npx madge --circular --extensions ts packages/miniflare/src`.
mrbbot
added a commit
that referenced
this issue
Nov 1, 2023
* Bump to `[email protected]` and `@microsoft/[email protected]` TypeScript 5 includes lots of goodies, and allows us to remove a bunch of `@ts-expect-error`s. * Set `"moduleResolution": "bundler"` in `tsconfig.json` This loosens some resolution rules in accordance with how bundlers like `esbuild` resolve modules. This also allows us to remove a bunch of `@ts-expect-error`s. * Remove import cycle in `src/plugins/r2` This probably wasn't a problem, but generally it's not great to have cyclic dependencies. For future reference, this was found with `npx madge --circular --extensions ts packages/miniflare/src`.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From @Electroid:
I tried a quick implementation (#634) but actually I think this is maybe more complex than a simple fix like that.
We currently guess the worker format by checking for exports in the bundled code generated by esbuild. If there are no exports, then the worker is service-worker format. If there are some, it's a module worker.
The issue I'm running into is that a Durable Object implementation will contain an export, necessarily. So checking for the existence of exports is kind of not enough to cover this case, cause what if the user writes code like the following:
Edit:
I have been informed that by virtue of having an
export
statement, this code is actually an ESModule, and will error with "no default export" or some such when attempting to publish. So it's actually reasonable to keep the current logic, and just check if there's ascript_name
as Ashcon suggested.The text was updated successfully, but these errors were encountered: