📜 ⬆️ ⬇️

Release of the second version of the Nodejs plugin for Sublime Text

Good afternoon friends! In November 2016, I started playing with Nodejs plugin for Sublime Text. The plugin was small and had several old and well-known bugs under the cut.

In those days I was playing with Nodejs and my favorite code editor was Sublime Text. On the long-beaten track, I went to packagecontrol.io and looked for Nodejs plugins. I found this one . Having put and worked, I was very disappointed when I found out that some of the declared features of the plug-in do not work, or do not work as stated ...

In such situations, I usually go to the project page on GitHub and study the project for last activity to make sure that the project is not abandoned. I found that the last commit was in 2013. Pechalka, I thought, considering that this was the only plugin for working with Nodejs in Sublime Text.
')
Then I thought ... These are two pieces of technology that I like, and I always wanted to contribute to Open Source.

The plan was simple, fix the bugs that I face. Over time, I realized that fix bugs began to cause problems, due to the monolithic architecture of the plugin, the lack of tests and tools for debugging.

Plans change


As I mentioned earlier, I suffered from a lack of tests and debugging tools. Fixing one bug could cause a series of other bugs. Moreover, fix bugs on some platforms, could cause or leave bugs on other platforms. Then, it was decided to make life easier and happier. =)

What was done


A lot of things were refactored, redone and rethought. All changes can be logically divided into two groups: user interaction with the plugin and developer comfort.

Developer Comfort


I will present everything in the form of a list with a small explanation of why, as well as maybe why it was done.


With the help of all of the above, now we can fix bugs or add new functionality, enjoying the process.

User interaction with the plugin


So, we got to the most interesting part - the user interaction with the plugin. As in the previous part, I will list the list of changes and the reasons for this.


Debugger


In previous versions of the plugin, the Nodejs Debug (+ arguments) command ran the current file with the debug parameter passed to the node . It was useless. Starting with Nodejs version 6.3.0, debugging is supported using the Chrome DevTools debugger. Read more about this in Paul Irish's blog.

Now, when you run the Nodejs Debug (+ arguments) command, the current file will be launched with the --inspect = localhost: 60123 - debug-brk option for the 6th Nodejs version and with the - inspect-brk = localhost: 60123 for the 8th option version. As you can see, the debugger runs on port 60123, which does not conflict with the default port 9229.

Next, you can connect to the debugger using the steps displayed by the plugin:
Debugger is successfully started at localhost: 60123.

1. Now you can open Google Chrome and navigate to chrome: // inspect.
2. Then click Open dedicated DevTools for Node.
3. After click Add connection to localhost: 60123

What should be done


Source: https://habr.com/ru/post/343750/


All Articles