Opened 11 years ago
Closed 11 years ago
#12357 closed enhancement (duplicate)
Add support for node.js
Reported by: | Colin Snover | Owned by: | liucougar |
---|---|---|---|
Priority: | high | Milestone: | 1.7 |
Component: | General | Version: | 1.6.0rc1 |
Keywords: | Cc: | James Burke, Rawld Gill, Eugene Lazutkin | |
Blocked By: | Blocking: |
Description
There are three very minor things that need to change in order to support node.js when using RequireJS or another AMD-compliant loader.
- Stop setting this.console when it exists; this is a property with no mutator in node.js and it will crash if you try to set it:
--- dojo-release-1.6.0rc1-src/dojo/_base/_loader/bootstrap.js.orig 2011-02-21 08:36:01.000000000 -0600 +++ dojo-release-1.6.0rc1-src/dojo/_base/_loader/bootstrap.js 2011-02-27 21:25:34.000000000 -0600 @@ -142,7 +142,7 @@ // for Firebug 1.2 this["loadFirebugConsole"](); }else{ - this.console = this.console || {}; + if(!this.console) { this.console = {}; } // Be careful to leave 'log' always at the end var cn = [
- Only call d.addOnWindowUnload when that function actually exists.
--- dojo-release-1.6.0rc1-src/dojo/_base/html.js.orig 2011-02-27 21:41:53.000000000 -0600 +++ dojo-release-1.6.0rc1-src/dojo/_base/html.js 2011-02-27 21:42:27.000000000 -0600 @@ -94,7 +94,7 @@ var _destroyContainer = null, _destroyDoc; //>>excludeStart("webkitMobile", kwArgs.webkitMobile); - d.addOnWindowUnload(function(){ + d.addOnWindowUnload && d.addOnWindowUnload(function(){ _destroyContainer = null; //prevent IE leak }); //>>excludeEnd("webkitMobile");
- Include an alternative package main module that excludes portions of dojo core that require a window object.
define("dojo", [ "dojo/lib/kernel", "dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "dojo/_base/connect", "dojo/_base/Deferred", "dojo/_base/json", "dojo/_base/Color", "dojo/_base/event", "dojo/_base/html", "dojo/_base/NodeList", "dojo/_base/fx" ], function(dojo){ return dojo; });
It might be worth making the removed modules (window, query, xhr) a little smarter so that they can still be loaded in an environment that is missing window
(so that, for instance, they might be usable to query a DOM implementation or a server-side XHR object), but that would be a more significant undertaking.
I haven’t run DOH tests to see what is actually broken, but this at least gets dojo from crashing to running with the maximum number of core modules possible using only small tweaks. I can confirm that at least dojo.declare
, dojo.connect
, and pubsub are working, which is probably most of what people need on the server anyway. :)
Change History (8)
comment:1 Changed 11 years ago by
Owner: | changed from anonymous to liucougar |
---|
comment:2 Changed 11 years ago by
Cc: | James Burke Rawld Gill added |
---|
comment:3 Changed 11 years ago by
Status: | new → assigned |
---|
comment:4 Changed 11 years ago by
Milestone: | tbd → 1.7 |
---|
comment:5 Changed 11 years ago by
Cc: | Eugene Lazutkin added |
---|
comment:6 Changed 11 years ago by
moving to 1.8, today is feature freeze for 1.7 and there's been no movement on this in 2months.
comment:7 Changed 11 years ago by
This can probably be closed or marked as a dupe of #12672 since the loader has been updated with node support at this point.
Cougar, you are working on this already, so assigning ticket to you.