This repository has been archived by the owner on Feb 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Use webpack to build final product #117
Merged
Merged
Changes from 28 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
bdeaeed
Use webpack to build final product
dmsnell 168ed90
Small updates: formatting, version, main file
dmsnell e687f6c
Remove 'only' that was hogging the test suites
dmsnell e27b382
Update Makefile and tests to use minified build
dmsnell 255aa55
Push new distribution build of minified files.
dmsnell da5dbb3
Settle on a build layout.
dmsnell ef24996
Figure out public build process
dmsnell 4cf07e5
Make tests use `dist` version
dmsnell 3f63b0d
Update CircleCI config to build dist version
dmsnell 4188dca
fixup! Update CircleCI config to build dist version
dmsnell 3c3d212
Add the standalone file back into the repo
dmsnell 42adf06
Added phony targets to .PHONY in Makefile
mattsherman 500d902
Added dist/lib, dist/util, dist/test to .gitignore
mattsherman c153740
Cleaned up dist target dependencies in Makefile
mattsherman 17ae5b0
Remove prepublish npm script, create publish make target
mattsherman cb2e1f9
Remove install make target
mattsherman f68831d
dist
retrofox 33e910f
Use webpack to build final product
retrofox 94df1ab
Small updates: formatting, version, main file
dmsnell 854f212
Push new distribution build of minified files.
retrofox 76e2084
Settle on a build layout.
retrofox c7968a0
Figure out public build process
retrofox df4cccb
Update CircleCI config to build dist version
dmsnell a3ddbab
fixup! Update CircleCI config to build dist version
dmsnell c30cc98
Add the standalone file back into the repo
retrofox accc3d3
examples-cors: remove node.js server
retrofox dfd1ab6
Fix example server to grab config from test/config instead of test/data
mattsherman 9ed9b74
Committing dist files
mattsherman 32a7a6a
pkg: move babel into "dependencies" key
retrofox 4a1cb85
Clean up .gitignore, remove dist/index.js
mattsherman 503466a
Merge branch 'update/webpack-build-system' of github.com:Automattic/w…
mattsherman fe07656
Added self to list of contributors
mattsherman 793bcdd
remove `fs` from building process
retrofox 53498ba
example: update uploading testing file (proxy)
retrofox 8eba5e8
dist:updated
retrofox 7021e6f
Fixed `examples/browser-cors/upload-images.html`
mattsherman 6cff4f1
example: tweak upload images cors example
retrofox c77b18d
example: rename uploading testing file
retrofox File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,3 +1,4 @@ | ||
{ | ||
"blacklist": [ "strict" ] | ||
"blacklist": [ "strict" ], | ||
"sourceMaps": "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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,6 @@ npm-debug.log | |
/gh-tmp | ||
.DS_Store | ||
.idea | ||
/dist/lib | ||
/dist/util | ||
/dist/test | ||
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
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,183 @@ | ||
|
||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var request_handler = require('wpcom-xhr-request'); | ||
|
||
/** | ||
* Local module dependencies. | ||
*/ | ||
|
||
var Me = require('./lib/me'); | ||
var Site = require('./lib/site'); | ||
var Users = require('./lib/users'); | ||
var Batch = require('./lib/batch'); | ||
var Req = require('./lib/util/request'); | ||
var sendRequest = require('./lib/util/send-request'); | ||
var debug = require('debug')('wpcom'); | ||
|
||
/** | ||
* Local module constants | ||
*/ | ||
var DEFAULT_ASYNC_TIMEOUT = 30000; | ||
|
||
/** | ||
* XMLHttpRequest (and CORS) API access method. | ||
* | ||
* API authentication is done via an (optional) access `token`, | ||
* which needs to be retrieved via OAuth. | ||
* | ||
* Request Handler is optional and XHR is defined as default. | ||
* | ||
* @param {String} [token] - OAuth API access token | ||
* @param {Function} [reqHandler] - function Request Handler | ||
* @public | ||
*/ | ||
|
||
function WPCOM(token, reqHandler) { | ||
if (!(this instanceof WPCOM)) { | ||
return new WPCOM(token, reqHandler); | ||
} | ||
|
||
// `token` is optional | ||
if ('function' === typeof token) { | ||
reqHandler = token; | ||
token = null; | ||
} | ||
|
||
if (token) { | ||
debug('Token defined: %s…', token.substring(0, 6)); | ||
this.token = token; | ||
} | ||
|
||
// Set default request handler | ||
if (!reqHandler) { | ||
debug('No request handler. Adding default XHR request handler'); | ||
|
||
this.request = function (params, fn) { | ||
params = params || {}; | ||
|
||
// token is optional | ||
if (token) { | ||
params.authToken = token; | ||
} | ||
|
||
return request_handler(params, fn); | ||
}; | ||
} else { | ||
this.request = reqHandler; | ||
} | ||
|
||
// Add Req instance | ||
this.req = new Req(this); | ||
|
||
// Default api version; | ||
this.apiVersion = '1.1'; | ||
} | ||
|
||
/** | ||
* Get `Me` object instance | ||
* | ||
* @api public | ||
*/ | ||
|
||
WPCOM.prototype.me = function () { | ||
return new Me(this); | ||
}; | ||
|
||
/** | ||
* Get `Site` object instance | ||
* | ||
* @param {String} id | ||
* @api public | ||
*/ | ||
|
||
WPCOM.prototype.site = function (id) { | ||
return new Site(id, this); | ||
}; | ||
|
||
/** | ||
* Get `Users` object instance | ||
* | ||
* @api public | ||
*/ | ||
|
||
WPCOM.prototype.users = function () { | ||
return new Users(this); | ||
}; | ||
|
||
WPCOM.prototype.batch = function () { | ||
return new Batch(this); | ||
}; | ||
|
||
/** | ||
* List Freshly Pressed Posts | ||
* | ||
* @param {Object} [query] | ||
* @param {Function} fn callback function | ||
* @api public | ||
*/ | ||
|
||
WPCOM.prototype.freshlyPressed = function (query, fn) { | ||
return this.req.get('/freshly-pressed', query, fn); | ||
}; | ||
|
||
/** | ||
* Expose send-request | ||
* @TODO: use `this.req` instead of this method | ||
*/ | ||
|
||
WPCOM.prototype.sendRequest = function (params, query, body, fn) { | ||
var msg = 'WARN! Don use `sendRequest() anymore. Use `this.req` method.'; | ||
if (console && console.warn) { | ||
//eslint-disable-line no-console | ||
console.warn(msg); //eslint-disable-line no-console | ||
} else { | ||
console.log(msg); //eslint-disable-line no-console | ||
} | ||
|
||
return sendRequest.call(this, params, query, body, fn); | ||
}; | ||
|
||
if (!Promise.prototype.timeout) { | ||
/** | ||
* Returns a new promise with a deadline | ||
* | ||
* After the timeout interval, the promise will | ||
* reject. If the actual promise settles before | ||
* the deadline, the timer is cancelled. | ||
* | ||
* @param {number} delay how many ms to wait | ||
* @returns {Promise} | ||
*/ | ||
Promise.prototype.timeout = function () { | ||
var _this = this; | ||
|
||
var delay = arguments.length <= 0 || arguments[0] === undefined ? DEFAULT_ASYNC_TIMEOUT : arguments[0]; | ||
|
||
var cancelTimeout = undefined, | ||
timer = undefined, | ||
timeout = undefined; | ||
|
||
timeout = new Promise(function (resolve, reject) { | ||
timer = setTimeout(function () { | ||
reject(new Error('Action timed out while waiting for response.')); | ||
}, delay); | ||
}); | ||
|
||
cancelTimeout = function () { | ||
clearTimeout(timer); | ||
return _this; | ||
}; | ||
|
||
return Promise.race([this.then(cancelTimeout)['catch'](cancelTimeout), timeout]); | ||
}; | ||
} | ||
|
||
/** | ||
* Expose `WPCOM` module | ||
*/ | ||
|
||
module.exports = WPCOM; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this file here? shouldn't this be .git-ignored and build on install? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Taken care of in 4a1cb85 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just add
/dist/
here or are there files we want to keep?If, for example we want to keep the standalone file...
That
!
should whitelist the fileThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taken care of in 4a1cb85