Skip to content

Conversation

AlCalzone
Copy link
Contributor

This PR will make it possible to work on adapter with less delay. Instead of packing the repo each time and manually syncing files, we instead configure npm to symlink the repo into node_modules.

This requires some changes in js-controller (ioBroker/ioBroker.js-controller#2103), as well as a bit of fine-tuning because of sourcemaps/breakpoints.
Also we should make this opt in, at least until js-controller 5.

@AlCalzone
Copy link
Contributor Author

I also figured out debugging now. We need to create the following launch configs in VSCode, depending on the adapter type (JS or TS):

		{
			"name": "Debug JS adapter",
			"address": "127.0.0.1",
			"localRoot": "${workspaceFolder}",
			"port": 9229,
			"remoteRoot": "${workspaceFolder}/.dev-server/default/node_modules/iobroker.devserver-test",
			"request": "attach",
			"skipFiles": [
				"<node_internals>/**"
			],
			"type": "node"
		},

		{
			"name": "Debug TS adapter",
			"port": 9229,
			"request": "attach",
			"skipFiles": [
				"<node_internals>/**"
			],
			"type": "node",
			"resolveSourceMapLocations": [
				"${workspaceFolder}/**",
				// only exclude node_modules from the workspace folder
				// If we exclude node_modules from .dev-server/..., we don't get sourcemaps
				"!${workspaceFolder}/node_modules/**"
			],
			"sourceMapPathOverrides": {
				"../src/*": "${workspaceFolder}/src/*"
			}
		}

dev-server should probably do that itself.

The JS launch config simply replaces the symlinked path with the actual path (although the program still runs on the symlinked path). The TS launch config uses source maps to change the debugger path.

@AlCalzone
Copy link
Contributor Author

AlCalzone commented Jan 29, 2023

TODO:

  • decide if we should create VSCode launch configs for the user, or just document it
  • figure out why the proxy isn't working anymore, see below

grafik

@AlCalzone AlCalzone marked this pull request as ready for review February 4, 2023 23:08
Copy link
Collaborator

@UncleSamSwiss UncleSamSwiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. There are a few things we could improve, but I'll leave it at that.

Once JS Controller 5 is used by most developers, we should consider creating the launch config for VS Code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants