requirejs / cajon Goto Github PK
View Code? Open in Web Editor NEWJavaScript module loader for the browser that can load CommonJS/node and AMD modules
License: Other
JavaScript module loader for the browser that can load CommonJS/node and AMD modules
License: Other
Hi, I'm trying to use cajon with some existing CJS modules that use this exports pattern:
function Example(name) {
this.name = name;
}
exports.Example = Example;
However this doesn't seem to work with Cajon, console shows error:
"exports is not defined"
However, this pattern does:
function Example(name) {
this.name = name;
}
module.exports = {
Example: Example
}
Is this on purpose and/or expected? I have a lot of code that I'd rather not convert (which is why I'd like to use cajon here).
https://github.com/requirejs/cajon/blob/master/cajon.js#L11
Commenting out that line fixes all the problems I've had where 'use strict' would have caused issues.
Is there any chance Cajon would switch over to the //# sourceUrl=
style of notation?
The conditional comments around the line which appends the magical //@ sourceURL=
have a nasty habit of being stripped when passed through UglifyJS.
I attempted to solve the issue by rolling my own function for determining which comments to keep, but alas, the /*@end@*/
comment is ignored, apparently because there's no code following it in the block. If I add an executable line below the closing comment, it's passed into the preserve comment function for evaluation.
I do realise, that I should probably just change our development build to skip Cajon in the uglification process and just keep it as is, but I strive to having the build as similar as possible to minimise variables between environments.
Window.eval() is needed, otherwise something like CryptoJS (http://code.google.com/p/crypto-js) completely refuses to work.
function exec(content) {
/*jslint evil: true */
return window.eval(content);
}
at line ~1960.
exports.abc = true
works.
exports['abc'] = true
does not, but should.
Please make it available via Bower. Currently I have to refer to it in bower.json
in a following ugly way:
"cajon": "https://raw.githubusercontent.com/requirejs/cajon/master/cajon.js",
Looks like it wants full URLs.
var template = require('text!tmpl/something.tmpl')
// Uncaught Error: Module name "text!tmpl/simple.tmpl_unnormalized2" has not been loaded yet for context: _
var template = require(['text!tmpl/something.tmpl'], function (template) {
// no problem
})
Hi,
I had a config with Backbone shim working just fine with regular requirejs. Wanted to move over to use Cajon to reuse models in Node.js. It' seems however that shimming Backbone with the exact same config doesn't work:
paths: {
jquery: 'vendor/jquery',
underscore: 'vendor/underscore',
backbone: 'vendor/backbone',
...
},
shim: {
jquery: {
exports: 'jQuery'
},
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
When backbone is initialized there is not jQuery available, any idea why this would be?
In this pull, base64 javascript url support was added for the paths config.
#845 . It also enables this snippet
var url = 'data:text/javascript,define([], function() { return "wut" })';
require([url], function (wut) {
wut === 'wut'
});
See this example working with Require.js
http://jsfiddle.net/qsRT8/
I can't find cajon on any public CDN, but if you run the same thing with cajon it will fail because it is trying to do an XHR (because cajon) to the data uri, but that get's blocked by the browser because of Same-Origin Policy ('data:' is different protocol and thus different origin).
I am making a component loader that will support specifying a URL to JavaScript to run the component. The component may have a bundle that does all the right things at an http url, but it may just want to execute a bit of JavaScript without entailing the HTTP Request or having to host a file.
Could Cajon do a script tag load in the case that the URL is a data uri?
Is it possible that Cajon doesn't use the cs! plugin to parse a .coffee file before reading it's dependencies?
Upgrading from 0.1.14 -> 0.2.4, global
should be defined but an JS error is being thrown that "global is not defined".
Everything worked fine pre-cajon. Upon switching to cajon, handlebars (1.0.0, installed from bower, shimmed, used via the requirejs-handlebars plugin) is failing with this error:
Uncaught TypeError: Cannot call method 'compile' of undefined in /components/requirejs-handlebars/hb.js:15
This is the exact same error I'd see if I forgot to shim handlebars normally (ie. without cajon).
If I wrap handlebars.js with define([], function() { /*handlebars code*/ return Handlebars; });
or comment out the handlebars shim in requirejs.config
and add module.exports = Handlebars;
to the end of handlebars.js it works fine.
But with no modifications to handlebars.js, shim or not, I see that error. It's as if the handlebars shim config is being ignored.
Any way to decrease the length of the file name as displayed in the Chrome debugger by removing the query string parameters from the file path?
Convert this:
http://localhost:5000/gherkin-runner/gherkinRunner.html?featurePaths=features/stepArgumentTypes&libraryPaths=features/step_definitions/../gherkin-runner/scripts/text.js
To this:
http://localhost:5000/gherkin-runner/scripts/text.js
It starts fetching calls to 'fs', 'path', 'lexer', etc...
Is there a way to tell Cajon that a module is AMD?
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.