Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stimulus_ns entry in generated source map has absolute path #10

Open
stevequinlan opened this issue Mar 14, 2022 · 1 comment
Open

stimulus_ns entry in generated source map has absolute path #10

stevequinlan opened this issue Mar 14, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@stevequinlan
Copy link

stevequinlan commented Mar 14, 2022

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.

@zombiezen zombiezen added the enhancement New feature or request label Mar 20, 2022
@zombiezen
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants