forked from pouchdb/pouchdb
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(pouchdb#4652) - Migrate to ES6/Rollup, build one index.js
- Loading branch information
1 parent
57923d6
commit 99c24a5
Showing
186 changed files
with
1,547 additions
and
1,331 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
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 |
---|---|---|
|
@@ -11,3 +11,4 @@ phantomjsdriver.log | |
bower_components | ||
./docs/ | ||
pouchdb-webpack.js | ||
lib_unit |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
# | ||
# This script builds `src` to `lib` in a modular style that preserves the | ||
# original file structure. This is useful for things like 1) unit tests, which | ||
# need to "reach inside" the bundle, and 2) coverage reports, which need to be | ||
# able to run all tests against the codebase, including the unit tests. | ||
# | ||
|
||
npm run build | ||
|
||
# In this case, Babel is roughly equivalent to what Rollup would do. | ||
# "add-module-exports" gives us a backwards-compatible CJS module structure | ||
# that doesn't oblige use to do require('foo').default for every module. | ||
|
||
./node_modules/.bin/babel \ | ||
--presets es2015 \ | ||
--plugins add-module-exports \ | ||
--out-dir lib src | ||
|
||
# Add a version number to both files (equivalent to build.sh) | ||
|
||
VERSION=$(node -e "console.log(require('./package.json').version)") | ||
./node_modules/.bin/replace --silent __VERSION__ $VERSION lib/* | ||
|
||
# Make the extras point back to the modular code (instead of being bundles). | ||
|
||
echo "module.exports = require('../deps/promise');" \ | ||
> lib/extras/promise.js | ||
|
||
echo "module.exports = require('../replicate/checkpointer');" \ | ||
> lib/extras/checkpointer.js | ||
|
||
echo "module.exports = require('../deps/ajax/prequest');" \ | ||
> lib/extras/ajax.js | ||
|
||
echo "module.exports = require('../replicate/generateReplicationId');" \ | ||
> lib/extras/generateReplicationId.js |
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,117 @@ | ||
#!/usr/bin/env bash | ||
|
||
RIMRAF=./node_modules/.bin/rimraf | ||
MKDIRP=./node_modules/.bin/mkdirp | ||
BROWSERIFY=./node_modules/.bin/browserify | ||
ROLLUP=./node_modules/.bin/rollup | ||
REPLACE=./node_modules/.bin/replace | ||
DEREQUIRE=./node_modules/.bin/derequire | ||
UGLIFY=./node_modules/.bin/uglifyjs | ||
|
||
VERSION=$(node -e "console.log(require('./package.json').version)") | ||
|
||
$RIMRAF lib_staging | ||
$MKDIRP lib_staging | ||
|
||
EXTERNAL='argsarray,crypto,debug,double-ended-queue,es3ify,events,fruitdown,fs,inherits,inherits,js-extend,level-sublevel,level-sublevel/legacy,level-write-stream,levelup,lie,localstorage-down,memdown,path,pouchdb,pouchdb-collate,pouchdb-collections,request,scope-eval,spark-md5,through2,vuvuzela' | ||
|
||
# build for Node | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src/index.js \ | ||
--output=lib_staging/index.js | ||
|
||
# build for Browserify/Webpack | ||
|
||
$RIMRAF src_browser | ||
cp -r src src_browser | ||
|
||
for file in `find src_browser | grep '\-browser.js'`; do | ||
cp $file `echo $file | sed 's/-browser//g'`; | ||
done | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/index.js \ | ||
--output=lib_staging/index-browser.js | ||
|
||
# add a version number to both files | ||
$REPLACE --silent __VERSION__ $VERSION lib_staging/* | ||
|
||
# rename to avoid concurrency issues in dev server | ||
$MKDIRP lib | ||
mv lib_staging/* lib/ | ||
$RIMRAF lib_staging | ||
|
||
echo Built lib/index* | ||
|
||
# build for the browser (dist) | ||
|
||
$RIMRAF dist | ||
$MKDIRP dist | ||
|
||
$BROWSERIFY . -s PouchDB -p bundle-collapser/plugin \ | ||
| node ./bin/es3ify.js \ | ||
| $DEREQUIRE \ | ||
> dist/pouchdb.js | ||
|
||
$UGLIFY dist/pouchdb.js -m -c warnings=false > dist/pouchdb.min.js | ||
|
||
echo Built dist/* | ||
|
||
# build browser plugins | ||
|
||
$MKDIRP lib_staging/plugins | ||
|
||
for plugin in fruitdown localstorage memory; do | ||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/plugins/${plugin}/index.js \ | ||
> lib_staging/plugins/${plugin}.js | ||
done | ||
|
||
$MKDIRP lib/plugins | ||
mv lib_staging/plugins/* lib/plugins/ | ||
$RIMRAF lib_staging | ||
|
||
echo Built lib/plugins/* | ||
|
||
# build extras API | ||
|
||
$MKDIRP lib_staging/extras | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/deps/promise.js \ | ||
> lib_staging/extras/promise.js | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/replicate/checkpointer.js \ | ||
> lib_staging/extras/checkpointer.js | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/deps/ajax/prequest.js \ | ||
> lib_staging/extras/ajax.js | ||
|
||
$ROLLUP --format=cjs --external $EXTERNAL \ | ||
src_browser/replicate/generateReplicationId.js \ | ||
> lib_staging/extras/generateReplicationId.js | ||
|
||
$MKDIRP lib/extras | ||
mv lib_staging/extras/* lib/extras/ | ||
$RIMRAF lib_staging | ||
|
||
echo Built lib/extras/* | ||
|
||
# build browser plugins to dist/ | ||
|
||
for plugin in memory localstorage fruitdown; do | ||
$BROWSERIFY ./extras/${plugin} \ | ||
-x pouchdb \ | ||
-p bundle-collapser/plugin \ | ||
| ./bin/es3ify.js \ | ||
| $DEREQUIRE > ./dist/pouchdb.${plugin}.js | ||
$UGLIFY dist/pouchdb.${plugin}.js -m -c warnings=false \ | ||
> dist/pouchdb.${plugin}.min.js | ||
echo Built dist/pouchdb.${plugin}.* | ||
done | ||
|
||
# cleanup | ||
$RIMRAF src_browser |
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
Oops, something went wrong.