-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Node.js standalone mode + support for astro preview #5056
Conversation
🦋 Changeset detectedLatest commit: e7a9bd9 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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 PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
!preview |
Invalid comment format. Expected: "!preview " |
!preview node-standalone |
|
Released a snapshot for this which can be installed with: npm install astro@next--node-standalone @astrojs/node@next--node-standalone |
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.
LGTM! Flagging @withastro/maintainers-docs for a review of the types additions.
|
||
export default defineConfig({ | ||
output: 'server', | ||
build: { |
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.
nice! This makes a lot of sense!
|
||
See the @astrojs/node documentation to learn all of the options available in standalone mode. | ||
|
||
## Breaking change |
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.
thinking more about this, if you default to middleware
and make this option required, do you still need the major version?
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.
It wouldn't be required if it had a default, no?
We could default to middleware
. My thought was that these two modes are pretty significantly different and it didn't feel right to "prefer" one over the other. Kind of like Vercel serverless vs edge, just completely different things.
As far as semver, given that this is an integration I didn't think it mattered as much to do a semver major change.
But I don't feel too strongly on either of these things.
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.
yea, agreed that because its an integration this doesn't matter as much / I'm okay with the plan for a major. And I agree it makes more sense as required, or as defaulting to standalone. Defaulting to middleware
is probably the least natural of the 3...
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.
Ok, I think we should do a major in that case and require the option. We can track usage in the future and if standalone
is overwhelming (and once it becomes more stable) we can make it the default if we want to.
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.
Just left a few text suggestions to consider, and one other thing you might want to consider is a link or note to these new server configs around line 400ish from outputDir
, to make it known that they exist in SSR mode.
* This entrypoint is usually dependent on which host you are deploying to and | ||
* will be set by your adapter for you. | ||
* | ||
* Note that it is recommended that this file ends with `.mjs` so that the runtime |
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.
* Note that it is recommended that this file ends with `.mjs` so that the runtime | |
* Note that it is recommended that this file ends with `.mjs` so that the runtime |
Just checking this is intentional, because I think I've only ever heard "runtime" as an adjective "runtime environment, runtime system, runtime library". If this is a noun, then it's fine!
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.
I've definitely heard it used as a noun. In fact, nodejs.org's <meta description>
tag uses it as one! view-source:https://nodejs.org/en/
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
Co-authored-by: Sarah Rainsberger <sarah@rainsberger.ca>
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 PR is blocked because it contains a minor
changeset. A reviewer will merge this at the next release if approved.
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.
Nice! I've been missing astro preview
support for Netlify's CLI, great to see this new API will open that door 👍
Change looks good to me, just added one note in the image integration to make sure this won't break WASM support
if(needsBuildConfig) { | ||
_buildConfig = buildConfig; | ||
} |
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.
_buildConfig.server
is used in the astro:build:ssr
step below, does it need to be updated to make sure wasm files are copied to the preview output directory?
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.
So, this line exists for backwards compatibility. If you are using Astro < 1.5.0 then this line will get _buildConfig
from the 'astro:build:start'
hook. If you are using Astro >= 1.5.0 then it will get it from the 'astro:config:done'
hook here: https://github.com/withastro/astro/pull/5056/files#diff-0000f87084d8080bf428d6b3b7dc84cda4f01465d9a3e95c75bbc38b8129e1e5R99
In the future when we do a new major (or minor in the case of astro/image) we can get rid of this code and only support users of Astro >= 1.5.0
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.
Lgtm
Hello @matthewp, Node.js standalone mode, css resources unable to load.
|
Build did not work on latest version of "create astro". ``` "dependencies": { "astro": "^2.0.2" }, "devDependencies": { "@matthewp/astro-fastify": "^2.0.3" } ``` Issue origin: withastro/astro#5056
Changes
previewEntrypoint
API that adapters can support to enableastro preview
.{ mode: 'standalone' }
option for the @astrojs/node adapter.buildConfig
option inastro:build:start
in favor of moving those same options toconfig.build
.Testing
examples/ssr
example.Docs