I noticed the "stimulus_ns" entry in my generated source map had the absolute path of the Stimulus controllers folder. This meant on production I was leaking information about the directory structure of my server e.g.
"stimulus_ns:/home/myuser/railsapp/app/javascript/controllers"
return {
path: path.relative(process.cwd(), path.join(path.dirname(args.importer), sep)), //change from absolute to relative directory
namespace,
};
return {
contents,
loader: 'js',
resolveDir: path.join(process.cwd(), args.path), //change from relative to absolute directory
};
Hope that helps, not sure if it's the correct approach or desirable as a PR.