Babel Plugin callback when all files have been processed? - plugins

I'm trying to call a method when all files have been processed in a babel plugin but I'm having trouble doing so. There are pre() and post() methods that are called for every file passed into a plugin but I'd like a callback to run when ALL files have finished processing or... after ALL post()'s have finished running.
Is there a hook that I can use or is it possible for me to see how many files have been passed to my plugin for processing (so that I can keep track myself)?

Babel's plugin system is entirely per-file currently. Babel itself has no way of knowing that multiple files are being processed, or that they are finished, so it has no way of passing that information down into a plugin.

Related

TYPO3 Extension Development - Where should JavaScript modules be placed in the optimal case?

I have stored a JavaScript file in a TYPO3 extension (under Resources/Public/Css/JavaScript/Backend/Iconpack.js), which is used as a JavaScript module in the backend.
However, when developing the extension, I packed the file full of console.log() to allow debugging, and also to better document certain things.
Of course I want that in the final extension as well as when downloading via composer, only a minimized version of this JavaScript is loaded, but not the original source file.
On the other hand, of course, I want the original source file to be stored somewhere in the git repository, so that you can actually continue working on it.
In the frontend, I would normally just store Iconpack.js, for example, in the same folder, create a minimized version from it, i.e. Iconpack.min.js, and use this minimized file.
But unfortunately that doesn't work in this case, because the file path for JavaScript modules is also the namespace.
What would be the best way to solve this?
To summarize:
The minimized version should be able to be used directly in the backend via Iconpack.js.
The namespace should be TYPO3/CMS/Iconpack/Backend/Iconpack and not TYPO3/CMS/Iconpack/Backend/Iconpack.min or similar.
The source file should not end up in TER or be loaded via composer.
But the source file should be accessible via Github.
I was able to find out that I can at least prevent a certain file from being loaded via composer with .gitattributes.
Unfortunately, that doesn't solve the question of where I should best place it so that other developers have it easier and it's clear that it's the source file.
Currently I only have the minimized version stored in git for this reason, but that makes little sense for an open source repository: https://github.com/quellenform/t3x-iconpack/tree/main/Resources/Public/JavaScript/Backend
Ideas?

Does Next.js have plugins?

Imagine you want to produce a specific static asset for your Next.js web app. An image collage for example, or perhaps a web manifest or site map.
My current strategy for this kind of scenario is to make a script that can produce the desired output directly in my /public folder, but then I have to push the built file along with my source files in my repo, which is less than ideal.
Or, I have to set up a separate parallel asset pipeline to re-create the asset when the source files change and which I would launch whenever I launch next dev. I would also need to run the script when next build is called.
In either case, I then also need to ignore the built file so it's not pushed along with the other files in /public…
This kind of solution feels like I'm reinventing the wheel and losing the zero-config ideal around which the Next.js ecosystem revolves.
I'd much rather provide Next.js with my custom script and just hook into the existing asset pipeline, dev server lifecycle, and build script, letting Next.js do the heavy lifting for me, hence my question:
Does Next.js have a plugin architecture, extensions, or perhaps lifecycle hooks I could tap into to implement a custom asset pipeline?
I see some pluggable loaders exist for Next.js, such as the MDX loader, but it's not clear to me whether this is the way to go for what I'm trying to do, and I'm not finding any documentation about how to write my own loader, so I'm afraid this might not be a recommended approach…

Can I set apart changes I did in Moodle core to plugin?

I have changed the source code in the /lib/coursecatlib.php file. Can I set apart this changes to plugin?
There are some changes that can be made entirely withing plugins, by using the hooks made available in Moodle.
You haven't said what changes you have made to coursecatlib.php, but I suspect that anything you have done there will be hard/impossible to transfer into a plugin.
The closest you can get is usually to minimise the changes by adding a single line of code that calls a function in a custom plugin (preferably one in an automatically loaded class).

How can one sbt plugin set another plugin's settings then call that other plugin

I'm trying to augment an existing plugin, lets call it A-Plugin.
A-Plugin's main task uses the mappings setting.
However setting up the mappings setting is tedious for what I need and can be entirely automated. So I'm trying to write a plugin that calculates the correct mappings setting sets the mappings then calls A-Plugin's main task.
I have a task that does the calulation of mappings, but I cant' initialise mappings with it because settings can't depend on tasks, I also don't know how to call A-Plugin's task from mine when i'm ready.
This sounds like it should be a command but the best practice plugin guide says to avoid createing commands in plugins.
How can I do this? Am I on the right track or is there another idiom I should use?
Part of me is now thinking that I should just expose the function to calculate mappings and simply leave it up the the plugin user to set mappings from the function.... however this would run as soon as sbt was started... whereas I need to run it after some other tasks hove run.
Anyone know what to do?
Thanks
It's true that Plugins Best Practices says to generally try to avoid using commands first. However, if you can't achieve what you want using just settings and tasks, you should go ahead and reach for bigger hammer.
Also note:
One legitimate use of commands may be using plugin to access the build definition itself not the code. sbt-inspectr was implemented using a command before it became inspect tree.
In your case, if you're trying to dynamically set a setting, and then execute a task, that's sort of like rewiring the build definition, so I'd consider a candidate for a command. You'd still be careful implementing it to make sure it can handle multi-project etc.

When writing Eclipse JDT plugins, is there a way to track appearace of certain strings in code?

I'm writing an Eclipse plugin for the JDT.
I need a functionality that tracks certain strings or regular expressions and possibly creates markers.
I know that Eclipse already does that for //TODO comments, for example (creating task markers for them) but I'm not sure if I can use the same mechanism. I can write my own but worried it would be too inefficient and not sensitive enough to code chnanges.
It shouldn't be complicated. Register yourself as either resource listener or as a builder and use AST to parse the modified text files.