how to debug a file in node_modules - node.js

I'm new to node and am playing around with SailsJS. I found what I think is a bug (reported it), but I wanted to have ago at debuging it myself.
I located the file that I need to investigate in the node_modules folder.
I tried putting a console.log in it to ensure I had the right one. Nothing happened.
So I tried placing log statements in several other files in node_modules that are at the top of the dependency tree. Nothing is printing out.
Do I need to do something to refresh the cache make this work? OR am I going about this in completely the wrong way!

Usually, if you think that an external module has a bug, the best approach is to clone it and write a test that shows which is the offending set of inputs.
SailJS is available on GitHub, so you can freely and easily contribute with a merge request if you find that you are right.
This way, you can adopt the same approach used by the project to test the code (as an example, using mocha).
In case the merge request will be accepted, while waiting for a new release on npm you can refer to your remote copy by means of the package.json file.

Related

Creating a modular component library package for NPM

I'm currently creating an npm package that will consist of a series of React components that are common to some applications I am maintaining.
My intention is to be able to import this components individually as needed, not all at once. So for instance if I have the components Accordion, DropDown and Widget, but I'm only using one of them, I'd like for only its code to be required.
My understanding is that I would need to be able to do something like
import Widget from 'components/Widget';
Instead of
import {Widget} from 'components';
But I can't get the first version to work. I have not published this package, so I'm using npm link to test it on another application. I'm not even sure what to Google to solve the problem myself, so I'd also appreciate links to relevant documentation on this matter.
Thanks.
So, of course a few minutes after asking my question I resolved the issue:
First, as Yacine Filali commented on my question above, I need to have individual files in order for this to work (this part I had already figured out).
However, I was incorrectly assuming that the root of my package was going to be set to whichever directory my entry file was in. So in package.json I had set
"main": "./lib/index.js"
Incorrectly assuming that the folder structure would be read from there. After altering my configuration to build everything into the root directory it worked perfectly.
(Of course, I'm now working on a better alternative, like generating a package.json for the lib folder)
In your component:
export default Widget
In your index:
export { default as Component } from './Component'

ES6 imports: pick up updates to external project

We are starting a new project using angular2, typescript and gulp. For the time being our application will consist of two subprojects: a components library (which in the future might be spun off into a separate project) and the app using the component library.
The layouts of the project is going to be something along the lines:
/project_root
/component_library
/src
/library
/components
/services
... etc
/application
/src
/app_name
/components
/services
... etc
The components in application will be using components from the library (but not the other way round)
We would like to have clean (non relative) imports in the app components when importing stuff from the library (we want to avoid ugly imports of the sort '../../../component_library/src/library ...etc' plus, what's more important, we want to be able to move the library code to a separate project without the need to update imports.
There are two possible solutions I see (don't like any of them):
Add a gulp task that would watch the component library and on every change copy the file to node_modules in /project_root
Some sort of simlink? so that we can point /project_root/node_modules to /project_root/component_library/src?
I'm afraid the first solution might not work well with IDE autocomplete in the application (first gulp would need to do the compilation/copying then the IDE would need to pick up the change from node_modules - this looks like something that can be really slow)
The second solution feels hacky - it would need to be repeated by everyone who checks out the code from repo.
What would be the best solution here?
what's more important, we want to be able to move the library code to a separate project without the need to update imports.
Ship your component_library with source and add it as a node_module dependency. Then when someone pulls your code they can add a git remote to node_modules/component_library code and work on the two projects seemlessly.
This is the approach I took with ntypescript.

MonoDevelop: Any way to override resources / classes using projects?

Consider a solution has 2 projects: ProjectA and ProjectB (both are MonoTouch apps) and ProjectBase. ProjectBase contains the whole application, but Main.cs file (with the entry point) is located in ProjectA and ProjectB (which reference ProjectBase). This way, running any of A/B projects will boot up the application from ProjectBase.
Now, I want to override something for ProjectA only (it might be XIB file, image or a .NET class). Is there any way I can setup the solution so that the code and resources, produced by ProjectBase, are merged with the ones from ProjectA/ProjectB and the latter wins?
I found (probably a quirky and kinda-undefined-behavior-driven way) of overriding XIBs: I just put a XIB into ProjectA and ProjectB, name it the same as it was named in ProjectBase and them exclude it from ProjectBase. Although MonoDevelop compiles all items, it seems that the startup project's XIBs get priority, so that I see ProjectA-specific XIBs when I launch ProjectA and ProjectB-specific XIBs when I launch ProjectB. However, I am not sure it is the way it should behave, plus, from what I can see from build log, ALL projects get built yielding resources at the end.
P.S. I'm sorry if this has been asked previously, but I was not able to find the similar question on SO.
I was once trying to do this for a bunch of apps. I would have thought build order would be ProjectBase and then ProjectA, and the content copy system would be the same... Guess this means we are wrong.
You could do a few things.
A) Build your own program to copy resources which are marked for content. Would not be very hard, just need to read the .csproj files. XML parsing is easy enough in .NET. Run this program on post build. Would just have to be careful when doing builds such as to zip or to the device as I am not sure how it handles post-build events.
B) [This is what I did instead] If I expect to also make ProjectC, ProjectD ... ProjectN I instead made a program to generate my program... (Programception).
What it does, has ProjectBase, and ProjectTempalte. You enter your new project name into this program, say, "MyNewProject" and it will create the correct folder structure, write the correct csproj files, and update SLN file. ProjectTemplate has various placeholders in .csproj files like {PLACEHOLDER} which Programception would just go through and find/replace with my project name. Image files (and in your case XIB) are then only kept within ProjectA (B..C..N) unless I do not expect to try and override them in which case they would stay in ProjectBase. This is a lot easier with a XIBless application I would assume. I never use XIB's anyway.
Hope that helps!

Syntax errors in ls after update from SVN

We are using SVN for version control of code from notes databases. These databases contains a lot of ls/js/java code. For js/java code it works fine.
The problem is with ls libraries. There are at least a hundred of them and they are interconnected. Sometimes if developer submits a ls code change to SVN and then someone else tries to update his copy of database he is getting a lot of syntax errors in notes client. The changed library does not even open properly in old editor and ls code is stored inside field oddly named $ScriptLib_error.
This problem goes away after the developer removes assosiation with on-disk project and than connects the db back to it.
Has anybody else encountered this problem? Are there any feasible solutions?
What version of Designer are you using? There were many fixes for source control issues (in particular in the area of LS script lib import) added to 853 Fix Pack 2. If you are not on that fix pack please upgrade to it.

Merge Module not found. Installshield 8

We're using Installshield 8 in creating our installer.
While building, we are getting this error.
Error -4075: File not found.
We traced the problem to a "missing" Merge Module. The weird thing is, the Merge Module does exist in the correct location! Browsing the merge module manually solved the problem. So we checked-in the fixed ISM file, restored the build machine (We had it snapshot'd), fetched the entire tree and built from there. Still, the merge module problem is there.
I noticed that when you browsed for the "missing" Merge Module, the problem will no longer exist even if you did not save the ISM file.
Have anyone experienced this problem?
Thanks.
UPDATE:
Our Merge Module is not located in the Default Location for Merge Modules where Installshield is looking. In the newer version of IIS, there is a -O flag for IsCmdBld.exe which allows you to specify additional locations for your custom merge modules. One option that we have is to just copy our merge module to one of those Default Locations. But if someone can have a "neater" solution, please. :)
If you click on Tools/Options/Merge Modules you can specify the directories in which you want the IDE to search for merge modules; in other words, expand the number of "default" locations where IS will search.*
For command-line building, you are correct; you have to use the "-o" switch.
*Disclaimer: this holds true for modern versions of InstallShield (last 5 years). I assume IS8 is the same, but YMMV.

Resources