diff --git a/.travis.yml b/.travis.yml index a235b44877..01a610b3e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,15 @@ language: node_js node_js: - - "4" + - 4 + - 6 + - 8 + - 10 script: npm run $COMMAND env: - COMMAND=test - COMMAND=test:karma-travis - #- COMMAND=integration MONTAGE_VERSION=. MOP_VERSION=latest - - COMMAND=integration MONTAGE_VERSION=. MOP_VERSION="#master" + - COMMAND=integration MONTAGE_VERSION=. MOP_VERSION="#feature/npm3" before_install: - - "npm set legacy-bundling=true" - export CHROME_BIN=chromium-browser - export DISPLAY=:99.0 - sh -e /etc/init.d/xvfb start diff --git a/montage.js b/montage.js index a3dc057a98..1f2cf7a5a9 100644 --- a/montage.js +++ b/montage.js @@ -91,12 +91,19 @@ } }, - load: function (location,loadCallback) { + load: function (location, callback) { var script = document.createElement("script"); script.src = location; script.onload = function () { - if(loadCallback) { - loadCallback(script); + if (callback) { + callback(null, script); + } + // remove clutter + script.parentNode.removeChild(script); + }; + script.onerror = function () { + if (callback) { + callback(new Error("Can't load script " + JSON.stringify(location)), script); } // remove clutter script.parentNode.removeChild(script); @@ -253,13 +260,28 @@ allModulesLoaded(); }; + var montageLocation; + function loadModuleScript(path, callback) { + montageLocation = montageLocation || resolve(global.location, params.montageLocation); + // try loading script relative to app first (npm 3+) + browser.load(resolve(global.location, path), function (err, script) { + if (err) { + // if that fails, the app may have been installed with + // npm 2 or with --legacy-bundling, in which case the + // script will be under montage's node_modules + browser.load(resolve(montageLocation, path), callback); + } else if (callback) { + callback(null, script); + } + }); + } + // load in parallel, but only if we're not using a preloaded cache. // otherwise, these scripts will be inlined after already if (typeof global.BUNDLE === "undefined") { - var montageLocation = resolve(global.location, params.montageLocation); - //Special Case bluebird for now: - browser.load(resolve(montageLocation, pending.promise), function() { + // Special Case bluebird for now: + loadModuleScript(pending.promise, function () { delete pending.promise; //global.bootstrap cleans itself from global once all known are loaded. "bluebird" is not known, so needs to do it first @@ -272,7 +294,7 @@ for (var module in pending) { if (pending.hasOwnProperty(module)) { - browser.load(resolve(montageLocation, pending[module])); + loadModuleScript(pending[module]); } } }); @@ -777,34 +799,8 @@ hash: params.montageHash }) .then(function (montageRequire) { - // load the promise package so we can inject the bootstrapped - // promise library back into it - var promiseLocation; - if (params.promiseLocation) { - promiseLocation = URL.resolve(Require.getLocation(), params.promiseLocation); - } else { - //promiseLocation = URL.resolve(montageLocation, "packages/mr/packages/q"); - //node tools/build --features="core timers call_get" --browser - promiseLocation = URL.resolve(montageLocation, "node_modules/bluebird"); - } - - var result = [ - montageRequire, - montageRequire.loadPackage({ - location: promiseLocation, - hash: params.promiseHash - }) - ]; - - return result; - }) - .spread(function (montageRequire, promiseRequire) { montageRequire.inject("core/mini-url", URL); montageRequire.inject("core/promise", {Promise: Promise}); - promiseRequire.inject("bluebird", Promise); - - // This prevents bluebird to be loaded twice by mousse's code - promiseRequire.inject("js/browser/bluebird", Promise); // install the linter, which loads on the first error config.lint = function (module) { diff --git a/node.js b/node.js index ad6c0cec6c..1b93bc16dd 100644 --- a/node.js +++ b/node.js @@ -72,12 +72,11 @@ function getMontageMontageDeserializer() { return getMontageMontageDeserializer._promise; } - return (getMontageMontageDeserializer._promise = MontageBoot.loadPackage( - PATH.join(__dirname, "."), {mainPackageLocation: PATH.join(__dirname, "../")}) + return (getMontageMontageDeserializer._promise = MontageBoot.loadPackage(PATH.join(__dirname, ".")) .then(function (mr) { return mr.async("./core/serialization/deserializer/montage-deserializer") .then(function (MontageDeserializerModule) { - return (MontageBoot.MontageDeserializer = + return (MontageBoot.MontageDeserializer = MontageDeserializerModule.MontageDeserializer ); }); diff --git a/package.json b/package.json index df66264f8f..13fbf552ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "montage", - "version": "17.2.1", + "version": "18.0.0-rc2", "description": "Build your next application with a browser based platform that really gets the web.", "license": "BSD-3-Clause", "repository": { @@ -9,8 +9,8 @@ }, "main": "montage", "engines": { - "node": "<=4.9.1", - "npm": "<=2.15.11" + "node": ">=4", + "npm": ">=2" }, "overlay": { "browser": { @@ -53,7 +53,7 @@ "frb": "~4.0.x", "htmlparser2": "~3.0.5", "q-io": "^1.13.3", - "mr": "^17.0.11", + "mr": "18.0.0-rc2", "weak-map": "^1.0.5", "lodash.kebabcase": "^4.1.1", "lodash.camelcase": "^4.3.0",