The transform
hook allows you to manipulate the contents of each module before it's bundled. It receives two arguments: the raw code string and the id
(usually the path to the file).
This is especially useful for:
transform(code, id) {
if (id.endsWith('.js')) {
return code.replace('__HELLO__', '"Hello from plugin!"')
}
}
If you want to change how source code behaves or inject logic, this is your hook.
Add a transform hook that looks for MY_NAME and replaces it with your actual name in any .ts or .js file.