-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat(space-nuxt-base): run tunnel on start up #75
Merged
Merged
Changes from 4 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
037b52c
feat(common): run tunnel on start up
eunjae-lee edbaad9
Merge branch 'main' into feat/run-tunnel-on-start-up
eunjae-lee 59c1a60
change implementation
eunjae-lee b240df6
Merge branch 'feat/run-tunnel-on-start-up' of github.com:storyblok/sp…
eunjae-lee 1eb63ac
update .env.example
eunjae-lee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineNuxtModule } from '@nuxt/kit'; | ||
import { execaCommand } from 'execa'; | ||
|
||
export default defineNuxtModule({ | ||
setup(_options, nuxt) { | ||
const tunnelCommand = process.env.TUNNEL_COMMAND; | ||
if (process.env.NODE_ENV !== 'development' || !tunnelCommand) { | ||
return; | ||
} | ||
nuxt.hook('listen', async () => { | ||
// using execa@8.0.1 because we're using a bit lower version of Node.js than what execa@9 requires. | ||
// https://github.com/sindresorhus/execa/blob/v8.0.1/readme.md | ||
execaCommand(tunnelCommand); | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hey @eunjae-lee this might not be ready yet, I am just leaving comments as I am OOO tomorrow, but not to block you.
nit:
process.env.NODE_ENV !== 'development'
is this check needed? From what I understood, thelisten
hook will only be triggered when dev server is loaded. But I might be missing something here.question: What happens when the dev server is closed, will the tunnel still be running?
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 actually added the explanation in the PR description, but if the dev server is closed, the tunnel will be closed as well, because the tunnel is the child process of the dev server process. When the parent dies, the child dies as well. (horrific dev story)
process.env.NODE_ENV !== 'development'
-> I guess we won't really need it becauselisten
is for the dev server as you said, however, if we have this, the production build will not include the code within the if clause at all, and it means we won't includeexeca
dependency as well in the bundle output. I actually copied this https://github.com/nuxtus/localtunnel/blob/main/src/module.ts#L44, and I believe that's why they did so?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.
😂😂
Totally missed the description sorry. I read it now, thank you for the details. Everything looks perfect. Can't wait to try it 🫰🏻