Giter Site home page Giter Site logo

eishay / play-2.0-193-javascript-require-support-in-non-minimized-files Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 140 KB

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

Home Page: https://play.lighthouseapp.com/projects/82401/tickets/193-javascript-require-support-in-non-minimized-files

play-2.0-193-javascript-require-support-in-non-minimized-files's Introduction

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;

play-2.0-193-javascript-require-support-in-non-minimized-files's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.