utopia-ui/rollup.config.js
Ulf Gebhardt feae3dc482
fix(source): type export via rollup plugin by using the correct input (#122)
* fix typeexport via rollup plugin by using the correct input

The rollup plugin dts requires a d.ts tree as input not the txs sources.

This change points the plugin into the right direction and removes the
type export hacks.

* corrected types path

apparently this was not properly adjusted accross the board when moving
the folder

* fix rollup config

properly export types

* use export * where needed

Since we now export types alongside with defintions we use the `export *
from` syntax to simplify things

* export types alongside with interfaces

export types so we can properly use them in external projects alongside
the exported function/module/...

* fix type-problems uncovered by utopia-map

When including types properly in the utopia-map several missing typings
showed up.

* fix typing

fix an inhereted type

* dummy restructure code

to properly be able to compile things we are not allowed to have unsed
parameters/props

* assigne types to category types
2025-02-19 12:05:42 +00:00

92 lines
2.2 KiB
JavaScript

import path from 'path'
import { fileURLToPath } from 'url'
import alias from '@rollup/plugin-alias'
import resolve from '@rollup/plugin-node-resolve'
import typescript from '@rollup/plugin-typescript'
import { dts } from 'rollup-plugin-dts'
import postcss from 'rollup-plugin-postcss'
const __filename = fileURLToPath(import.meta.url)
const __dirname = path.dirname(__filename)
const aliasConfig = alias({
entries: [{ find: '#types', replacement: path.resolve(__dirname, 'src/types') }],
})
export default [
{
input: 'src/index.tsx',
output: [
{
file: 'dist/index.esm.js',
format: 'esm',
sourcemap: true,
},
{
file: 'dist/index.cjs',
format: 'cjs',
sourcemap: true,
},
],
plugins: [
aliasConfig,
resolve({
extensions: ['.ts', '.tsx'],
}),
postcss({
plugins: [],
}),
typescript({
tsconfig: './tsconfig.json',
}),
],
external: [
'react',
'react-dom',
'react-markdown',
'react/jsx-runtime',
'remark-breaks',
'leaflet',
'react-leaflet',
'react-toastify',
'react-string-replace',
'react-toastify/dist/ReactToastify.css',
'tw-elements',
'react-router-dom',
'react-leaflet-cluster',
'@tanstack/react-query',
'tributejs',
'prop-types',
'leaflet/dist/leaflet.css',
'@heroicons/react/20/solid',
'@heroicons/react/24/outline/ChevronRightIcon',
'@heroicons/react/24/outline',
'date-fns',
'@heroicons/react/24/outline/InformationCircleIcon',
'@heroicons/react/24/outline/QuestionMarkCircleIcon',
'@heroicons/react/24/outline/ChevronDownIcon',
'axios',
'react-image-crop',
'react-image-crop/dist/ReactCrop.css',
'react-colorful',
'leaflet.locatecontrol/dist/L.Control.Locate.css',
'yet-another-react-lightbox',
'react-photo-album',
],
},
{
input: 'dist/types/src/index.d.ts',
output: [{ file: 'dist/index.d.ts', format: 'es' }],
plugins: [
aliasConfig,
dts({
compilerOptions: {
skipLibCheck: true,
},
}),
],
external: [/\.css$/], //, /\.d\.ts$/
},
]