Skip to content

Commit 74177d3

Browse files
author
Chuck Dumont
committed
Remove ES6 code from unwrapPromiseValue
1 parent 03e1035 commit 74177d3

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,22 @@
2020
<!-- TOC START min:1 max:3 link:true update:true -->
2121
- [Introduction](#introduction)
2222
- [The Dojo loader](#the-dojo-loader)
23-
- [CommonJS require vs. Dojo synchronous require](#commonjs-require-vs-dojo-synchronous-require)
23+
- [CommonJS require vs. Dojo synchronous require](#commonjs-require-vs-dojo-synchronous-require)
2424
- [The Dojo loader config](#the-dojo-loader-config)
2525
- [Dojo loader extensions](#dojo-loader-extensions)
2626
- [The dojo/has loader extension](#the-dojohas-loader-extension)
2727
- [The dojo/loaderProxy loader extension](#the-dojoloaderproxy-loader-extension)
2828
- [Options](#options)
29-
- [async](#async)
30-
- [loaderConfig](#loaderconfig)
31-
- [environment](#environment)
32-
- [buildEnvironment](#buildenvironment)
33-
- [globalContext](#globalcontext)
34-
- [loader](#loader)
35-
- [locales](#locales)
36-
- [cjsRequirePatterns](#cjsrequirepatterns)
37-
- [coerceUndefinedToFalse](#coerceundefinedtofalse)
38-
- [noConsole](#noconsole)
29+
- [async](#async)
30+
- [loaderConfig](#loaderconfig)
31+
- [environment](#environment)
32+
- [buildEnvironment](#buildenvironment)
33+
- [globalContext](#globalcontext)
34+
- [loader](#loader)
35+
- [locales](#locales)
36+
- [cjsRequirePatterns](#cjsrequirepatterns)
37+
- [coerceUndefinedToFalse](#coerceundefinedtofalse)
38+
- [noConsole](#noconsole)
3939
- [Building the Dojo loader](#building-the-dojo-loader)
4040
- [The `dojo-config-api` feature](#the-dojo-config-api-feature)
4141
- [The `dojo-undef-api` feature](#the-dojo-undef-api-feature)
@@ -247,13 +247,13 @@ Promise.resolve(require('myAmdModule')).then(function(myAmdModule) {
247247

248248
This section is for the special (and hopefully rare) case of requiring, from CommonJS code, an AMD module that itself returns a promise as the module value. If you're not doing this in your code, then you can ignore this section.
249249

250-
dojo-webpack-plugin wraps module value promises in a non-promise object. This is done in order to prevent promise chaining from replacing the promise with the resolved value before it is provided to the caller. Promise wrapping and unwrapping happens transparently within AMD modules, so you don't need to be concerned with it. When an AMD module is required from CommonJS code, however, then the promise wrapper can be exposed and you need to take steps to deal with it, as shown in the following example:
250+
dojo-webpack-plugin wraps module value promises (actually, any thenable) in a non-promise object. This is done in order to prevent promise chaining from replacing the promise with the resolved value before it is provided to the caller. Promise wrapping and unwrapping happens transparently within AMD modules, so you don't need to be concerned with it. When an AMD module is required from CommonJS code, however, then the promise wrapper can be exposed and you need to take steps to deal with it, as shown in the following example:
251251

252252
```javascript
253253
// From within a CommonJS module
254254
const unwrap = require('dojo-webpack-plugin/cjs/unwrapPromiseValue');
255255

256-
Promise.resolve(require("amdModuleThatReturnsAPromiseValue"))
256+
Promise.resolve(require("amdModuleThatHasPromiseValue"))
257257
.then(wrapped => unwrap(wrapped))
258258
.then(resolved => {
259259
resolved.doSomething();

cjs/unwrapPromiseValue.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@
1919
* an AMD module that returns a promise as the value of the module is
2020
* required within CommonJS code.
2121
*/
22-
module.exports = m => m && m.__DOJO_WEBPACK_PROMISE_VALUE__ || m;
22+
module.exports = function(m) {return m && m['__DOJO_WEBPACK_PROMISE_VALUE__'] || m;};

0 commit comments

Comments
 (0)