diff --git a/.babelrc b/.babelrc deleted file mode 100755 index 37f2890..0000000 --- a/.babelrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": [ - "@babel/plugin-transform-runtime" - ], - "presets": [ - [ - "@babel/preset-env", - {loose: true} - ] - ] -} diff --git a/.gitignore b/.gitignore index 167ecd9..9cd9f26 100755 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ node_modules .lock-wscript # The compiled/babelified modules +esm/ lib/ # Editors diff --git a/babel.config.js b/babel.config.js new file mode 100755 index 0000000..08e1e54 --- /dev/null +++ b/babel.config.js @@ -0,0 +1,19 @@ +module.exports = function (api) { + api.cache(true); + + return { + "plugins": [ + "@babel/plugin-transform-runtime" + ], + "presets": [ + [ + "@babel/preset-env", + { + modules: process.env.ESM ? false : "cjs", + loose: true + } + ] + ] + }; + +} diff --git a/package.json b/package.json index 118a2a0..6c97fa2 100755 --- a/package.json +++ b/package.json @@ -4,6 +4,8 @@ "version": "3.0.0", "homepage": "https://github.com/feathersjs/feathers-redux", "main": "lib/", + "module": "esm/", + "sideEffects": false, "keywords": [ "feathers", "feathers-plugin" @@ -32,7 +34,10 @@ "release:minor": "npm version minor && npm publish", "release:major": "npm version major && npm publish", "changelog": "github_changelog_generator && git add CHANGELOG.md && git commit -am \"Updating changelog\"", - "compile": "shx rm -rf lib/ && babel -d lib/ src/", + "precompile": "shx rm -rf lib/ esm/", + "compile": "npm run compile:cjs && npm run compile:esm", + "compile:cjs": "babel -d lib/ src/", + "compile:esm": "ESM=1 babel -d esm/ src/", "watch": "babel --watch -d lib/ src/", "lint": "semistandard src/**/*.js test/**/*.js --fix", "mocha": "mocha --opts mocha.opts", @@ -47,6 +52,7 @@ ] }, "directories": { + "esm": "esm", "lib": "lib" }, "peerDependencies": {