Keep bundled /public and /private node_modules symlink content #9666
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Many npm based packages provide supporting assets that need to be made available, when used on the web. For example, to use the
font-awesome
package properly, thenode_modules/font-awesome/fonts
files need to be made accessible to incoming web requests.With Meteor, an easy way to handle this would be to create a symlink to
node_modules/font-awesome/fonts
from within an application's/public
directory. This would then allow all offont-awesome
's font files to be accessed directly by incoming clients. Unfortunately, while this approach does work in development when using the Meteor Tool, it does not work when production bundles are created.Meteor's isobuild process uses a helper class called
SymlinkLoopChecker
, to make sure the build process doesn't get caught up in an infinite loop trying to follow circular symlinks. Currently, a sharedSymlinkLoopChecker
instance is used to watch for symlink loops during both the_findSoures
and_findAssets
parts of the isobuild process._findSources
is called first, and covers source files that an application uses from thenode_modules
directory. TheSymlinkLoopChecker
tracks all of thenode_modules
directories covered, so they can be watched for in the future (to prevent duplicate inclusions). Next,_findAssets
is called using the sameSymlinkLoopChecker
. This means that if there are anynode_modules
symlinks used in thepublic
orprivate
directories, they will be marked as being duplicates (and stripped), since they were already covered in the_findSources
run.This commit changes things a bit so that both
_findSources
and_findAssets
use their ownSymlinkLoopChecker
instance. This opens up an applications symlink capabilities a bit, while still preserving some circular symlink safeguards. By doing this, a production application bundle can now maintain the contents ofnode_modules
based symlinks, used inpublic
andprivate
.So in the case of
font-awesome
for examplebecomes the following in the production application bundle
Fixes #7013.