-
Notifications
You must be signed in to change notification settings - Fork 673
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
wrangler publish fails when ESModule is used #252
Comments
I can confirm this bug. The error is being thrown here: https://github.com/cloudflare/wrangler2/blob/65f9904936a11dad8fef599242e0590bb5b7431a/packages/wrangler/src/publish.ts#L142 |
You can work around this by providing the entry-point script at the command line: npm wrangler publish index.js |
I think this might already be fixed in main after #196, but we should verify |
#196 didn't help. |
Working on a fix... |
The `publish` command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file. This was because we were using the `metafile.inputs` to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match. This fix avoids this by using the fact that the `metadata.outputs` object will only contain one element that has the `entrypoint` property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements. Fixes cloudflare#252
The `publish` command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file. This was because we were using the `metafile.inputs` to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match. This fix avoids this by using the fact that the `metadata.outputs` object will only contain one element that has the `entrypoint` property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements. Fixes cloudflare#252
Hitting this right now as well. The temp fix doesn't seem to work - same error. Is there another workaround? |
We just published a fix, could you try again with |
wow awesome! Worked great - thanks a million |
The `publish` command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file. This was because we were using the `metafile.inputs` to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match. This fix avoids this by using the fact that the `metadata.outputs` object will only contain one element that has the `entrypoint` property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements. Fixes cloudflare#252
The `publish` command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file. This was because we were using the `metafile.inputs` to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match. This fix avoids this by using the fact that the `metadata.outputs` object will only contain one element that has the `entrypoint` property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements. Fixes cloudflare#252
The `publish` command was failing when the entry-point was specified in the wrangler.toml file and the entry-point imported another file. This was because we were using the `metafile.inputs` to guess the entry-point file path. But the order in which the source-files were added to this object was not well defined, and so we could end up failing to find a match. This fix avoids this by using the fact that the `metadata.outputs` object will only contain one element that has the `entrypoint` property - and then using that as the entry-point path. For runtime safety, we now assert that there cannot be zero or multiple such elements. Fixes #252
Hello,
I got this error when publishing my ESModule project:
Cannot read properties of undefined (reading '1')
I reproduce the issue with the following files:
test.js
another.js
wragnler.toml
And then run
npx wrangler@beta publish
The issue does not exist if
another.js
is not imported. I am not sure this is a bug or it is because v2 is still in beta and ESModule is not yet supportedThank you.
The text was updated successfully, but these errors were encountered: