Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#4700) - fix and test Webpack #4701

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -13,3 +13,4 @@ phantomjsdriver.log
tests/pouchdb_server
tests/performance-bundle.js
dist/*
pouchdb-webpack.js
3 changes: 3 additions & 0 deletions .travis.yml
Expand Up @@ -86,6 +86,9 @@ env:
- CLIENT=selenium:firefox:41.0.1 ADAPTERS=memory COMMAND=test
- CLIENT=selenium:firefox:41.0.1 ADAPTERS=localstorage COMMAND=test

# Test Webpack bundle
- CLIENT=selenium:firefox:41.0.1 COMMAND=test-webpack

# Test CouchDB master (aka bigcouch branch)
- CLIENT=node SERVER=couchdb-master COMMAND=test
- SKIP_MIGRATION=true CLIENT=selenium:firefox:41.0.1 SERVER=couchdb-master COMMAND=test
Expand Down
6 changes: 6 additions & 0 deletions TESTING.md
Expand Up @@ -57,6 +57,12 @@ or e.g.:

or you can append it as `?es5shim=true` if you manually opened a browser window.

#### Other test options

* `SKIP_MIGRATION=1` should be used to skip the migration tests.
* `POUCHDB_SRC=../../dist/pouchdb.js` can be used to treat another file as the PouchDB source file.
* `npm run test-webpack` will build with Webpack and then test that in a browser.

#### Run the map/reduce tests

The map/reduce tests are done separately from the normal integration tests, because
Expand Down
3 changes: 3 additions & 0 deletions bin/dev-server.js
Expand Up @@ -34,6 +34,9 @@ if (process.env.ADAPTERS) {
if (process.env.AUTO_COMPACTION) {
queryParams.autoCompaction = true;
}
if (process.env.POUCHDB_SRC) {
queryParams.src = process.env.POUCHDB_SRC;
}

var indexfile = "./lib/index.js";
var outfile = "./dist/pouchdb.js";
Expand Down
3 changes: 3 additions & 0 deletions bin/test-browser.js
Expand Up @@ -73,6 +73,9 @@ if (process.env.SERVER) {
if (process.env.SKIP_MIGRATION) {
qs.SKIP_MIGRATION = process.env.SKIP_MIGRATION;
}
if (process.env.POUCHDB_SRC) {
qs.src = process.env.POUCHDB_SRC;
}

testUrl += '?';
testUrl += querystring.stringify(qs);
Expand Down
13 changes: 13 additions & 0 deletions bin/test-webpack.sh
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

#
# Build PouchDB with Webpack instead of Browserify, and test that.
# We have this test because there are enough differences between
# Webpack and Browserify to justify it.
#

./node_modules/.bin/webpack \
--module-bind json \
--output-library PouchDB --output-library-target umd \
./lib/index.js pouchdb-webpack.js
POUCHDB_SRC='../../pouchdb-webpack.js' npm test
2 changes: 1 addition & 1 deletion lib/deps/ajax/ajaxCore.js
@@ -1,6 +1,6 @@
"use strict";

var request = require('request');
var request = require('./request');
var extend = require('js-extend').extend;
var errors = require('./../errors');
var clone = require('../../deps/clone');
Expand Down
5 changes: 5 additions & 0 deletions lib/deps/ajax/request.js
@@ -0,0 +1,5 @@
'use strict';

// May seem redundant, but this is to allow switching with
// request-browser.js.
module.exports = require('request');
2 changes: 1 addition & 1 deletion lib/index.js
Expand Up @@ -9,7 +9,7 @@ PouchDB.utils = require('./utils');
PouchDB.Errors = require('./deps/errors');
PouchDB.replicate = require('./replicate').replicate;
PouchDB.sync = require('./sync');
PouchDB.version = require('./version');
PouchDB.version = require('../package.json').version;
var httpAdapter = require('./adapters/http');
PouchDB.adapter('http', httpAdapter);
PouchDB.adapter('https', httpAdapter);
Expand Down
2 changes: 0 additions & 2 deletions lib/version-browser.js

This file was deleted.

1 change: 0 additions & 1 deletion lib/version.js

This file was deleted.

24 changes: 13 additions & 11 deletions package.json
Expand Up @@ -18,7 +18,6 @@
],
"dependencies": {
"argsarray": "0.0.1",
"browserify-versionify": "^1.0.6",
"debug": "2.2.0",
"double-ended-queue": "2.0.0-0",
"es3ify": "0.1.4",
Expand All @@ -31,6 +30,7 @@
"lie": "3.0.1",
"localstorage-down": "0.6.3",
"memdown": "1.1.0",
"package-json-versionify": "^1.0.0",
"pouchdb-collate": "1.2.0",
"pouchdb-collections": "1.0.1",
"request": "2.67.0",
Expand Down Expand Up @@ -60,6 +60,7 @@
"istanbul": "0.4.1",
"istanbul-coveralls": "1.0.3",
"jshint": "2.8.0",
"json-loader": "^0.5.4",
"less": "2.5.3",
"mkdirp": "0.5.1",
"mocha": "2.3.4",
Expand All @@ -81,7 +82,8 @@
"uglify-js": "2.6.1",
"watch-glob": "0.1.3",
"watchify": "3.6.1",
"wd": "0.4.0"
"wd": "0.4.0",
"webpack": "^1.12.9"
},
"scripts": {
"build-js": "npm run build-main-js && npm run min && npm run build-plugins",
Expand All @@ -106,7 +108,8 @@
"build-site": "node ./bin/build-site.js",
"report-coverage": "COVERAGE=1 npm test && istanbul-coveralls --no-rm",
"build-perf": "browserify tests/performance/*.js > tests/performance-bundle.js",
"verify-bundle-size": "sh bin/verify-bundle-size.sh"
"verify-bundle-size": "sh bin/verify-bundle-size.sh",
"test-webpack": "sh bin/test-webpack.sh"
},
"browser": {
"./adapters/levelalt": false,
Expand All @@ -116,34 +119,33 @@
"./lib/adapters/leveldb/prepareAttachmentForStorage.js": "./lib/adapters/leveldb/prepareAttachmentForStorage-browser.js",
"./lib/adapters/leveldb/readAsBlobOrBuffer.js": "./lib/adapters/leveldb/readAsBlobOrBuffer-browser.js",
"./lib/adapters/preferredAdapters.js": "./lib/adapters/preferredAdapters-browser.js",
"./lib/deps/ajax/prequest.js": "./lib/deps/ajax/prequest-browser.js",
"./lib/deps/ajax/applyTypeToBuffer.js": "./lib/deps/ajax/applyTypeToBuffer-browser.js",
"./lib/deps/ajax/createBlobOrBufferFromParts.js": "./lib/deps/ajax/createBlobOrBufferFromParts-browser.js",
"./lib/deps/ajax/createMultipartPart.js": "./lib/deps/ajax/createMultipartPart-browser.js",
"./lib/deps/ajax/defaultBody.js": "./lib/deps/ajax/defaultBody-browser.js",
"./lib/deps/ajax/explainError.js": "./lib/deps/ajax/explainError-browser.js",
"./lib/deps/ajax/explainCors.js": "./lib/deps/ajax/explainCors-browser.js",
"./lib/deps/env/hasLocalStorage.js": "./lib/deps/env/hasLocalStorage-browser.js",
"./lib/deps/env/isChromeApp.js": "./lib/deps/env/isChromeApp-browser.js",
"./lib/deps/ajax/explainError.js": "./lib/deps/ajax/explainError-browser.js",
"./lib/deps/ajax/prequest.js": "./lib/deps/ajax/prequest-browser.js",
"./lib/deps/ajax/request.js": "./lib/deps/ajax/request-browser.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I sorted these alphabetically; the only true change is the above line.

"./lib/deps/binary/base64.js": "./lib/deps/binary/base64-browser.js",
"./lib/deps/binary/base64StringToBlobOrBuffer.js": "./lib/deps/binary/base64StringToBlobOrBuffer-browser.js",
"./lib/deps/binary/binaryStringToBlobOrBuffer.js": "./lib/deps/binary/binaryStringToBlobOrBuffer-browser.js",
"./lib/deps/binary/blobOrBufferToBase64.js": "./lib/deps/binary/blobOrBufferToBase64-browser.js",
"./lib/deps/binary/buffer.js": "./lib/deps/binary/buffer-browser.js",
"./lib/deps/binary/cloneBinaryObject.js": "./lib/deps/binary/cloneBinaryObject-browser.js",
"./lib/deps/binary/isBinaryObject.js": "./lib/deps/binary/isBinaryObject-browser.js",
"./lib/deps/env/hasLocalStorage.js": "./lib/deps/env/hasLocalStorage-browser.js",
"./lib/deps/env/isChromeApp.js": "./lib/deps/env/isChromeApp-browser.js",
"./lib/deps/md5.js": "./lib/deps/md5-browser.js",
"./lib/deps/migrate.js": "./lib/deps/migrate-browser.js",
"./lib/mapreduce/md5.js": "./lib/mapreduce/md5-browser.js",
"./lib/version.js": "./lib/version-browser.js",
"crypto": false,
"fs": false,
"leveldown": false,
"request": "./lib/deps/ajax/request-browser.js"
"leveldown": false
},
"browserify": {
"transform": [
"browserify-versionify"
"package-json-versionify"
]
}
}
8 changes: 7 additions & 1 deletion tests/integration/webrunner.js
Expand Up @@ -5,7 +5,13 @@
// use query parameter pluginFile if present,
// eg: test.html?pluginFile=memory.pouchdb.js
var preferredAdapters = window.location.search.match(/[?&]adapters=([^&]+)/);
var scriptsToLoad = ['../../dist/pouchdb.js'];
var pouchdbSrc = window.location.search.match(/[?&]src=([^&]+)/);
if (pouchdbSrc) {
pouchdbSrc = decodeURIComponent(pouchdbSrc[1]);
} else {
pouchdbSrc = '../../dist/pouchdb.js';
}
var scriptsToLoad = [pouchdbSrc];
if (preferredAdapters) {
preferredAdapters = preferredAdapters[1].split(',');
preferredAdapters.forEach(function (adapter) {
Expand Down