Skip to content

Commit

Permalink
fix: use NODE_OPTIONS instead of calling node directly for debugg…
Browse files Browse the repository at this point in the history
…ing (#350)

* fix: use `NODE_OPTIONS` instead of calling `node` directly for debugging

* docs: add changelog entry

* refactor: don't use `+=`
  • Loading branch information
G-Rath authored Aug 29, 2023
1 parent 4170fd3 commit 8617937
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ Changes since last non-beta release.

_Please add entries here for your pull requests that are not yet released._

### Fixed
- Use `NODE_OPTIONS` to enable Node-specific debugging flags [PR 350](https://github.com/shakacode/shakapacker/pull/350)

## [v7.0.3] - July 7, 2023
### Fixed
- Fixed commands execution for projects with space in absolute path [PR 322](https://github.com/shakacode/shakapacker/pull/322) by [kukicola](https://github.com/kukicola).
Expand Down
3 changes: 2 additions & 1 deletion lib/shakapacker/dev_server_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def execute_cmd
env = Shakapacker::Compiler.env
env["SHAKAPACKER_CONFIG"] = @shakapacker_config
env["WEBPACK_SERVE"] = "true"
env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""

cmd = if node_modules_bin_exist?
["#{@node_modules_bin_path}/webpack", "serve"]
Expand All @@ -83,7 +84,7 @@ def execute_cmd
end

if @argv.delete("--debug-shakapacker") || @argv.delete("--debug-webpacker")
cmd = [ "node", "--inspect-brk", "--trace-warnings" ] + cmd
env["NODE_OPTIONS"] = "#{ENV["NODE_OPTIONS"]} --inspect-brk --trace-warnings"
end

cmd += ["--config", @webpack_config]
Expand Down
7 changes: 4 additions & 3 deletions lib/shakapacker/webpack_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class WebpackRunner < Shakapacker::Runner
def run
env = Shakapacker::Compiler.env
env["SHAKAPACKER_CONFIG"] = @shakapacker_config
env["NODE_OPTIONS"] = ENV["NODE_OPTIONS"] || ""

cmd = if node_modules_bin_exist?
["#{@node_modules_bin_path}/webpack"]
Expand All @@ -36,15 +37,15 @@ def run
end

if @argv.delete("--debug-shakapacker") || @argv.delete("--debug-webpacker")
cmd = ["node", "--inspect-brk"] + cmd
env["NODE_OPTIONS"] = "#{ENV["NODE_OPTIONS"]} --inspect-brk"
end

if @argv.delete "--trace-deprecation"
cmd = ["node", "--trace-deprecation"] + cmd
env["NODE_OPTIONS"] = "#{ENV["NODE_OPTIONS"]} --trace-deprecation"
end

if @argv.delete "--no-deprecation"
cmd = ["node", "--no-deprecation"] + cmd
env["NODE_OPTIONS"] = "#{ENV["NODE_OPTIONS"]} --no-deprecation"
end

# Webpack commands are not compatible with --config option.
Expand Down

0 comments on commit 8617937

Please sign in to comment.