From ba1cb003418a0f1f1b005b62532c43278e220d7e Mon Sep 17 00:00:00 2001 From: Pascal Roehling Date: Wed, 21 Feb 2024 20:15:19 +0100 Subject: [PATCH] Migrate @polar/plugin-geo-location to the new rollup setup Also, import the styles from the package in all clients. --- packages/plugins/GeoLocation/package.json | 23 ++++++++++- packages/plugins/GeoLocation/rollup.config.js | 40 +++++++++++++++++++ packages/plugins/GeoLocation/tsconfig.json | 8 +++- 3 files changed, 68 insertions(+), 3 deletions(-) create mode 100644 packages/plugins/GeoLocation/rollup.config.js diff --git a/packages/plugins/GeoLocation/package.json b/packages/plugins/GeoLocation/package.json index c2d9af813..ae4957c32 100644 --- a/packages/plugins/GeoLocation/package.json +++ b/packages/plugins/GeoLocation/package.json @@ -5,16 +5,32 @@ "license": "EUPL-1.2", "type": "module", "author": "Dataport AöR ", - "main": "src/index.ts", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "module": "dist/index.js", + "exports": { + ".": { + "import": "./dist/index.js", + "require": "./dist/index.js" + }, + "./styles.css": { + "import": "./dist/index.css", + "require": "./dist/index.css" + } + }, "repository": { "type": "git", "url": "https://github.com/Dataport/polar.git", "directory": "packages/plugins/GeoLocation" }, "files": [ - "src/**/*", + "dist/**", "CHANGELOG.md" ], + "scripts": { + "bundle": "tsc --declaration --emitDeclarationOnly && rollup -c", + "preversion": "npm run bundle" + }, "peerDependencies": { "@repositoryname/vuex-generators": "^1.1.2", "ol": "^7.1.0", @@ -28,5 +44,8 @@ "devDependencies": { "@polar/lib-custom-types": "^1.0.0", "@polar/lib-test-mount-parameters": "^1.0.0" + }, + "nx": { + "includedScripts": ["bundle"] } } diff --git a/packages/plugins/GeoLocation/rollup.config.js b/packages/plugins/GeoLocation/rollup.config.js new file mode 100644 index 000000000..f9a3d22cd --- /dev/null +++ b/packages/plugins/GeoLocation/rollup.config.js @@ -0,0 +1,40 @@ +import commonjs from '@rollup/plugin-commonjs' +import resolve from '@rollup/plugin-node-resolve' +import scss from 'rollup-plugin-scss' +import svg from 'rollup-plugin-svg' +import terser from '@rollup/plugin-terser' +import typescript from 'rollup-plugin-typescript2' +import vue from 'rollup-plugin-vue' +import { createFilter } from '@rollup/pluginutils' + +const external = createFilter( + ['@polar/**', '@repositoryname/vuex-generators', 'ol/**', 'vue', 'vuex'], + null, + { resolve: false } +) + +export default { + input: 'src/index.ts', + output: [ + { + file: 'dist/index.js', + name: '@polar/plugin-geo-location', + format: 'es', + sourcemap: 'inline', + }, + ], + external, + plugins: [ + vue({ + defaultLang: { script: 'ts', style: 'scss' }, + css: false, + }), + scss({ fileName: 'index.css', sourceMap: true }), + // Types are not checked as typechecking does not work for vue-files with the current version, might be fixable with an upgrade of vue and vuex; see https://github.com/vuejs/vuex/pull/1121. + typescript({ check: false }), + commonjs(), + resolve(), + svg(), + terser(), + ], +} diff --git a/packages/plugins/GeoLocation/tsconfig.json b/packages/plugins/GeoLocation/tsconfig.json index 618c6c3e9..f41632188 100644 --- a/packages/plugins/GeoLocation/tsconfig.json +++ b/packages/plugins/GeoLocation/tsconfig.json @@ -1,3 +1,9 @@ { - "extends": "../../../tsconfig.json" + "extends": "../../../tsconfig.json", + "compilerOptions": { + "outDir": "dist", + }, + "include": [ + "src/**/*" + ] }