Skip to content
Permalink
Browse files

Implement CompileStep.readAssetFromPackage

A rather hacky feature for #2506 and #2606
  • Loading branch information...
Slava committed Nov 1, 2014
1 parent 56d53e6 commit 6600c1dfe0c78a048fcf50f4de7c6aaa33a9a4e1
Showing with 18 additions and 0 deletions.
  1. +18 −0 tools/compiler.js
@@ -707,6 +707,24 @@ var compileUnibuild = function (isopk, inputSourceArch, packageLoader,
return ret;
},

/**
* @summary Read the asset from certain package on a given path, returns a
* buffer. The package should be a dependency of the build target. The
* asset should be included on the same arch as the compiled file.
* @param {String} package Name of the requested package.
* @param {String} assetPath Path to the asset relative to the requested
* package.
* @instance
* @memberOf CompileStep
*/
readAssetFromPackage: function (package, assetPath) {
var pkg = packageLoader.getPackage(package, { throwOnError: true });
var unibuild = pkg.getUnibuildAtArch(inputSourceArch.arch);
var asset =
_.findWhere(unibuild.resources, { type: 'asset', path: assetPath });
return asset.data;
},

/**
* @summary Works in web targets only. Add markup to the `head` or `body`
* section of the document.

7 comments on commit 6600c1d

@mizzao

This comment has been minimized.

Copy link
Contributor

replied Nov 1, 2014

Yes, I am interested! Looping in #2506 people.

I think this is a slightly different issue than what I described, because it gives a way to get files from other packages. That is very useful, I admit. However, I don't see an easy way to take another package's file and use api.addFiles in a depending package, which would help solve issues like in https://github.com/mizzao/meteor-sharejs/blob/master/sharejs-base/package.js.

Another similar use is that we need to be able to search through the paths of the package. Here is a list of packages I know of that are doing something like this:

In that case we just want to be able to look up files, and currently we are doing our own stuff with the working directory. Maybe you can suggest a better solution?

@mizzao

This comment has been minimized.

Copy link
Contributor

replied Nov 1, 2014

I understand these are two different use cases, maybe we can talk about it more if you are interested.

@Slava

This comment has been minimized.

Copy link
Member Author

replied Nov 1, 2014

@mizzao I am confused on your post. As I see it, there are several cases:

  • Packages can get their asset served path (for client-side assets): 56d53e6
  • Packages can get their assets in the build step: 6600c1d
  • Packages can get paths of other package's assets: 47f265f

Which one is ShareJS?

@mizzao

This comment has been minimized.

Copy link
Contributor

replied Nov 1, 2014

It appears to be neither of those. It is the ability to traverse the package's subdirectories looking for file paths for which to call addFiles (both asset and normal.)

One might think this is silly, given that the package should know about it's own files. But for big packages wrapping other things, it's smelly to hard-code in the filepaths (and new files may appear in each new version.)

@Slava

This comment has been minimized.

Copy link
Member Author

replied Nov 1, 2014

@mizzao yeah, your issue sounds more like a feature request for doing addFiles(".npm/special/path/**/*.js", 'web'). Am I understanding correctly?

@mizzao

This comment has been minimized.

Copy link
Contributor

replied Nov 1, 2014

I guess so - and not even necessarily things in .npm/, especially for packages that use submodules to wrap other software.

BTW what is 'web' now, is that different from 'client'?

@1seck

This comment has been minimized.

Copy link

replied Sep 2, 2016

Hi there,

can this help in getting a meteoric app to the app store. The scss won't compile right with TestFlight.
Google's Play Store is fine.

Regards

Please sign in to comment.
You can’t perform that action at this time.