diff --git a/.gitignore b/.gitignore index b7e26c2..f79cfd2 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ # production /build /lib +/lib-without-polyfill # misc .DS_Store diff --git a/babel-without-polyfill.config.json b/babel-without-polyfill.config.json new file mode 100644 index 0000000..be91d70 --- /dev/null +++ b/babel-without-polyfill.config.json @@ -0,0 +1,20 @@ +{ + "presets": [ + [ + "@babel/preset-env", + { + "targets": "> 0.25%, not dead", + "useBuiltIns": false, + "corejs": 3 + } + ], + "@babel/preset-typescript" + ], + "plugins": [ + "@babel/plugin-transform-runtime", + "@babel/plugin-proposal-class-properties", + "@babel/plugin-proposal-object-rest-spread", + "@babel/plugin-proposal-optional-chaining", + "lodash" + ] +} diff --git a/.babelrc b/babel.config.json similarity index 100% rename from .babelrc rename to babel.config.json diff --git a/package.json b/package.json index 8c107dc..5c641e5 100644 --- a/package.json +++ b/package.json @@ -21,11 +21,12 @@ "test": "echo \"Error: no test specified\" && exit 0", "start": "NODE_ENV=development webpack-dev-server", "build": "rm -rf build/ && NODE_ENV=production webpack", - "build:lib": "rm -rf lib/ && babel src/ -d lib/ -x \".js\",\".ts\" --source-maps --ignore \"src/**/__tests__/**/*\"", + "build:lib": "rm -rf lib/ && babel src/ -d lib/ -x \".js\",\".ts\" --config-file \"./babel.config.json\" --source-maps --ignore \"src/**/__tests__/**/*\"", + "build:lib-without-polyfill": "rm -rf lib-without-polyfill/ && babel src/ -d lib-without-polyfill/ -x \".js\",\".ts\" --config-file \"./babel-without-polyfill.config.json\" --source-maps --ignore \"src/**/__tests__/**/*\"", "stats": "NODE_ENV=production webpack --profile --json > stats.json", "analyzer": "ANALYZER=true NODE_ENV=production webpack", "ci": "node --version && babel --version", - "before-publish": "npm run build && npm run build:lib", + "before-publish": "npm run build && npm run build:lib && npm run build:lib-without-polyfill", "publish:patch": "npm run before-publish && npm version patch && npm publish", "publish:minor": "npm run before-publish && npm version minor && npm publish", "publish:major": "npm run before-publish && npm version major && npm publish", diff --git a/webpack.config.js b/webpack.config.js index 7820401..a9b7105 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,9 +6,11 @@ const isDevelopment = env === 'development'; const analyzer = process.env.ANALYZER; const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; +const babelOptions = require('./babel.config.json'); + const webpackConfig = { entry: { - main: './src/index.ts' + rapiop: './src/index.ts' }, output: { path: path.resolve(__dirname, 'build'), @@ -27,7 +29,10 @@ const webpackConfig = { rules: [ { test: /\.(ts|js)$/, - use: 'babel-loader', + use: { + loader: 'babel-loader', + options: babelOptions + }, exclude: /node_modules/ } ]