From d1aa052d1528f8eb2a769bee34d4292ef8c91a01 Mon Sep 17 00:00:00 2001 From: Michael Dokolin Date: Sat, 2 Oct 2021 10:43:12 +0200 Subject: [PATCH] Update build configuration (closes #36) --- babel.config.js | 20 -------------------- package.json | 12 ++++-------- rollup.config.js | 34 ++++++++++++---------------------- terser.json | 10 ---------- tsconfig.json | 2 -- 5 files changed, 16 insertions(+), 62 deletions(-) delete mode 100644 babel.config.js delete mode 100644 terser.json diff --git a/babel.config.js b/babel.config.js deleted file mode 100644 index 61e4c2a..0000000 --- a/babel.config.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2019 dokmic, Snowplow Analytics Ltd. All rights reserved. - * - * This program is licensed to you under the Apache License Version 2.0, - * and you may not use this file except in compliance with the Apache License Version 2.0. - * You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0. - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the Apache License Version 2.0 is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. - */ - -module.exports = { - "presets": [ - ["@babel/preset-env", { - "modules": false - }] - ] -} diff --git a/package.json b/package.json index c42f914..97d1c63 100644 --- a/package.json +++ b/package.json @@ -21,10 +21,9 @@ ], "main": "dist/index.js", "module": "dist/index.mjs", - "es2015": "dist/index.es6.mjs", "types": "dist/index.d.ts", "scripts": { - "build": "rollup -c rollup.config.js", + "build": "rollup -c", "lint": "eslint --ext .ts src/", "prepare": "$npm_execpath run build", "test": "jest --coverage" @@ -33,8 +32,6 @@ "node": ">=6.4.0" }, "devDependencies": { - "@babel/core": "^7.0", - "@babel/preset-env": "^7.0", "@types/jest": "^27.0", "@typescript-eslint/eslint-plugin": "^5.0", "@typescript-eslint/parser": "^5.0", @@ -46,10 +43,9 @@ "eslint-plugin-prettier": "^4.0", "jest": "^27.2", "prettier": "^2.4", - "rollup": "^1.23", - "rollup-plugin-babel": "^4.0", - "rollup-plugin-terser": "^5.0", - "rollup-plugin-typescript2": "^0.24", + "rollup": "^2.58", + "rollup-plugin-dts": "^4.0", + "rollup-plugin-typescript2": "^0.30", "ts-jest": "^27.0", "typescript": "^4.4" }, diff --git a/rollup.config.js b/rollup.config.js index f4d398e..6856fd3 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 dokmic, Snowplow Analytics Ltd. All rights reserved. + * Copyright (c) 2019-2021 dokmic, Snowplow Analytics Ltd. All rights reserved. * * This program is licensed to you under the Apache License Version 2.0, * and you may not use this file except in compliance with the Apache License Version 2.0. @@ -11,56 +11,46 @@ * See the Apache License Version 2.0 for the specific language governing permissions and limitations there under. */ -import babel from 'rollup-plugin-babel'; -import { terser } from 'rollup-plugin-terser'; +import dts from 'rollup-plugin-dts'; import typescript from 'rollup-plugin-typescript2'; -import terserOptions from './terser.json'; export default [ { input: 'src/index.ts', output: [ { + dir: 'dist', + entryFileNames: '[name].js', exports: 'named', - file: 'dist/index.js', format: 'umd', name: 'SnowplowAnalyticsSdk', sourcemap: true, sourcemapExcludeSources: true, }, { - file: 'dist/index.mjs', + dir: 'dist', + entryFileNames: '[name].mjs', format: 'esm', }, ], plugins: [ typescript({ - cacheRoot: './node_modules/.cache/rpt2', - compilerOptions: { - declaration: false, + clean: true, + tsconfigOverride: { + compilerOptions: { removeComments: true }, }, }), - babel({ extensions: ['.ts'] }), - terser(terserOptions), ], }, - { input: 'src/index.ts', output: [ { - file: 'dist/index.es6.mjs', + dir: 'dist', + entryFileNames: '[name].d.ts', format: 'esm', }, ], - plugins: [ - typescript({ - cacheRoot: './node_modules/.cache/rpt2', - tsconfigOverride: { - useTsconfigDeclarationDir: true, - }, - }), - terser(terserOptions), - ], + plugins: [dts()], }, ]; diff --git a/terser.json b/terser.json deleted file mode 100644 index 9e699fa..0000000 --- a/terser.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "ecma": 6, - "mangle": false, - "compress": false, - "output": { - "beautify": true, - "comments": false - }, - "sourcemap": true -} diff --git a/tsconfig.json b/tsconfig.json index 492a256..10506df 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,5 @@ { "compilerOptions": { - "declaration": true, - "declarationDir": "./dist", "esModuleInterop": true, "lib": [ "es6"