grunt requirejs ignores paths from my mainConfigFile

跟風遠走 提交于 2019-12-05 05:45:48

r.js uses Esprima as Javascript parser to extract the config object from the specified mainConfigFile. It only looks for certain signatures in the code.

Look at

  • hasRequire(): determine the AST node is a configuration call candidate
  • findConfig(): calls the above deciding how to extract the config

I've created a patch making it aware of recognizing

requirejs.config(_VariableToExport = { ... });

This is limited and the Javascript parser approach makes it very complicated to make r.js able to extract configurations that were created by functions (like in your code) or so. This patch has not been submitted to the project yet. I'm struggling with bureaucracy yet.

I think the only working workaround so far is

  • not to use mainConfigFile
  • exporting the config as NodeJS module
  • requiring the main.js/config.js in Node (Grunt)
  • passing the object as value to the config attribute or method

See my comment to this issue for a scribble.

This approach is proven in another, a bit older project I'm working on.

Related to r.js 2.1.11.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!