stimulus_ns entry in generated source map has absolute path
Hello Thanks for the great plugin
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"
My workaround:
I replaced the returned path in build.onResolve with
return {
path: path.relative(process.cwd(), path.join(path.dirname(args.importer), sep)), //change from absolute to relative directory
namespace,
};
and the resolveDir in build.onLoad with
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.
Thanks for the feedback. I'd have to look at what esbuild uses for its sourcemap paths to recommend a resolution here. Anchoring relative to the esbuild process's working directory seems reasonable, but I would want to ensure that this doesn't have any strange side-effects.