New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[1.3.2.4] Can't have symlink to node_modules in /public #7013
Comments
I confirmed that running |
What is the workaround? Copy into public instead of symlink? |
@polgfred Unfortunately copying is what I'm doing right now. Glad I don't have too much npm dependencies needed as public assets. |
Same issue here with font-awesome – I tried to link their fonts: cd public
ln -ls ../node_modules/font-awesome/fonts ./fonts Font-awesome is a very popular library that provides lots of font-based icons. New icons appear as the library develops, which leads to frequent changes to the fonts files. The directory with fonts is around 1M now. If one manually copies new fonts to Until the issue is fixed, public assets from npm modules can be added to #.gitignore
/node_modules/
/public/fonts/ # package.json
{
"...": "...",
"scripts": {
"...": "...",
"prepare-public-dir": "cp -r ./node_modules/font-awesome/fonts ./public/fonts"
}
} # after npm install
npm run prepare-public-dir |
@kachkaev interesting hack I think I'm gonna use it. |
Looks like this bug was not addressed for quite a while. Having symlink in public can be useful not only to link to node_modules, but also to other external asset folders. For example, JSON schema files to be exposed to the client. Copying assets, as a workaround, - is exactly what I am trying to avoid by using symlinks. |
+1 |
Hi guys is this bug going to be fix in the next meteor releases? The work around is actually quite ugly :( |
Hi all - symlinks created in the meteor/tools/isobuild/package-source.js Lines 1214 to 1217 in 8b95173
The loop checker itself is being a bit overzealous, and prevents
when the isobuild process looks for asset files to include, it skips over the symlink'd files because I ran out of time on this one today, but I was able to verify that commenting out the above code does allow the contents of |
Just to clarify this a bit - the meteor/tools/isobuild/package-source.js Lines 854 to 887 in 5e9ff34
You can see that the same I'll prep a PR for this. |
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, the `node_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 of `font-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 shared `SymlinkLoopChecker` 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 the `node_modules` directory. The `SymlinkLoopChecker` tracks all of the `node_modules` directories covered, so they can be watched for in the future (to prevent duplicate inclusions). Next, `_findAssets` is called using the same `SymlinkLoopChecker`. This means that if there are any `node_modules` symlinks used in the `public` or `private` 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 own `SymlinkLoopChecker` 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 of `node_modules` based symlinks, used in `public` and `private`. So in the case of `font-awesome` for example ``` public/fonts --> ../node_modules/font-awesome/fonts ``` becomes the following in the production application bundle ``` bundle/programs/web.browser/app/fonts/[all fonts files] ``` Fixes meteor#7013.
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, the `node_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 of `font-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 shared `SymlinkLoopChecker` 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 the `node_modules` directory. The `SymlinkLoopChecker` tracks all of the `node_modules` directories covered, so they can be watched for in the future (to prevent duplicate inclusions). Next, `_findAssets` is called using the same `SymlinkLoopChecker`. This means that if there are any `node_modules` symlinks used in the `public` or `private` 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 own `SymlinkLoopChecker` 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 of `node_modules` based symlinks, used in `public` and `private`. So in the case of `font-awesome` for example ``` public/fonts --> ../node_modules/font-awesome/fonts ``` becomes the following in the production application bundle ``` bundle/programs/web.browser/app/fonts/[all fonts files] ``` Fixes #7013.
Example app to reproduce the issue: https://github.com/Zodiase/Meteor-Tests/tree/public-files-no-symlink.
This is a clean new app without any extra packages. A demo npm package and a symlink to it are added to reproduce the issue.
Issue reproduced with Meteor 1.3.2.4 on OSX El Capitan.
Expected behavior
.meteor/local/build/programs/web.browser/app
should contain static files inpublic
.appurl/mdi/css/materialdesignicons.css
.appurl/foo.txt
.Actual behavior
.meteor/local/build/programs/web.browser/app
does not contain any static file inpublic
.appurl/mdi/css/materialdesignicons.css
brings up the app not the expected file.appurl/foo.txt
also brings up the app not the expected file.The text was updated successfully, but these errors were encountered: