I have some React developer experience/productivity improvement ideas that depend on static analysis of component files. I'd like to run some script to generate some code in component files if some characters appear in said files.
NextJS automatically runs its compiler whenever a component file changes, so I'd like to intercept/hook into that compile step to run my script and generate some code before the compiler continues.
I've looked around, but I can't find anything that suggests a way to go about doing this.
next/build does not expose hooks, so you cannot get in front of it like you are asking. You can use nodemon or something similar to listen to .next/server/pages/** and do something after the build script, or listen to src/pages/** and do something at the same time as the dev rebuild, but you cannot get in front of it.
This is actually a pretty common feature for other bundlers (Rollup etc.), so I opened a feature request for you.
Related
I have been playing around with Apache module development and got the module working. However, I ran into the issue of where to hook properly to get all the data I need.
I am making a simple caching module that needs to hook at the beginning of the request and check if the file for this URL exists on disk and if it does then serve that file and stop content generation of Apache.
Currently, the module still continues to go into content generation mode. Let's say I have a long-running PHP script that takes 5s to generate. I would to omit calling the script altogether and just serve the static file from disk.
Furthermore, if the local file does not exist, I would like Apache to execute content generation (actually executes the PHP script) and before sending that data to the client I would like to have a proper hook that somehow gets this data and saves it to a local file.
I have tried ap_hook_fixups, ap_hook_handler and APR_HOOK_LAST, APR_HOOK_LAST and all the variations but no luck.
It always executes at the start of the request.
I also do not want to use any existing Apache modules. I want this to be a self-contained module.
Is there a way to do this kind of thing?
Based on the information you have provided, it sounds like you want your module to execute First and not last.
From what I understand of your issue, you want to make sure the file that would potentially be generated is already on disk or not, and if it is, serve that file, instead of allowing your php script to serve it.
In this case, you'll want to use APR_HOOK_FIRST or APR_HOOK_REALLY_FIRST
Then, assuming your file is on disk, you serve your file, and at the end of your module's work do a return OK;
If the file does not exist, do a return DECLINED
The DECLINED tells Apache that your module should not be the handler for this request and will continue down the list of modules till it finds something that will.
The goal here is to get your module to run before the php module does, to prevent your generation code from running, and fall back onto the php module if the requested file was not found.
Note:
The APR_HOOK_? priorities are just numbers -10 to 30
You should be able to fine tune this if you find your module executing a little too soon, like before mod_ssl for example.
Also, I am terrible at following documents, but the official Apache module development docs are amazingly assembled. Please try to use them, if you have,
I have spent the last 6 months messing around with Apache module development, working on a telegram bot.
I have had to do this song and dace a few times now.
I'm having a hard time understanding how to even search online for this behavior. I've seen it several times before and know it's something that can be done but don't know if this is a language level feature or what. What do you call the ability for code that you edited to automatically be applied to an executed instance of said code being run.
To use a common version of this that I see: you'll have a game that you're developing open and you'll be running that game in your engine and then edit a value (let's say one representing walking speed) and then simply save that file (maybe compile it? maybe just that line? I don't know how it's done) and then, suddenly, that behavior is updated in the live instance of the program just like that.
It seems so much better then having to recompile a file, or a whole project, and then run it to be able to test it. How do I do this kind of rapid iteration and what is it called? NOTE: the first time I saw this was with Clojure in emacs. Does that have something to do with it?
You may want to read about the Clojure REPL and also here.
"Hot Reloading" is related and is commonly used in UI development in the browser with ClojureScript:
Shadow CLJS
Figwheel Main
I am a beginner and started learning C using VS Codium in Ubuntu. So I have a file named "programm1". And every time I try to run it in terminal with "./programm1" it doesnt recognise changes I made, unless I type "make programm1"
Is it supposed to be like this? Or is there ways to make it automatic, so I dont have to save every change I make with "make programm1"?
Your binary, programm1 doesn't know how it is build. Your build system, in this case, make specifies how to build your binary. As you found that you can execute a build manually. This is how I prefer to work (and in nvim I have the plugin ale enabled for real-time feedback).
Linux has a mechanism called inodify that allows a program to be notified of file system changes. You may want to check out wrappers for the API including the packages entr, inotify-hookable and inotify-tools.
Another option is to configure your editor to run make for you when you save a file.
The app starts with a blank screen for a while before the app really loads
I'm using electron-forge's react-typescript template.
I can make a dmg or deb file successfully, but I noticed when I run the packaged app, there will be a blank screen for a while before the app actually load especially the first time
I checked the distributable file and found the whole source code inside it, so I guess it's because it has to compile typescript every time?
Then how to "precompile" my source code and use that to make a distributable app?
update:
Since the project was developed by other colleague, I just found out this project is using electron-compile to compile it on the fly, maybe the solution has something to do with this?
I checked the distributable file and found the whole source code inside it, so I guess it's because it has to compile typescript every time?
This is not true. Current stable uses electron-prebuilt-compile (https://github.com/electron-userland/electron-forge/blob/1709af0bc53bd962466dd2025672b95f2e9399cc/packages/api/core/src/util/electron-version.ts#L6) which creates precompiled cache for typescript files for packaging time. Typescript source is only needed for module resolution in actual filesystem.
there will be a blank screen for a while before the app actually load especially the first time
This requires profiling application itself to find out what is happening in meanwhile. It is possible module resolution takes long or either any js execution time's blocking, but can't tell without profiling it.
The Issue
We have a batch script which is called on post-commit-hook and post-update-hook. We would like to either pause the script or show the output if an error has occurred within the batch script.
Issuing a pause somewhere in the script will not result in a pause inserted when called from the hook.
Running the script normally will issue a pause.
Is it at all possible to issue a pause in a hook script? If so, how? Or are there other ways to display an error in a hook-script?
What are the scripts supposed to do?
We would like to include the revision number of the current build within a xx_version.c file. This is needed so that our testers can perform their tests using a certain version and that we as developers can continue working on newer versions till they are finished with their tests and if there are any problems we can switch back to that revision and see if we can fix it. But that revision information needs to be stored in the software itself, even so that we can always go back to a certain revision if needed to fix 'things'. Testers will always use the 'nightly-builds' to test the soft- and hardware.
Update 2012-11-16
We have made some progress, but quite in the wrong direction. We are using Eclipse as the IDE and we expected that the hooks would be executed when we would update/commit from within Eclipse. Sadly this is not the case. Thus we are looking in to other ways to automagically run these scripts. Preferable from within Eclipse when commiting/updating
Preface:
Eclipse SVN-integration doesn't related to TortoiseSVN and TSVN client-side hooks
Any and every hook can write own log-file for reading this log later
You can get HEAD revision of repository-tree dynamically, using svn info URL
If you really want and use client-side hooks, you have don't forget about hook settings in TortoiseSVN
While "Wait" haven't sense in you case, do not hide output window may be useful
PS: Maybe inside Eclipse you can start only usual SVN-scripts, in which only exit-code is usable