hello.js
(could be foo
).hello.js
file to js-bundler.boomla.net/v1
or whatever
your install location is.Add your main code in hello.js
, for example:
let hello = require('/hello.js');
console.log(hello.sum(1, 2));
Create a module by spreading your code across children of the hello.js
file,
for example hello.js/sum.js
could hold the sum()
function.
File names must end in .js
and not _test.js
to be included in the bundle.
Within the module files, use the CommonJS module format. Anything the module
exports shall be assigned to module.exports
or exports
, for example:
let sum = function(a, b) {
return a + b;
};
module.exports.sum = sum;
// or exports.sum = sum;
The only difference to CommonJS modules is that you can spread your code across multiple files, and not the file itself but its parent need to be imported.
exports.sum = sum
.module.exports
variable, simply set its
properties.let hello = require('/hello.js');
.
You must specify the full path relative to the domain./hello.js
file can import any module, not only itself.sum()
function stored in /hello.js/sum.js
, place the test code
in /hello.js/sum_test.js
(the important part is that it ends in _test.js
).
Files ending in _test.js
are only included in the test bundle./hello.js/sum.js
bear no significance
except for the .js
and _test.js
ending. They are only for keeping order./hello.js
./hello.js?test=1
.--------VIEWS--------
as visual
separators.'use strict';
). To disable it, set the
useStrict int32
attribute of the /hello.js
file to 0
.Look at the source of the /hello
file for an example.
The bundled code is available at /hello/hello.js
.
The tests can be run by visiting /hello/hello.js?test=1
.