This is the Montage app template.
Note: Before working on your app you will need to add montage to it.
npm install .
| var Serializer = require("montage/core/serialization").Serializer; | |
| var MyComponent = Montage.create(Component, { | |
| handleButtonClick: { | |
| value: function (event) { | |
| var serializer = Serializer.create().initWithRequire(require); | |
| var serialization = serializer.serialize(this.theObjects); | |
| console.log(serialization); |
| var Q = require("q"); | |
| var Set = require("collections/set"); // https://npmjs.org/package/collections | |
| window.outstandingPromises = new Set(); | |
| var originalDefer = Q.defer; | |
| Q.defer = function () { | |
| console.error("Deferred created"); | |
| var deferred = originalDefer(); | |
| deferred.stack = new Error("").stack; | |
| window.outstandingPromises.add(deferred); |
| var spawn = require("child_process").spawn; | |
| var Q = require("q"); | |
| /** | |
| * Wrap executing a command in a promise | |
| * @param {string} command command to execute | |
| * @param {Array<string>} args Arguments to the command. | |
| * @param {string} cwd The working directory to run the command in. | |
| * @return {Promise} A promise for the completion of the command. | |
| */ |
| var joey = require("joey"); | |
| // Uses qs https://npmjs.org/package/qs | |
| var qs = require("qs"); | |
| joey | |
| .log() | |
| .error() | |
| .favicon() | |
| .route(function ($) { |
| var defaultLocalizer = require("montage/core/localizer").defaultLocalizer; | |
| defaultLocalizer.localize("hello_name", "Hello, {name}!") | |
| .then(function (hi) { | |
| console.log(hi({name: "World"})); // => "Hello, World!", or the translation at the "hello_name" key | |
| }); | |
| defaultLocalizer.localize("cat", "Cat") | |
| .then(function (cat) { | |
| console.log(cat.toString()); // => "Cat", or the translation at the "cat" key |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <title>resolve</title> | |
| <!-- Base URL ensures montage.js and style.css are loaded from the root of the server | |
| Make sure this comes before any `script`, `style`, or `link` tags to ensure that | |
| resources are loaded from the correct place. --> | |
| <base href="/"> |
| // usage: | |
| // require = require("./heap-require")(require); | |
| // then use require as normal | |
| module.exports = function (_require) { | |
| var newRequire = function (id) { | |
| var before = process.memoryUsage().heapUsed / 1024 / 1024; | |
| var exports = _require(id); | |
| var after = process.memoryUsage().heapUsed / 1024 / 1024; |
| var webpackConfig = { | |
| plugins: [ | |
| // Plugin to show any webpack warnings and prevent tests from running | |
| function () { | |
| this.plugin("done", function (stats) { | |
| if (stats.compilation.warnings.length) { | |
| // Log each of the warnings | |
| stats.compilation.warnings.forEach(function (warning) { | |
| console.log(warning.message || warning); | |
| }); |