diff --git a/.babelrc b/.babelrc index 46a76b32d60..a3682b46af6 100644 --- a/.babelrc +++ b/.babelrc @@ -1,12 +1,19 @@ { - "presets": ["es2015"], - "plugins": [ - [ - "transform-async-to-generator", - "transform-runtime", { - "polyfill": false, - "regenerator": false - } - ] - ] + "env": { + "es5": { + "presets": ["es2015"], + "plugins": [ + [ + "transform-async-to-generator", + "transform-runtime", { + "polyfill": false, + "regenerator": false + } + ] + ] + }, + "es6": { + "presets": ["es2017"] + } + } } diff --git a/package.json b/package.json index cd5c203f8e6..5d3410685db 100755 --- a/package.json +++ b/package.json @@ -24,8 +24,8 @@ ], "license": "Apache-2.0", "main": "./dist/lib/index.js", - "jsnext:main": "./src/index.js", - "module": "./src/index.js", + "jsnext:main": "./dist/es/index.js", + "module": "./dist/es/index.js", "types": "./src/index.d.ts", "scripts": { "pretest": "npm run transpile", @@ -33,12 +33,14 @@ "test:node": "npm run pretest && gulp --gulpfile ./config/gulpfile.js test", "test:browser": "npm run pretest && karma start ./config/karma.conf.js", "dockertest": "docker run -it -v $(pwd):/usr/src/app markadams/chromium-xvfb-js:latest-onbuild", - "clear": "rimraf -rf test_tmp/ && rimraf -rf dist/lib/ && rimraf .transpile_state.json", + "clear": "rimraf -rf test_tmp/ && rimraf -rf dist/ && rimraf .transpile_state.json", "lint": "eslint --ignore-path ./config/.eslintignore src test ./config/gulpfile.js", + "transpile:clean": "rimraf dist/lib", "transpile": "node scripts/transpile.js", + "build:es": "cross-env NODE_ENV=es6 babel src --out-dir dist/es", "build:rollup": "rollup -c --environment UGLIFY:true --config ./config/rollup.config.js && rollup -c --environment UGLIFY:false --config ./config/rollup.config.js", "build:webpack": "webpack --optimize-minimize --config ./config/webpack.config.js", - "build": "npm run clear && npm run transpile && browserify dist/lib/browserify.index.js > dist/rxdb.browserify.js && uglifyjs --compress --mangle --output dist/rxdb.browserify.min.js -- dist/rxdb.browserify.js", + "build": "npm run clear && npm run transpile && npm run build:es && browserify dist/lib/browserify.index.js > dist/rxdb.browserify.js && uglifyjs --compress --mangle --output dist/rxdb.browserify.min.js -- dist/rxdb.browserify.js", "disc": "npm run transpile && browserify dist/lib/index.js --full-paths | uglifyjs --compress --mangle | discify --open --full-paths", "preversion": "npm run lint && npm run test", "dev": "watch 'npm run test:node' src/ test/", @@ -81,6 +83,7 @@ "babel-polyfill": "^6.23.0", "babel-preset-es2015": "^6.24.0", "babel-preset-es2015-rollup": "3.0.0", + "babel-preset-es2017": "^6.24.1", "babelrc-rollup": "3.0.0", "brfs": "1.4.3", "browserify": "^14.1.0", diff --git a/scripts/transpile.js b/scripts/transpile.js index e0be368c1e2..25f57c72dd9 100644 --- a/scripts/transpile.js +++ b/scripts/transpile.js @@ -1,3 +1,5 @@ +process.env['NODE_ENV'] = 'es5'; + /** * runs the babel-transpile * remembers mtime of files and only transpiles the changed ones