Skip to content
This repository was archived by the owner on May 1, 2020. It is now read-only.

Support for symlinked folders #474

Closed
cubicleWar opened this issue Nov 25, 2016 · 2 comments
Closed

Support for symlinked folders #474

cubicleWar opened this issue Nov 25, 2016 · 2 comments

Comments

@cubicleWar
Copy link

Shared modules are proving to be quite a mess in the Angular 2/Ionic 2 world. Although a shared module template has been provided this seems to break quite easily when you want to use js libraries like pouchdb in the shared module. Its also a bit of a pain to have to compile the typescript with every change the you are writing the shared module in parallel to app development.

A simple solution is to use git sub modules however a simpler solution for be symlink support in the build scripts. This way you could just symlink the shared module (all typescript) into the src folder and build away.

@leyk0001
Copy link

leyk0001 commented Dec 19, 2016

Hi. I agree that symlink support is a must for a rapid shared module development. I was able to get it working with app-scripts version "0.0.47" after some trial and error. To save time for fellow developers, here’s what I had to do.

  1. Add symlink to the source root of your shared module in the project that imports it. I added symlink directly under the src folder but I don’t know if this is a hard requirement. If you are writing a js script to do this, you can use:

fs.ensureSymlinkSync(realFolderPath, symlinkedFolderPath)

  1. Add a bit of custom configuration to webpack.config.js and watch.config.js. I copied and modified the original files and then pointed to them in “config” section of package.json.

In watch.config.js

Add your symlinked folder to srcFiles.paths. You will have to explicitly add the path even if you symlink your shared module under the source folder of your app due to an issue (I believe) with “chokidar” dependency. For example, for a module called “mysharedmodule” symlinked directly under source folder your would change:

paths: ['{{SRC}}/**/*.(ts|html|scss)']

to

paths: ['{{SRC}}/mysharedmodule/**/*.(ts|html|scss)', '{{SRC}}/**/*.(ts|html|scss)']

I also added followSymlinks: true to srcFiles.options just in case, but this should be the default value anyways.

In webpack.config.js

Add symlinks: false under module.exports.resolve. Yes, I know it sounds counter-intuitive.

I may be forgetting a step, but I believe that it's all that I had to do. Good luck.

@danbucholtz
Copy link
Contributor

We are going to track this here:
#635

Thanks,
Dan

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants