requirejs / r.js Goto Github PK
View Code? Open in Web Editor NEWRuns RequireJS in Node and Rhino, and used to run the RequireJS optimizer
License: Other
Runs RequireJS in Node and Rhino, and used to run the RequireJS optimizer
License: Other
Update the integrated uglifyjs to 1.1.1, the latest tag available.
I looked at implementing it and it looks fairly strait forward, however I don't have time to ensure I don't screw up requirejs in the process, and the optimization function will have to be async as well.
http://code.google.com/closure/compiler/docs/gettingstarted_api.html
Not really an issue, but wasn't sure where else to post this
Is it possible to include the r.js config file in other node scripts? I've tried requiring it and assigning it to a variable but obviously there are no exports etc...
How does r.js load the build config file?
I was hopping that we could do something like this:
/*!
* RequireJS plugin for loading JSON files
* - depends on Text plugin and it was HEAVILY "inspired" by it as well.
*
* IMPORTANT:
* it doesn't work on the current version of RequireJS optimizer (as of 2011/06/11).
* code for build process is for future versions (if it starts working).
*
* @author Miller Medeiros
* @version 0.0.1 (2011/06/10)
* Released under the WTFPL <http://sam.zoy.org/wtfpl/>
*/
define(['text'], function(text){
var jsonParse = (typeof JSON !== 'undefined' && typeof JSON.parse === 'function')? JSON.parse : function(val){
return eval('('+ val +')'); //quick and dirty
},
buildMap = {};
//API
return {
load : function(name, req, onLoad, config) {
text.get(req.toUrl(name), function(data){ //this fails during build since `text` is undefined
if (config.isBuild) {
buildMap[name] = data;
onLoad(data);
} else {
onLoad(jsonParse(data));
}
});
},
//write method based on RequireJS official text plugin by James Burke
//https://github.com/jrburke/requirejs/blob/master/text.js
write : function(pluginName, moduleName, write){
if(moduleName in buildMap){
var content = buildMap[moduleName];
write('define("'+ pluginName +'!'+ moduleName +'", function(){ return '+ content +';});\n');
}
}
};
});
I know that a plugin for JSON is kind stupid since if you have the files locally you can just wrap them into a define
call and if it is on your server you can just load it as text and parse the JSON data, but you get the idea...
Doing a node r.js main.js to run an app in Node 0.5.3 with this error:
Error: require.paths is removed. Use node_modules folders, or the NODE_PATH environment variable instead.
Need to change the approach used in that code.
Optimization still works in 0.5.3, just app running seems to fail.
this was happening even before r.js was split into a separate project.
When optimizing an app I noticed that r.js does not copy any files starting with a period (.) to the new "build" location. Specifically it is skipping .htaccess. There is a regexp to skip over hidden directories but that isn't it exactly. Looking inside r.js, the RegExp /\w/
is used when calling file.getFilteredFileList
.
So it should not include 'b' below:
define(['a'], function(require, a) {
require(['b'], function (b) {
});
});
Or, since 1.0 shipped with this parsing and some may depend on it now, allow it only with a build config setting.
When doing a Whole Project optimization, all calls to file.copyDir() fail when running from node.js on windows. The file.copyDir() function calls path.normalize() on the srcDir and destDir parameters which converts the paths to backslashes.
This mistake prevents all files from being copied since the call to file.getFilteredFileList() returns paths with only forward-slashes and later the paths fail to combine to create valid file-paths due to the slash-conflicts.
To fix this issue, I added a quickfix to my local r.js at line 2462 as follows;
if(isWindows) {
srcDir = srcDir.replace(/(\\)/g, '/');
destDir = destDir.replace(/(\\)/g, '/');
}
main.js
file:
define(['foo/main']), function() {});
app.build.js
file:
...
modules: [{
name: 'main',
exclude: ['foo/main']
})
...
My foo/main
is from a separate library (e.g. not in any local directory) but is a dependency of my main
module.
I get an Error evaluating module "undefined" at location ... Bad file descriptor
even though I am excluding it from the build. The hack I am using write now is to simply add foo
to the paths
hash, so it doesn't fail:
paths: {
'foo': '.'
}
Everything works as expected once I do this, but it seems that all paths are attempting to be found prior to taking in account the excluded ones.
http://requirejs.org/docs/release/0.27.1/r.js
line: 8966
requirejs.define = define;
module.exports = requirejs;
return;
}
if (commandOption === 'o') {
//Do the optimizer work.
loadLib();
/**
* @license Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/jrburke/requirejs for details
*/
/*
* Create a build.js file that has the build options you want and pass that
* build file to this file to do the build. See example.build.js for more information.
*/
/*jslint strict: false, nomen: false */
/*global require: false */
require({
baseUrl: require.s.contexts._.config.baseUrl,
//Use a separate context than the default context so that the
//build can use the default context.
context: 'build',
catchError: {
define: true
}
}, ['env!env/args', 'build'],
function (args, build) {
build(args);
});
Consider this build config:
({
appDir: "../app",
baseUrl: "./js",
dir: "../public",
modules: [
{ name: "common"},
{ name: "bundles/index", exclude: ["common"]},
{ name: "bundles/gradebook", exclude: ["common"]},
{ name: "bundles/quiz", exclude: ["common"]}
]
})
When you land on the index page, the common bundle script tag will be injected by RequireJS. We use the src=foo.js?v=1
method to take advantage of browser caching, and to not get bitten by it, but we don't have control over the tags that RequireJS injects aside from urlArgs
.
Currently we set urlArgs
to the build number of our app to ensure users get the latest JS. The problem is that we release every 2 weeks, and have plenty of hot fixes in-between, so our users will have to download every optimized module every time we release :(
I'd propose a "version" key in a module's build config so that when RequireJS fetches a script, it'll append the version as urlArgs (or any other implementation that has the same effect)
({
appDir: "../app",
baseUrl: "./js",
dir: "../public",
modules: [
{ name: "common", version: "1"},
{ name: "bundles/index", exclude: ["common"], version: "2"},
{ name: "bundles/gradebook", exclude: ["common"], version: "2"},
{ name: "bundles/quiz", exclude: ["common"]}
]
})
This way a single module can change versions w/o requiring the entire front-end app to be downloaded again.
node build/r.js -o src/app.build.js (source files in src/
app.build.js
({
paths: {
lib: "../lib",
"dist.depends": "../dist/depends"
},
//appDir: './',
baseUrl: '.',
dir: '../dist/src',
skipModuleInsertion: false,
//optimize: 'none',
modules: [
{
name: "app"
}
]
})
On Linux this works fine, on windows I get the following error:
node.js:189
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Error evaluating module "undefined" at location "":
Error: Path is not supported: c:\Users\dwells\work\dist\src/
Optimizer can only handle local paths. Download the locally if necessary and upd
ate the config to use a local path.
fileName:undefined
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
at makeError (c:\Users\dwells\work\columbus\build\r.js:183:17)
at execManager (c:\Users\dwells\work\columbus\build\r.js:691:23)
at Object.onDep (c:\Users\dwells\work\columbus\build\r.js:738:33)
at execManager (c:\Users\dwells\work\columbus\build\r.js:706:45)
at Object.onDep (c:\Users\dwells\work\columbus\build\r.js:738:33)
at execManager (c:\Users\dwells\work\columbus\build\r.js:706:45)
at Object.onDep (c:\Users\dwells\work\columbus\build\r.js:738:33)
at execManager (c:\Users\dwells\work\columbus\build\r.js:706:45)
at Object.onDep (c:\Users\dwells\work\columbus\build\r.js:738:33)
at execManager (c:\Users\dwells\work\columbus\build\r.js:706:45)
I traced out which manager created the error, here's what it's object looks like.
{ waitId: '_r@@0',
depCount: 2,
depMax: 2,
prefix: null,
name: undefined,
fullName: undefined,
deps:
{ 'env!env/args': [],
build:
{ [Function]
_run: [Function],
convertArrayToObject: [Function],
makeAbsPath: [Function],
createConfig: [Function],
findBuildModule: [Function],
removeModulePath: [Function],
traceDependencies: [Function],
flattenModule: [Function],
anonDefRegExp: /(^|[^\.])(require\s*\.\s*def|define)\s*\(\s*(\/\/[^\n\r]
*[\r\n])?(\[|f|\{)/,
toTransport: [Function] } },
depArray: [ 'env!env/args', 'build' ],
callback: [Function],
onDep: [Function],
isDone: true }
Hi!
I'd like to use the optimizer from expressjs to serve optimized builds on the fly.
Being able to do something like this would be helpful and bypass the need of a mktemp call :
var config = {
baseUrl: '../appDir/scripts',
name: 'main',
out: false //or whatever
};
requirejs.optimize(config, function (buildResponse,actualCode) {
//var contents = fs.readFileSync(config.out, 'utf8');
var contents = actualCode;
});
Thanks in advance!
@timmywil found that doing a build with an appDir: that had about 450mb of files in it ended up using 600mb before doing the actual dependency tracing.
So there seems to a be a weakness in the copyDir code for node, which does sync file copying via binary writes. This was done because of the ease of dealing with sync file code, but probably need to switch to:
That second one is a bit hacky, and since it would imply needing a callback into file.copyDir, might as well try the stream approach.
As of 1.0.2, license comments are preserved, as fixed in Issue #41. However, as @GEDDesign points out, the optimized file might have many licenses in it, and it may make more sense to have a smaller comment that just has a link to a page that lists all the license info.
So, maybe provide a 'preserveLicenseComments' to be default true, but if set to false, skips this work.
From the example build configuration file it seems to state that if you left out appDir
that no files except the output minified file would be in dir
. However it seems to take the contents of baseUrl
and places it into dir
along with the built script.
As a result I tried appDir: ""
and appDir: path/to/empty/folder
and both give the same result as above. Is there a way to run r.js and output 1 file containing the module specified and all it's dependencies?
while running a slightly complex build with multiple modules, r.js is tracing same dependencies multiple times so the build process takes forever.
eg:
({
baseUrl : '../js',
dir : '../../deploy/js/',
paths : {
'text' : 'lib/require/text',
'jquery' : 'lib/jquery/jquery',
'signals' : 'lib/signals',
'crossroads' : 'lib/crossroads'
},
modules : [
{
name : 'main', //this module loads everything that is shared across site
include : [
'text',
'signals',
'crossroads'
]
},
{
name : 'section/projects',
exclude : [ //exclude everything already loaded by "main.js"
'text',
'jquery',
'signals',
'widgets/Pagination',
'core/AbstractSection'
]
},
{
name : 'section/contact',
exclude : [ //exclude everything already loaded by "main.js"
'text',
'jquery',
'signals',
'widgets/Pagination',
'core/AbstractSection'
]
}
]
})
r.js will trace dependencies of all files on the "exclude" list even if the dependencies was already traced before... I think it should cache the values between modules and only do the process once since it is the same build and paths will resolve to same location...
amdefine allows using define() in a node module, but the optimizer should not build it in, since it is not needed for optimizer output -- there will already be a define available.
Strip out mentions of this code:
if (typeof define !== 'function') { var define = (require('amdefine'))(module); }
Allow for spaces/line returns in the above and for 'amdefine' to be a relative ID.
Lines 78-84 in require.js
:
function makeError(id, msg, err) {
var e = new Error(msg + '\nhttp://requirejs.org/docs/errors.html#' + id);
if (err) {
e.originalError = err;
}
return e;
}
404 returned from http://requirejs.org/docs/errors.html
Not sure if this is an issue with requirejs.org or if the URL needs to be updated. I don't see anything related to errors in http://www.requirejs.org/docs/
How I can handle errors like to "Cannot find module" when I use it with node?
From http://requirejs.org/docs/api.html#jsfiles :
Script names that are just regular paths ending in ".js", start with a "/" or have a protocol in them are always mapped relative to the HTML page instead of relative to baseUrl, just like HTML <script> src="" values.
The optimizer still looks for *.js files using the baseUrl, set in the build config file, as if they were modules. This is different behavior than what require.js does, and so it fails to find them. Instead, it should look for them relative to the project/output directories, or some other special parameter specifically for .js files.
I'm using this r.js and have an odd configuration to build my require module..:
My directory structure looks like:
I want to build Project/examples/lib/main.js
and most of my dependencies happen to fold under Project/src
. The problem that I ran into is that when I run node
from Project/examples/lib
with these options (below) it actually compiles Project/src/main
. I assumed that this is because the baseUrl
is set to the src
directory. It should also be noted that everything runs fine without errors locally and remotely when not building.
node ../../utils/r.js -o \
name=main out=./build/example.js \
baseUrl=../../src \
paths.text=../third-party/requirejs/text
...
So, I tried changing the name
property to name=../examples/gui/main
. This works except that one of my dependencies in Project/examples/lib/main.js
relies on the plugin text.js (content.html
) and somehow r.js
misreads where that particular file is... it resolves the path to content.html to:
/Project/src/../examples/examples/examples/lib/contents.html
I'm not positive, but I'm pretty sure that somewhere in r.js it's being resolved incorrectly, because I've console.log
'd in text and the path was already resolved by the time text tried to find the file and threw the error in node. I don't want to jump to conclusions, but I think this is a bug โย I feel strongly towards the API resolving the name
property agnostic of baseUrl
and / or this odd case of text!
being fixed.
Cheers,
-Jono
From this thread:
http://groups.google.com/group/requirejs/browse_thread/thread/f1fd5645b406ab2c
So when doing a full project optimization (not a single file optimization) have an option to remove the files that were rolled up into a layer. Miller's suggestion is "removeCombined" as the option.
This was reported as issue 141 in the requirejs project, but opening a bug here so that milestone fixes are accurately reflected.
Basic issue is that parse.findRequireDepNames sometimes has an undefined call value, so just skip those since they do not match what we are looking for.
Is there a way to apply a partial rewrite to the dependency paths? Like using a regExp in the app.build.js? I would like to rewrite something like ${version} to an explicit version.
Currently the snaptshots are versioned by file name but I would like to keep the file name as r.js on my projects and just update the content (for version control) the problem is that there is no way to know which snapshot I am using since version only shows as r.js 0.25.0+
.
It would be cool if it had something like r.js 0.25.0+ (2011/08/11)
, maybe even add time since some days you do more than 1 snapshot.
If findNestedDependencies: true, and have a has: {} config in the build config, then depending on the has: {} config used in the build, only certain one(s) of these nested require() calls should be found for dependency tracing:
define(['require', 'a'], function(require, a) {
if (has('needC')) {
require(['c'], function (c) {
});
} else if (has('needB')) {
require(['b'], function (b) {
});
} else {
require(['d'], function (d) {
});
}
});
jQuery 1.7 has this kind of define check due to the widespread use of jQuery:
if (typeof define === 'function' && define.amd && define.amd.jQuery) {
}
Right now that last define.amd.jQuery will not get converted to the namespaced name. Update r.js to catch it.
issue when optimizing whole project and also while trying to optimize a single file.
@import url('./foo/bar.css');
body{background-image:url('../img/lol_cat.jpg')}
#bar{background-image:url('../../../img/unicorn.jpg')}
#bar{background-image:url(./img/unicorn.jpg)}
body{background-image:url(../img/lol_cat.jpg)}
#bar
background image is pointing to wrong folder.
issue only happens if @import url
starts with a relative path ("./") - replacing first line of main.css with @import url('foo/bar.css');
produces the desired output.
Today I've replaced my r,js v0.2.6 to v1.0.0 and got Regexp error at line 5801. Checked with v0.2.7 also with same result then changed regexp pattern to RegExp object like this:
var re = new RegExp("<\x2fscript([>/\t\n\f\r ])","gi");
ret = ret.replace(re, "<\\/script$1");
It seems Rhino has problem to understand regexp patterns...
Hi James,
It seems that during the optimization step in r.js, define.amd is undefined. This causes issues when executing plugins during optimization.
Please refer to this gist for an example: https://gist.github.com/1349759
Running r.js -o name=main.js baseUrl=. out=out.js
on this example will result in the following output:
Tracing dependencies for: main.js
Has define(): true
Has define.amd: false
It's broken :(
I'm not sure whether r.js is supposed to set define.amd, but to me it feels like it should. During optimization plugins are evaluated as regular AMD modules, and as such their dependencies are also loaded. By not setting define.amd the contract for AMD is being violated and causing unpredictable results with plugin dependencies.
Thanks for your time :)
Hi guys,
i making some test cases and its imposible to preserve the comments from source files, in need to include my copyright info at the begining of file ...
take a look ...
modules: [
{
name: "foo", // merge requirejs with foo file from src folder
include: ["../vendor/requirejs/require", "foo"],
create: true
}
]
note: in my foo.js file from source folder we have an comment like ...
/*! wooooot copyright ... fooo ... blaaa ... 2011 */
i doing something wrong ??!?!
thks !
One of the common boilerplates may look like so:
(function (factory){
if(typeof define === 'function' && define.amd){
define(['dep'], factory);
}else{
factory(this.dep);
}
}(function(dep){
}));
However, the AST parsing skips that define call. However the anonymous define calls do name the define call correctly.
Update the AST parsing to find the above. Test the namespacing code with this pattern too.
When a namespace is defined in app.build, r.js fails to name anonymous modules in the output.
In 0.2.6/0.2.6+. If you run a build with a namespace defined, r.js fails to find the namespaced define/require/etc calls in the module's source, and leaves the output file with anonymous definitions that fail at runtime.
I did some debugging and here's what I found. The regexp (build.anonDefRegExp) used to match the definitions doesn't pick them up after the namespacing happens (which does happen before the toTransport stuff). A dot preceding require/def/define prevents the namespaced match from happening.
var rex = /(^|[^\.])(require\s*\.\s*def|define)\s*\(\s*(\/\/[^\n\r]*[\r\n])?(\[|f|\{)/;
rex.test('define(){}'); //true
rex.test('foo.define(){}'); //false
The simpleNamespace.build.js test defines 2 modules, one and dimple, that are named explicitly within their source. If I make those anonymous then I was able to confirm that NAMESPACE.js does in fact have modules left unnamed.
I'd try to fix and submit a pull but this seems involved and might involve design decisions. I assume there's very good reason not to go after already namespaced AMD method calls. As far as ideas, one possible solution could simply be to add the namespace to the regexp dynamically and allow a match to begin with ([namespace].). Alternatively, the substitution could come before the namespacing.
PS - If anyone needs a workaround, just drop '// define()' as a comment at the top of your source file. It'll trick the optimizer into checking the file for substitution), which it will then perform properly. (The reason that works is that the namespace is only added to the first define() in the file, leaving at least 1 define call un-namespaced to get picked up by the regexp. That call eventually gets namespaced within contents.replace so it comes out ok.)
In my setup I see that "included" modules are in fact not included in the target file, their dependencies are, though.
My setup is r.js 1.0.1 with node 0.6.1 on Windows 7 x64.
The outcome of this problem is similar to what is described in this thread: http://groups.google.com/group/requirejs/browse_thread/thread/2fc8a1de59b9a129/
I have narrowed it down to the following scenario:
/public
/public/main.js
/public/include-not-working.js
app.build.js
where both modules depend on "empty:" modules:
/public/main.js:
require(['empty1'], function () { });
/public/include-not-working.js:
define(['empty2'], function () { });
the build file app.build.js:
({
baseUrl: 'public/',
optimize: 'none',
paths: {
'empty1': 'empty:',
'empty2': 'empty:'
},
modules: [{
name: 'main',
include: ['include-not-working']
}]
})
The build output build.txt is:
main.js
--
main.js
Expected the list to also contain 'include-not-working.js"
Problem seems to be triggered by 'empty:' modules in dependencies.
e.g.:
//
// this is a comment
//
define(function(){
...
});
will output
//
// this is a comment
//define(function(){
...
});
it only happens because of the empty //
before define
and if you set optimization to none since closure compiler removes all the comments..
Hello,
I'm having a problem with the current version of uglify-js used in requirejs, and it seems the new version would fix it.
Is it possible to provide requirejs with another uglify-js instead of the one embedded in it without rebuilding it ?
Since it's on a Node.js project indeed heavily relying on NPM, it would be ideal if we could keep going with the official packages while overriding only uglify-js.
Thanks for any help.
Hello,
I am running the latest r.js snapshot and I am getting the following error:
Minifying file: C:/Projectos/spreadd/SpreaddClient/js/./../../client-prod/js/app.build.js
js: ".\r.js", line 1632: exception from uncaught JavaScript throw: Error: Error evaluating module "undefined" at locatio
n "undefined":
TypeError: Cannot call property value in object [JavaPackage com.google.common.flags.Flag]. It is not a function, it is
"object".
fileName:undefined
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
I am using the following command to run r.js:
java -classpath "C:\rhino1_7R3\js.jar;c:\rhino1_7R3\compiler.jar" org.mozilla.javascript.tools.shell.Main .\r.js -o .\app.build.js
Is this a known issue?
Thanks
Files with requirejs() calls in them do not have their dependencies scanned.
See this thread for more information, in particular this message.
The goal was to be able to use a module name that maps to a package as the target for a build layer.
I want to encourage moving away from package config in general, but I will create this issue to track the request in case there are others that feel this is important to have.
If i add more than one module name to build, in the production.js after the build is done i am getting file duplicates, text,i18n,order plugins are added more than once. text files and language file are also added more than once, I am also adding the build production.js file for reference, please scroll bottom to see the multiple additions
if i change the order in build file i am getting duplicates, just search for define('i18n' in the gist link, the production.js will have 2 "i18n" modules, production1.js will have 1 "i18n" module, the only difference is the module order in build file
If i add require inside define that is not combined during the build process, try loading html file in some function and build the file html file is not added to the build it is loaded using a separate request
({
appDir: "../",
baseUrl: "web/",
dir: "../../project-build",
//Comment out the optimize line if you want
//the code minified by UglifyJS
optimize: "none",
paths: {
"order": "../common/js/vendor/requirejs/plugins/order",
"text": "../common/js/vendor/requirejs/plugins/text",
"i18n": "../common/js/vendor/requirejs/plugins/i18n",
"wsl":"../common/js/vendor/wsl/base",
"goog":"../common/js/vendor/goog",
"bootstrap":"../common/js/vendor/bootstrap",
"iscroll":"../common/js/vendor/iscroll",
"jquery":"../common/js/vendor/jquery",
"layout":"../common/js/vendor/layout",
"mustache":"../common/js/vendor/mustache",
"underscore":"../common/js/vendor/underscore/underscore",
"spine":"../common/js/vendor/spine",
"models":"../core/models",
"web":"modules", // this is the base path for web
//All modules should be configured here
"web.config":"modules/config/config",
"web.app":"modules/app/app",
"web.actionBar":"modules/actionBar/actionBar",
"web.sideBar":"modules/sideBar/sideBar"
},
modules: [
//for some reasons if you add more than one module here during the build process modules are added twice and sometimes thrice
// so if you want to make a build for production add dependencies in production.js file
{
name: "production"
},
{
name: "web.sideBar"
}
]
})
require.config({
//what ever paths you mention here should be copied to build file
paths: {
"order": "../common/js/vendor/requirejs/plugins/order",
"text": "../common/js/vendor/requirejs/plugins/text",
"i18n": "../common/js/vendor/requirejs/plugins/i18n",
"wsl":"../common/js/vendor/wsl/base",
"goog":"../common/js/vendor/goog",
"bootstrap":"../common/js/vendor/bootstrap",
"iscroll":"../common/js/vendor/iscroll",
"jquery":"../common/js/vendor/jquery",
"layout":"../common/js/vendor/layout",
"mustache":"../common/js/vendor/mustache",
"underscore":"../common/js/vendor/underscore/underscore",
"spine":"../common/js/vendor/spine",
"models":"../core/models",
"web":"modules",
//All modules should be configured here
"web.config":"modules/config/config",
"web.app":"modules/app/app",
"web.actionBar":"modules/actionBar/actionBar",
"web.sideBar":"modules/sideBar/sideBar"
},
waitSeconds: 15,
locale: "fr-fr"
});
require(
[
'wsl',
'order!spine/spine',
'order!spine/route',
'order!spine/manager',
'layout/layout',
'iscroll/iscroll'
],function(){
wsl.provide('web');
wsl.provide('web.Config');
//Start Application
require(['order!web.config','order!web.app'], function(config,App){
web.Config = config;
$(document).ready(function(){
var app = new App();
app.start();
});
});
});
require(['main'],function(){
//from here main config will be loaded so the urls will be changed according to the config
require(['web.sideBar']);
require(['web.actionBar']);
});
define('web.sideBar',
[
'text!web/sideBar/html/sideBar.html!strip',
'text!web/sideBar/css/sideBar.css',
'i18n!web/sideBar/nls/i18n'
],
function(html,css,language){
var SideBar = Spine.Controller.sub();
SideBar.extend({
module: {
name: 'web.sideBar',
css: css,
lang: language
}
});
SideBar.include({
init: function(){
this.render();
},
render: function(){
console.log("I am render from Side Bar");
var self = this;
var options = {
element: self.el,
tpl:html,
module:SideBar.module
};
wsl.module.render(options);
},
bindEvents: function(){
}
});
return SideBar;
});
define('web.actionBar',
[
'text!web/actionBar/html/actionBar.html!strip',
'text!web/actionBar/css/actionBar.css',
'i18n!web/actionBar/nls/i18n'
],
function(html,css,language){
var ActionBar = Spine.Controller.sub();
ActionBar.extend({
module: {
name: 'web.actionBar',
css: css,
lang: language
}
});
ActionBar.include({
init: function(){
this.render();
},
render: function(){
console.log("I am render from Action Bar");
var self = this;
var options = {
element: self.el,
tpl:html,
module:ActionBar.module
};
wsl.module.render(options);
},
bindEvents: function(){
}
});
return ActionBar;
});
Use of node/r.js uglify resulted in JavaScript code which failed under FireFox 5. It's suspected that the problem may be in r.js. Please see:
mishoo/UglifyJS#196
See Issue #51 for an example -- while an error may be printed out, the next part of the script is still executed. It would be nice to have execution stop after any error. Just need to set up some shell flag.
Not really an issue, but wasn't sure where else to post this
Is it possible to include the r.js config file in other node scripts? I've tried requiring it and assigning it to a variable but obviously there are no exports etc...
How does r.js load the build config file?
Normally, require('coffee-script')
allows you to directly require
.coffee libraries from that point onwards.
In a flat directory hierarchy this still works with r.js
. However, when r.js
is run out of a child directory from the project, say tools
, it successfully loads javascript modules but not coffee modules.
The error is:
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Error evaluating module "./coffee-library" at location "././coffee-library.js":
Error: Calling node's require("./coffee-library") failed with error: Error: Cannot find module './coffee-library'
fileName:undefined
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
at makeError (/Users/eboto/rjsexample/tools/r.js:183:17)
at execManager (/Users/eboto/rjsexample/tools/r.js:691:23)
at main (/Users/eboto/rjsexample/tools/r.js:821:17)
at callDefMain (/Users/eboto/rjsexample/tools/r.js:834:18)
at Object.completeLoad (/Users/eboto/rjsexample/tools/r.js:1417:21)
at Function.load (/Users/eboto/rjsexample/tools/r.js:2238:17)
at Function.get (/Users/eboto/rjsexample/tools/r.js:2181:21)
at Object.require (/Users/eboto/rjsexample/tools/r.js:1336:36)
at /Users/eboto/rjsexample/tools/r.js:1579:24
at /Users/eboto/rjsexample/script.js:3:1
Hello James
not really an issue but I just noticed that r.js complains when you add a ";" at the end of the build profile file
Is it intended ? my build file was generated from a coffee file and thus was adding this extra ;
({
appDir: "client"
...
});
Error Message
js: "r.js", line 1629: exception from uncaught JavaScript throw: Error: Error evaluating module "undefined" at location "":
Error: Path is not supported: D:/Working/Cofamilies-JS/public/
Optimizer can only handle local paths. Download the locally if necessary and update the config to use a local path.
fileName:undefined
lineNumber: undefined
http://requirejs.org/docs/errors.html#defineerror
Directory structure (Volume D)
Command line
java -classpath ./js.jar;./compiler.jar org.mozilla.javascript.tools.shell.Main r.js -o onramp-build.js
Build file
({
appDir: "public",
baseUrl: "javascripts",
dir: "public-build",
modules: [
{
name: "onramp"
}
]
})
Bits
r.js, compiler.jar and js.jar from package 0.25.0
And...
Modifying... build file to try to generate paths without a volume...
appDir: "/Working/Cofamilies-JS/public",
baseUrl: "javascripts",
dir: "/Working/Cofamilies-JS/public-build",
Generates... Error: Path is not supported: D:/Working/Cofamilies-JS/public-build/javascripts/
when minifying soundmanager2-nodebug.js using r.js 1.0.2 i get
js: "build/r.js", line 7656: exception from uncaught JavaScript throw: Error: Error evaluating module "undefined" at location "undefined":
JavaException: java.lang.RuntimeException: java.lang.RuntimeException: INTERNAL COMPILER ERROR.
Please report this problem.
index (1) must be less than size (1)
Node(BLOCK): D:/Prod/trunk/src/web/static_websites/uranus/src/main/www/scripts/../../../../out/main/www/scripts/libs/soundmanager2-nodebug.js:19:35
function SoundManager(smURL, smID) {
Parent(FUNCTION SoundManager): D:/Prod/trunk/src/web/static_websites/uranus/src/main/www/scripts/../../../../out/main/www/scripts/libs/soundmanager2-nodebug.js:19:9
function SoundManager(smURL, smID) {
fileName:undefined
lineNumber: undefined
soundmanager2-nodebug.js is available from
http://www.schillmania.com/projects/soundmanager2/
error is on version V2.97a.20111030
I usually update to the latest version at each new project and it would be great if I could simply run a bash script to update it without worrying about what is the current version number, like:
curl https://raw.github.com/jrburke/r.js/master/dist/r.js > dev/site/_build/rjs/r.js
it would be also great if we could get latest snapshot:
curl https://raw.github.com/jrburke/r.js/master/dist/r-edge.js > dev/site/_build/rjs/r.js
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.