Skip to content

Commit

Permalink
Merge pull request #425 from canjs/fix-webpack-debug-style
Browse files Browse the repository at this point in the history
fix dev code for webpack compatibility
  • Loading branch information
matthewp authored Jun 22, 2018
2 parents 2a2f050 + 49d62c7 commit 17b6865
Show file tree
Hide file tree
Showing 11 changed files with 74 additions and 39 deletions.
4 changes: 3 additions & 1 deletion cache-requests/cache-requests.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ var cacheRequestsBehaviour = connect.behavior("cache-requests",function(baseConn
module.exports = cacheRequestsBehaviour;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
}
module.exports = validate(cacheRequestsBehaviour, ['getListData', 'cacheConnection']);
//!steal-remove-end
4 changes: 3 additions & 1 deletion can/constructor-hydrate/constructor-hydrate.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ var constructorHydrateBehavior = connect.behavior("can-connect/can/construct-hyd
module.exports = constructorHydrateBehavior;

//!steal-remove-start
var validate = require('can-connect/helpers/validate');
if(process.env.NODE_ENV !== 'production') {
var validate = require('can-connect/helpers/validate');
}
module.exports = validate(constructorHydrateBehavior, ['Map', 'List', 'instanceStore', 'hydrateInstance']);
//!steal-remove-end
38 changes: 24 additions & 14 deletions can/map/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,16 @@ var canMapBehavior = connect.behavior("can/map",function(baseConnection){
*/
updatedList: function(list, listData, set){
queues.batch.start();
queues.mutateQueue.enqueue(baseConnection.updatedList, this, arguments,{
//!steal-remove-start
reasonLog: ["set", set,"list", list,"updated with", listData]
//!steal-remove-end
});
var enqueueOptions = {};
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
enqueueOptions = {
reasonLog: ["set", set,"list", list,"updated with", listData]
};
}
//!steal-remove-end

queues.mutateQueue.enqueue(baseConnection.updatedList, this, arguments, enqueueOptions);
queues.batch.stop();

},
Expand Down Expand Up @@ -442,8 +447,10 @@ canMapBehavior.callbackInstanceEvents = function (funcName, instance) {
eventQueue.dispatch.call(instance, {type: funcName, target: instance});

//!steal-remove-start
if (this.id) {
dev.log("can-connect/can/map/map.js - " + (constructor.shortName || this.name) + " " + this.id(instance) + " " + funcName);
if(process.env.NODE_ENV !== 'production') {
if (this.id) {
dev.log("can-connect/can/map/map.js - " + (constructor.shortName || this.name) + " " + this.id(instance) + " " + funcName);
}
}
//!steal-remove-end

Expand Down Expand Up @@ -802,11 +809,14 @@ var overwrite = function( connection, Constructor, overwrites) {
module.exports = canMapBehavior;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(
canMapBehavior,
[
'id', 'get', 'updatedList', 'destroy', 'save', 'getList'
]
);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");

module.exports = validate(
canMapBehavior,
[
'id', 'get', 'updatedList', 'destroy', 'save', 'getList'
]
);
}
//!steal-remove-end
6 changes: 4 additions & 2 deletions can/merge/merge.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ var mergeBehavior = connect.behavior("can/merge",function(baseConnection){
module.exports = mergeBehavior;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(mergeBehavior, ['createdInstance', 'destroyedInstance', 'updatedInstance', 'updatedList']);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(mergeBehavior, ['createdInstance', 'destroyedInstance', 'updatedInstance', 'updatedList']);
}
//!steal-remove-end
6 changes: 4 additions & 2 deletions constructor/callbacks-once/callbacks-once.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ var callbacksOnceBehavior = connect.behavior("constructor/callbacks-once",functi
module.exports = callbacksOnceBehavior;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(callbacksOnceBehavior, callbacks);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(callbacksOnceBehavior, callbacks);
}
//!steal-remove-end
6 changes: 4 additions & 2 deletions constructor/store/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,8 @@ constructorStore.requestCleanupDelay = 10;
module.exports = constructorStore;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(constructorStore, ['hydrateInstance', 'hydrateList', 'getList', 'get', 'save', 'destroy']);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(constructorStore, ['hydrateInstance', 'hydrateList', 'getList', 'get', 'save', 'destroy']);
}
//!steal-remove-end
6 changes: 4 additions & 2 deletions data/callbacks-cache/callbacks-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ var callbackCache = connect.behavior("data/callbacks-cache",function(baseConnect
module.exports = callbackCache;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(callbackCache, []);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(callbackCache, []);
}
//!steal-remove-end
10 changes: 6 additions & 4 deletions data/callbacks/callbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,10 @@ var dataCallbackBehavior = connect.behavior("data/callbacks",function(baseConnec
module.exports = dataCallbackBehavior;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(dataCallbackBehavior, [
"getListData", "createData", "updateData", "destroyData"
]);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(dataCallbackBehavior, [
"getListData", "createData", "updateData", "destroyData"
]);
}
//!steal-remove-end
12 changes: 8 additions & 4 deletions data/url/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,10 @@ var findContentType = function( url, method ) {
return url.contentType;
} else {
//!steal-remove-start
dev.warn("Unacceptable contentType on can-connect request. " +
"Use 'application/json' or 'application/x-www-form-urlencoded'");
if(process.env.NODE_ENV !== 'production') {
dev.warn("Unacceptable contentType on can-connect request. " +
"Use 'application/json' or 'application/x-www-form-urlencoded'");
}
//!steal-remove-end
}
}
Expand Down Expand Up @@ -376,6 +378,8 @@ var makeAjax = function ( ajaxOb, data, type, ajax, contentType, reqOptions ) {
module.exports = urlBehavior;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(urlBehavior, ['url']);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(urlBehavior, ['url']);
}
//!steal-remove-end
6 changes: 4 additions & 2 deletions fall-through-cache/fall-through-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ var fallThroughCache = connect.behavior("fall-through-cache",function(baseConnec
module.exports = fallThroughCache;

//!steal-remove-start
var validate = require("can-connect/helpers/validate");
module.exports = validate(fallThroughCache, ['hydrateList', 'hydrateInstance', 'getListData', 'getData']);
if(process.env.NODE_ENV !== 'production') {
var validate = require("can-connect/helpers/validate");
module.exports = validate(fallThroughCache, ['hydrateList', 'hydrateInstance', 'getListData', 'getData']);
}
//!steal-remove-end
15 changes: 10 additions & 5 deletions real-time/real-time.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,9 @@ var canDev = require('can-util/js/dev/dev');
module.exports = connect.behavior("real-time",function(baseConnection){

var createPromise = Promise.resolve();
var behavior;

return {
behavior = {
createData: function(){
var promise = baseConnection.createData.apply(this, arguments);
var cleanPromise = promise.catch(function () { return ''; })
Expand Down Expand Up @@ -358,9 +359,11 @@ module.exports = connect.behavior("real-time",function(baseConnection){
return instance;
});
}
};

//!steal-remove-start
,gotListData: function(items, set) {
//!steal-remove-start
if(process.env.NODE_ENV !== 'production') {
behavior.gotListData = function(items, set) {
var self = this;
if (this.algebra) {
for(var item, i = 0, l = items.data.length; i < l; i++) {
Expand All @@ -380,8 +383,10 @@ module.exports = connect.behavior("real-time",function(baseConnection){

return Promise.resolve(items);
}
//!steal-remove-end
};
}
//!steal-remove-end

return behavior;
});

var create = function(props){
Expand Down

0 comments on commit 17b6865

Please sign in to comment.