Local NPM package breaks build process


#1

Hi all,

I’ve been working on a project that incorporates ionic 2/angular 2 for a native app and plain angular 2 for the desktop version. In order to share and maintain shared dependencies for both versions I’ve created a local NPM package that contains all of the different shared items (basic providers, interfaces, api calls). Using npm link I’ve been able to add these shared dependencies into the angular 2 desktop project and it works great, however when I add this package to the ionic 2 project, it causes a bug in the build process by changing the folder structure in the .tmp file.

To further explain, before I added the local NPM package, the .tmp folder would contain a transpiled version of everything inside of the src folder which the build process then uses to complete the build. When I add the local NPM package to the project however, inside the .tmp folder there is a different structure that looks like shared\path\between\npm\and\ionic

For example:
If the ionic project is located at

C:\Projects\ProjectA

and the npm package is located at

C:\LocalNPM\ProjectA-Shared

then the resulting structure inside of the .tmp file is

.tmp\Projects\ProjectA\src\transpiledStuffHere

Or if the ionic project was located at

C:\Users\shared\Desktop\Projects\Apps\Ionic2\ProjectA

and the npm package is the same as listed above, then the resulting structure inside of the .tmp file would be

.tmp\Users\shared\Desktop\Projects\Apps\Ionic2\ProjectA\src\transpiledStuffHere

This change in folder structure then breaks the build process as it looks for the components inside of

./tmp/transpiledStuffHere

which isn’t correct. Hopefully this helps make sense of things. I’m not quite sure how to go about fixing this issue, whether it be a change in the ionic build process that I can make or if there is a setting that needs to be made in either of the package.json files. If anyone has any thoughts or ideas, it would be greatly appreciated!

Thanks

Note: I have been able to recreate this by starting a new project and local npm package, linking the npm package to the new ionic project and adding a simple dependency from the npm package. On ionic serve, it breaks the path generation, even though it doesn’t use a .tmp directory.

Cordova CLI: 6.3.1
Gulp version:  CLI version 3.9.1
Gulp local:
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v6.5.0