Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Support onBuildRead option #199

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Support onBuildRead option #199

wants to merge 2 commits into from

Conversation

Rush
Copy link

@Rush Rush commented Oct 23, 2014

To support Angular.JS one has to prevent uglifier destroying the function arguments for dependency injection. One solution is to convert those arguments into a different uglier syntax that will prevail uglification. onBuildRead needs to be passed to r.js as a literal function, not a string that's what this pull request does.

Example usage:

modules:
  - name: 'application'
onBuildRead: "function (moduleName, path, contents) { return require('ng-annotate')(contents, {add: true}).src;}"

requires installing ng-annotate
npm-install -g ng-annotate

@carsomyr
Copy link
Collaborator

@RushPL Thanks! Before I get around to this, can you say if your PR is related to this one?

@Rush
Copy link
Author

Rush commented Oct 23, 2014

It is but I added support for only one specific field that must be a function :)

@carsomyr
Copy link
Collaborator

@RushPL Can you explain how adding functions is the only solution? Is onBuildRead a compile time concept or something like that?

@Rush
Copy link
Author

Rush commented Oct 23, 2014

I have never said it is the only solution but it is the only solution I know that can integrate with requirejs-rails. One could use grunt for example instead. Yes, it is purely compile/build time. It simply passes this raw function input input to rjs_driver.js, this input can arbitrarily preprocess the code.

@carsomyr
Copy link
Collaborator

@RushPL Thanks for the explanation. Looks like the gem will have to accommodate functions to modify r.js behavior in the near future.

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

Successfully merging this pull request may close these issues.

2 participants