Skip to content
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

Assets.absoluteFilePath() is undocumented and doesn't work in build plugins #6552

Closed
tmeasday opened this issue Mar 22, 2016 · 2 comments
Closed
Milestone

Comments

@tmeasday
Copy link
Contributor

CF: 134707b#commitcomment-16742686

In the above commit, Assets.absoluteFilePath was implemented in tools/static-assets/server/boot.js. However the documentation for the other Assets APIs is in tools/isobuild/bundler.js, where the Assets APIs are duplicated.

This was confusing. It turns out the reason for this is when you are using the asset API from a build plugin. The only way you can do this is:

  1. You have a build plugin X, that depends on package Y.
  2. X calls Y.foo()
  3. Y.foo() calls Assets.Z() -- this version of Assets.Z() is the bundler.js version.

Note that if Y.foo() is called from application code (possibly via some other package), it will use the version in boot.js.

The issue is that in bundler.js, we have the contents of the asset but not the on-disk path. This makes implementing Assets.absoluteFilePath difficult there.

Options from here:

  1. Leave Assets.absoluteFilePath() undocumented.
  2. Document Assets.absoluteFilePath() in boot.js and explain the limitation there (it's probably unlikely anyone will ever even try to use in the above way.
  3. Try and figure out a way to implement Assets.absoluteFilePath() in the bundler.js context (if this is even possible.
@tmeasday tmeasday added this to the Post-1.3 milestone Mar 22, 2016
@aldeed
Copy link
Contributor

aldeed commented Apr 8, 2016

I like option 2, at least until someone complains it doesn't work in the build plugin.

@tmeasday
Copy link
Contributor Author

tmeasday commented Jun 8, 2016

Ok, finally did this.

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

No branches or pull requests

2 participants