migrate to tsup

This commit is contained in:
goenning 2023-09-01 13:35:18 +01:00
parent e256d13c92
commit c9bb14f809
5 changed files with 22 additions and 85 deletions

View file

@ -3,13 +3,13 @@
"version": "0.1.3",
"type": "module",
"description": "JavaScript SDK for Aptabase: Open Source, Privacy-First and Simple Analytics for Mobile, Desktop and Web Apps",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": "./dist/index.js",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs",
"import": "./dist/index.js",
"types": "./dist/index.d.ts"
}
},
@ -24,10 +24,7 @@
"homepage": "https://github.com/aptabase/aptabase-js",
"license": "MIT",
"scripts": {
"build": "rollup -c ./rollup.config.mjs",
"watch": "rollup -c ./rollup.config.mjs -w",
"prepublishOnly": "npm run build",
"pretest": "npm run build"
"build": "tsup"
},
"files": [
"README.md",
@ -36,11 +33,6 @@
"package.json"
],
"devDependencies": {
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-typescript": "11.1.3",
"rollup": "3.28.1",
"@rollup/plugin-terser": "0.4.3",
"tslib": "2.6.2",
"typescript": "5.2.2"
"tsup": "7.2.0"
}
}

View file

@ -1,38 +0,0 @@
import replace from '@rollup/plugin-replace';
import terser from '@rollup/plugin-terser';
import typescript from '@rollup/plugin-typescript';
import pkg from './package.json' assert { type: 'json' };
const plugins = [
terser(),
replace({
'env.PKG_VERSION': pkg.version,
preventAssignment: true,
}),
typescript({
tsconfig: './tsconfig.json',
moduleResolution: 'node',
}),
];
const cjs = {
input: './src/index.ts',
output: {
dir: './dist',
entryFileNames: '[name].js',
format: 'cjs',
},
plugins,
};
const es = {
input: './src/index.ts',
output: {
dir: './dist',
entryFileNames: '[name].mjs',
format: 'es',
},
plugins,
};
export default [cjs, es];

View file

@ -1,15 +1,15 @@
{
"compilerOptions": {
"target": "ES5",
"target": "es6",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"jsx": "react-jsx",
"baseUrl": ".",
"paths": {
"types": ["@types"]
},
"declaration": true,
"declarationDir": "./dist",
"rootDir": "./src"
},
"include": ["./"]
"declarationDir": "./dist"
}
}

View file

@ -0,0 +1,10 @@
import { defineConfig } from 'tsup';
export default defineConfig({
entry: ['src/index.ts'],
format: ['cjs', 'esm'],
dts: true,
splitting: false,
sourcemap: true,
clean: true,
});