Comparing version 2.0.0-alpha.5 to 2.0.0-alpha.6
@@ -832,4 +832,38 @@ import has = require('./has'); | ||
var injectUrl: (url: string, callback: (node?: HTMLScriptElement) => void, module: IModule, parent?: IModule) => void; | ||
if (has('host-browser')) { | ||
if (has('host-node')) { | ||
var vm: any = require('vm'); | ||
var fs: any = require('fs'); | ||
// retain the ability to get node's require | ||
req.nodeRequire = require; | ||
injectUrl = function (url: string, callback: (node?: HTMLScriptElement) => void, module: IModule, parent?: IModule): void { | ||
fs.readFile(url, 'utf8', function (error: Error, data: string): void { | ||
if (error) { | ||
throw new Error('Failed to load module ' + module.mid + ' from ' + url + (parent ? ' (parent: ' + parent.mid + ')' : '')); | ||
} | ||
// global `module` variable needs to be shadowed for UMD modules that are loaded in an Electron webview; | ||
// in Node.js the `module` variable does not exist when using `vm.runInThisContext`, but in Electron it | ||
// exists in the webview when Node.js integration is enabled which causes loaded modules to register | ||
// with Node.js and break the loader | ||
var oldModule = this.module; | ||
this.module = undefined; | ||
try { | ||
vm.runInThisContext(data, url); | ||
} | ||
finally { | ||
this.module = oldModule; | ||
} | ||
callback(); | ||
}); | ||
}; | ||
setGlobals = function (require: IRequire, define: IDefine): void { | ||
module.exports = this.require = require; | ||
this.define = define; | ||
}; | ||
} | ||
else if (has('host-browser')) { | ||
injectUrl = function (url: string, callback: (node?: HTMLScriptElement) => void, module: IModule, parent?: IModule): void { | ||
// insert a script element to the insert-point element with src=url; | ||
@@ -863,24 +897,2 @@ // apply callback upon detecting the script has loaded. | ||
} | ||
else if (has('host-node')) { | ||
var vm: any = require('vm'); | ||
var fs: any = require('fs'); | ||
// retain the ability to get node's require | ||
req.nodeRequire = require; | ||
injectUrl = function (url: string, callback: (node?: HTMLScriptElement) => void, module: IModule, parent?: IModule): void { | ||
fs.readFile(url, 'utf8', function (error: Error, data: string): void { | ||
if (error) { | ||
throw new Error('Failed to load module ' + module.mid + ' from ' + url + (parent ? ' (parent: ' + parent.mid + ')' : '')); | ||
} | ||
vm.runInThisContext(data, url); | ||
callback(); | ||
}); | ||
}; | ||
setGlobals = function (require: IRequire, define: IDefine): void { | ||
module.exports = this.require = require; | ||
this.define = define; | ||
}; | ||
} | ||
else { | ||
@@ -945,5 +957,9 @@ throw new Error('Unsupported platform'); | ||
var module: IModule = getModule(id); | ||
module.injected = true; | ||
defineModule(module, deps, factory); | ||
// Some modules in the wild have an explicit module ID that is null; ignore the module ID in this case and | ||
// register normally using the request module ID | ||
if (id != null) { | ||
var module: IModule = getModule(id); | ||
module.injected = true; | ||
defineModule(module, deps, factory); | ||
} | ||
} | ||
@@ -950,0 +966,0 @@ |
@@ -15,5 +15,12 @@ import CallbackQueue = require('./CallbackQueue'); | ||
// Node.JS 0.10 added `setImmediate` and then started throwing warnings when people called `nextTick` recursively; | ||
// Node.JS 0.11 supposedly removes this behaviour, so only target 0.10 | ||
if (has('host-node') && typeof setImmediate !== 'undefined' && process.version.indexOf('v0.10.') === 0) { | ||
// Despite claims that setImmediate is broken in IE because it can be blocked forever by the renderer, MutationObserver | ||
// in IE11 seems to work even less reliably when it is used by Intern via WebDriver. In this case, mutations do not | ||
// always trigger a queue drain, which causes very slow/never-completing tests. setImmediate does always work in this | ||
// case | ||
if ( | ||
typeof setImmediate !== 'undefined' && | ||
// Node.JS 0.10 added `setImmediate` and then started throwing warnings when people called `nextTick` recursively; | ||
// Node.JS 0.11 removes this behaviour, so use setImmediate for 0.10 and nextTick for the rest | ||
(!has('host-node') || (has('host-node') && process.version.indexOf('v0.10.') === 0)) | ||
) { | ||
nextTick = function (callback: () => void): core.IHandle { | ||
@@ -20,0 +27,0 @@ var timer = setImmediate(callback); |
{ | ||
"name": "dojo", | ||
"version": "2.0.0-alpha.5", | ||
"version": "2.0.0-alpha.6", | ||
"description": "Dojo 2 core. The Dojo 2 core library provides TypeScript & JavaScript authors with a complete set of tools for developing well-structured, highly maintainable applications.", | ||
@@ -5,0 +5,0 @@ "homepage": "https://dojotoolkit.org", |
@@ -483,4 +483,29 @@ (function () { | ||
var injectUrl; | ||
if (has('host-browser')) { | ||
if (has('host-node')) { | ||
var vm = require('vm'); | ||
var fs = require('fs'); | ||
req.nodeRequire = require; | ||
injectUrl = function (url, callback, module, parent) { | ||
fs.readFile(url, 'utf8', function (error, data) { | ||
if (error) { | ||
throw new Error('Failed to load module ' + module.mid + ' from ' + url + (parent ? ' (parent: ' + parent.mid + ')' : '')); | ||
} | ||
var oldModule = this.module; | ||
this.module = undefined; | ||
try { | ||
vm.runInThisContext(data, url); | ||
} | ||
finally { | ||
this.module = oldModule; | ||
} | ||
callback(); | ||
}); | ||
}; | ||
setGlobals = function (require, define) { | ||
module.exports = this.require = require; | ||
this.define = define; | ||
}; | ||
} | ||
else if (has('host-browser')) { | ||
injectUrl = function (url, callback, module, parent) { | ||
var node = document.createElement('script'); | ||
@@ -508,20 +533,2 @@ var handler = function (event) { | ||
} | ||
else if (has('host-node')) { | ||
var vm = require('vm'); | ||
var fs = require('fs'); | ||
req.nodeRequire = require; | ||
injectUrl = function (url, callback, module, parent) { | ||
fs.readFile(url, 'utf8', function (error, data) { | ||
if (error) { | ||
throw new Error('Failed to load module ' + module.mid + ' from ' + url + (parent ? ' (parent: ' + parent.mid + ')' : '')); | ||
} | ||
vm.runInThisContext(data, url); | ||
callback(); | ||
}); | ||
}; | ||
setGlobals = function (require, define) { | ||
module.exports = this.require = require; | ||
this.define = define; | ||
}; | ||
} | ||
else { | ||
@@ -570,5 +577,7 @@ throw new Error('Unsupported platform'); | ||
factory = arguments[2]; | ||
var module = getModule(id); | ||
module.injected = true; | ||
defineModule(module, deps, factory); | ||
if (id != null) { | ||
var module = getModule(id); | ||
module.injected = true; | ||
defineModule(module, deps, factory); | ||
} | ||
} | ||
@@ -575,0 +584,0 @@ if (arguments.length === 1) { |
@@ -16,3 +16,4 @@ (function (deps, factory) { | ||
var nextTick; | ||
if (has('host-node') && typeof setImmediate !== 'undefined' && process.version.indexOf('v0.10.') === 0) { | ||
if (typeof setImmediate !== 'undefined' && | ||
(!has('host-node') || (has('host-node') && process.version.indexOf('v0.10.') === 0))) { | ||
nextTick = function (callback) { | ||
@@ -19,0 +20,0 @@ var timer = setImmediate(callback); |
{ | ||
"name": "dojo", | ||
"version": "2.0.0-alpha.5", | ||
"version": "2.0.0-alpha.6", | ||
"description": "Dojo 2 core. The Dojo 2 core library provides TypeScript & JavaScript authors with a complete set of tools for developing well-structured, highly maintainable applications.", | ||
@@ -5,0 +5,0 @@ "homepage": "http://dojotoolkit.org", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
568904
12654
3