-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve performance by removing pitch loader, also disable notifications
- Loading branch information
Showing
8 changed files
with
58 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
{ | ||
"node": true, | ||
"globals": { | ||
"window": true, | ||
"Notification": true | ||
"window": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
'use strict'; | ||
|
||
var updaters = {}, | ||
makeModuleUpdater = require('./makeModuleUpdater'); | ||
|
||
function getHotUpdateAPI(React, filename, moduleId) { | ||
var exists = updaters.hasOwnProperty(moduleId); | ||
if (!exists) { | ||
updaters[moduleId] = makeModuleUpdater(React, filename); | ||
} | ||
|
||
var updater = updaters[moduleId]; | ||
return { | ||
createClass: exists ? updater.updateClass : updater.createClass, | ||
updateMountedInstances: updater.updateMountedInstances | ||
}; | ||
} | ||
|
||
module.exports = getHotUpdateAPI; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,34 @@ | ||
var path = require('path'), | ||
loaderUtils = require('loader-utils'); | ||
var path = require('path'); | ||
|
||
module.exports = function () {}; | ||
module.exports.pitch = function (remainingRequest) { | ||
this.cacheable && this.cacheable(); | ||
module.exports = function (source) { | ||
if (this.cacheable) { | ||
this.cacheable(); | ||
} | ||
|
||
var patchedModuleRequest = '!!' + require.resolve('./replaceCreateClass') + '!' + remainingRequest, | ||
originalFilename = path.basename(remainingRequest), | ||
query = loaderUtils.parseQuery(this.query); | ||
var matches = 0, | ||
processedSource; | ||
|
||
query.notify = query.notify || 'none'; | ||
processedSource = source.replace(/React\.createClass/g, function (match) { | ||
matches++; | ||
return '__hotUpdateAPI.createClass'; | ||
}); | ||
|
||
return [ | ||
'var React = require("react");', | ||
'var notifier = require(' + JSON.stringify(require.resolve('./makeNotifier')) + ')(' + JSON.stringify(originalFilename) + ', ' + JSON.stringify(query.notify) + ');', | ||
'var moduleUpdater = require(' + JSON.stringify(require.resolve('./makeModuleUpdater')) + ')(' + JSON.stringify(originalFilename) + ', React);', | ||
|
||
'module.exports = require(' + JSON.stringify(patchedModuleRequest) + ')(moduleUpdater.createClass);', | ||
if (!matches) { | ||
return source; | ||
} | ||
|
||
'if (module.hot && moduleUpdater.canUpdateModule() && React.isValidClass(module.exports)) {', | ||
' module.hot.accept(' + JSON.stringify(patchedModuleRequest) + ', function () {', | ||
' try {', | ||
' require(' + JSON.stringify(patchedModuleRequest) + ')(moduleUpdater.updateClass);', | ||
' moduleUpdater.updateMountedInstances();', | ||
' notifier.handleSuccess()', | ||
' } catch (err) {', | ||
' notifier.handleFailure(err)', | ||
' }', | ||
return [ | ||
'var __hotUpdateAPI = (function () {', | ||
' var React = require("react");', | ||
' var getHotUpdateAPI = require(' + JSON.stringify(require.resolve('./getHotUpdateAPI')) + ');', | ||
' return getHotUpdateAPI(React, ' + JSON.stringify(path.basename(this.resourcePath)) + ', module.id);', | ||
'})();', | ||
processedSource, | ||
'if (module.hot) {', | ||
' module.hot.accept();', | ||
' module.hot.dispose(function () {', | ||
' var nextTick = require(' + JSON.stringify(require.resolve('next-tick')) + ');', | ||
' nextTick(__hotUpdateAPI.updateMountedInstances);', | ||
' });', | ||
'}' | ||
].join('\n'); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gaearon
Author
Owner
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
You should consider using the
source-map
.SourceNode class to build the source. This is required to support SourceMaps once petehunt/jsx-loader#16 get merged...