Add shim to compile optimiser config (with test).#135
Add shim to compile optimiser config (with test).#135maxpeterson wants to merge 3 commits intocaolan:masterfrom
Conversation
|
@caolan have you had a chance to look at this? It is blocking us from using If there is anything I can do let me know. |
|
I'm running into the same problem right now actually with the added issue of I need to supply extra shim configuration. It would appear that the require.config.js for jam gets regenerated and is not a safe place to do this so I have a separate file that specifies our additional shim info. Again, in a non-optimized site it works fine, but once you run everything through |
|
@copenhas you can usually put the shim in the package.js. Have you tested with this branch. The only change you actually need for the fix is in |
|
@maxpeterson I haven't tested with this branch. I've been fighting this issue for a little over a day and once I knew what was happening I started searching. Great to see that the exact issue is trying to be resolved, but at the moment I need to get this working and will probably resort to globals temporarily. |
This is the same issue as caolan/jam/#113 with the addition of a test.
The crux of this issue is that if you use shim to define that a package
exportsa variable (e.g. Backbone or in mytest PackageOne) then this shim is needed by require's optimiser to defines the package such that it returns the exported variable.My test includes a module with main.js:
and package.js:
If the shim is not passed to the optimiser then it will define
package-one/mainas:define("package-one/main",function(){})If shim is passed to the optimiser then it will define
package-one/mainas:define("package-one/main",function(e){return function(){var t,n;return t||e.PackageOne}}(this));In both cases
package-oneis defined asdefine("package-one",["package-one/main"],function(e){return e})The result is that without the shim any package that requires
package-oneas a dependency will not get passed PackageOne:In addition I fixed some typos in the other integration tests,