Skip to content

eishay/Play-2.0-193-javascript-require-support-in-non-minimized-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 

Repository files navigation

Demonstrating the issue described at https://play.lighthouseapp.com/projects/82401/tickets/193-javascript-require-support-in-non-minimized-files "javascript require support in non-minimized files". The demo runs on Play 2.1-SNAPSHOT 21ba2e879b7912b44f1edf5f9e2ab6cf9fe5e4cb from https://github.com/playframework/Play20.git

The functionality demoed is described at http://www.playframework.org/documentation/2.0/AssetsGoogleClosureCompiler "CommonJS-style dependencies"

Fetching the javascripts

The following commands are fetching the test.js javascript file from https://github.com/eishay/Play-2.0-193-javascript-require-support-in-non-minimized-files/blob/master/requireDemo/app/assets/javascript/test.js The first call is fetching test.js, the second is fetching test.min.js While in test.min.js closure compiled require("lib") into its modules system, it did not do so with test.js.

Not Minified

$ curl http://localhost:9000/assets/javascript/test.js;echo;
// The test

require("lib");

function showSum(first, second) {
    alert(require("lib").sum(first, second));
}

showSum([2,3], 4);

Minified

$ curl http://localhost:9000/assets/javascript/test.min.js;echo;
var module$lib={};function sum$$module$lib(a,b){return a+b}module$lib.sum=sum$$module$lib;if(module$lib.module$exports)module$lib=module$lib.module$exports;var module$test={};module$lib;function showSum$$module$test(first,second){alert(module$lib.sum(first,second))}showSum$$module$test([2,3],4);if(module$test.module$exports)module$test=module$test.module$exports;

Here is a bit prettier test.min.js:

var module$lib={
};
function sum$$module$lib(a,b){
	return a+b
}
module$lib.sum=sum$$module$lib;
if(module$lib.module$exports)
	module$lib=module$lib.module$exports;
var module$test={
};
module$lib;
function showSum$$module$test(first,second){
	alert(module$lib.sum(first,second))
}
showSum$$module$test([2,3],4);
if(module$test.module$exports)
	module$test=module$test.module$exports;

About

example for the problem described at issue #193 "javascript require support in non-minimized files"

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published