-
Notifications
You must be signed in to change notification settings - Fork 125
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
add next-dev internal-package #486
add next-dev internal-package #486
Conversation
|
0917efd
to
7923438
Compare
🧪 Prereleases are available for testing 🧪 @cloudflare/next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/6739263039/npm-package-next-on-pages-486 @cloudflare/eslint-plugin-next-on-pagesYou can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/next-on-pages/runs/6739263039/npm-package-eslint-plugin-next-on-pages-486 |
cfdbbc5
to
3ca3028
Compare
06ddf53
to
9ab7c28
Compare
Hello @dario-piotrowicz, Thank you for your work on this, which is going to make my development workflow 100x better. I have been testing this out in one of my projects to mock D1 and I have noticed that the mock database file has a different hash to that of the main wrangler commands. This causes issues as when I run my migrations via Cheers! |
Hi @millar, first of all thanks so very much for trying this out! I hope it's been working nicely for you! 😄 Regarding the D1 db, my mocks use miniflare under the hood for them which is what also wrangler uses, so the two should have the same exact results.... so I don't really know what you're experiencing that issue, maybe this depends on some options set for miniflare or something like that... I'll have to have a look Anyways just to be sure, did you check what happens when you run your application with |
@millar One thing you'll need to be careful of is that the database UUID passed to For the following [[d1_databases]]
binding = "DB"
database_name = "database"
database_id = "3eab3f70-03c0-41d2-81f2-9fc363117677" ...you'll want something like... setupDevBindings({
d1Databases: {
DB: "3eab3f70-03c0-41d2-81f2-9fc363117677"
},
}); ...whereas for the following [[d1_databases]]
binding = "DB"
database_name = "database"
database_id = "3eab3f70-03c0-41d2-81f2-9fc363117677"
preview_database_id = "00b88e8f-9cf3-4b92-8dfa-76d98a26c3b2" ...you'll want to use that instead... setupDevBindings({
d1Databases: {
DB: "00b88e8f-9cf3-4b92-8dfa-76d98a26c3b2"
},
}); |
24fd96e
to
1768e9c
Compare
const { kvNamespaces, r2Buckets, d1Databases, services, textBindings } = | ||
options; | ||
const bindings = { | ||
bindings: textBindings, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@IgorMinar, I'm totally happy to rename our textBindings
argument to bindings
if we don't want to introduce a new term
That's also how they are referred to in wrangler pages dev
:
I find the terminology pretty confusing but I understand introducing a new one not being great, so I'm totally ok with renaming this to bindings
if you prefer 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PS: Indeed I don't think we use textBinding
or anything alike anywhere else...
@dario-piotrowicz Thanks a lot for this. Local version works fine but having issues with deploying to Cloudflare pages. I'm using Plus, |
I'm not sure what the issue is... does bun support installs from non-registry sources such as our prerelease links? (if it works locally I guess it does? maybe only in some OSes/versions or something? 😕:thinking:) I'll try to look into it but I guess it could be a bug in bun itself? in the meantime, when you have to use prereleases maybe you could switch to
Thanks for the callout! I'll look into adding queues as well 🙂👍 |
Bun has had various issues with our prerelease registry links for many months sadly.
|
As @james-elicx mentioned, it looks like this issue is with bun itself. What's weird is that it works perfectly fine on local machine but fails while deploying to pages. As per the suggestion by @dario-piotrowicz I've modified the pre-build script for pages deployment and it's now using
While this works for the deployment, it strips away the package installation consistency offered by A better solution is to deploy the |
Prereleases are something we added to help testing changes, they were never added with the intention of being used for any non-minimal period of time. I don't think publish them to npm would make too much sense, please keep in mind that each every commit on an opened PR "generates" a new prerelease, so if we were to publish them in no time we'd have thousand of useless prerelease versions there (each formatting, comment change, etc... on an open PR would generate one). What you mentioned as Also please note that usually we do merge PRs rather quickly so the need to rely on a prerelease is quite rare I believe (and they are used as I mentioned above just to check things), this one has been a bit different as it is a significant addition and I didn't want to rush it in (potentially getting the API wrong). Sorry about that. |
PS: additional personal point of view 😅, this also does feel like a bug in bun to me, if that's the case then instead of us changing thing to accommodate bun's shortcomings the fix should happen in bun itself (unless they clearly state that this is not a bug and that they do intend only to support the standard npm registry and nothing else 🤷) |
@iamvishnusankar you could just leave your package.json as normal with next-on-pages pointing to the latest version. There's no need to use two different ways of installing dependencies for local vs CI... Dario's suggestion was to just use If you want to use the same build command between the two, you could use a package.json script that runs the npx command and use that instead for your build command. Before we merged our Bun PR, I would have my build command on Pages to use |
@james-elicx It seems like you misunderstood this situation here.! The point of using this pre-release version is to get access to It works fine locally, but when being deployed to Cloudflare pages, the CI will auto detect the To prevent this auto install, I use |
Oh, derp, you're right, I did misunderstand what you were referring to - totally slipped my mind that you can't use the import if it's not the one in your package.json. My apologies. |
@dario-piotrowicz No need to push every PR to npm. May be you could setup an action to pre-release the packages when you create a GitHub pre-release with |
@iamvishnusankar ok totally fair point 🙂 Adding an ad-hoc github action to take the latest prerelease from a PR and publish it shouldn't really be too hard, but again I'd be really interested to first see if bun has any intention of fixing this on their side 🤔 |
@iamvishnusankar I've checked with the team regarding the queue bindings, we agreed that we can just merge this PR without them and add them as a followup (since it's a simple additive change anyways) 🙂 |
@dario-piotrowicz Awesome, Looking forward for the merge! 🎉 |
@dario-piotrowicz Hi, any update on this? or a possible |
@iamvishnusankar so sorry for this taking a while, the changes are pretty much ready, I just need a review from the team, I'll ping them right now sorry about that! I will try to get this merged by the end of the week! 🙇 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! Let's suck it and see.
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
… collisions with user defined code)
@iamvishnusankar PR merged 😄, now you can use this with the latest beta release 🙂 But by the way, so you know, I think the API of how you pass the bindings might still change before we do a proper release (so you might need to slightly tweak that later on) |
Idea for supporting bindings mocking in
next dev
using miniflare's new magic proxy API.Usage
(more details are in the new module's README)
In the
next.config.js
just add the following:and then running
npm run dev
(a.k.a.next dev
) will populate theprocess.env
with the bindings defined in the config fileNotes
next dev
gets the binding mocks but it's still important to note that it is still not very representative of production, so it's still advised to check things withwrangler pages dev
before deployingnext dev
goodness is present, including fast reloading and HMR 🚀Small very minimal demos/examples that use this new implementation:
resolves #271