mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 17:42:20 +08:00

* chore(packages): remove rollup dts plugin * build(packages): add rollup copy plugin settings to copy ts declarations to esm and cjs builds * build(packages): remove copy settings as result doesnt pass attw cli checks * build(packages): use single types output in dist/types directory * ci(packages): update prepare and validate scripts for single type builds * fix(grafana-schema): copy raw types to dist/esm directory for grafana/scenes support
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { glob } from 'glob';
|
|
import { createRequire } from 'node:module';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'path';
|
|
import copy from 'rollup-plugin-copy';
|
|
|
|
import { cjsOutput, entryPoint, esmOutput, plugins } from '../rollup.config.parts';
|
|
|
|
const rq = createRequire(import.meta.url);
|
|
const pkg = rq('./package.json');
|
|
|
|
const [_, noderesolve, esbuild] = plugins;
|
|
|
|
export default [
|
|
{
|
|
input: entryPoint,
|
|
plugins,
|
|
output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-schema')],
|
|
},
|
|
{
|
|
input: Object.fromEntries(
|
|
glob
|
|
.sync('src/raw/composable/**/*.ts')
|
|
.map((file) => [
|
|
path.relative('src', file.slice(0, file.length - path.extname(file).length)),
|
|
fileURLToPath(new URL(file, import.meta.url)),
|
|
])
|
|
),
|
|
plugins: [
|
|
noderesolve,
|
|
esbuild,
|
|
// Support @grafana/scenes that pulls in types from nested @grafana/schema files.
|
|
copy({
|
|
targets: [
|
|
{
|
|
src: 'dist/types/raw/composable/**/*.d.ts',
|
|
dest: 'dist/esm/raw/composable',
|
|
rename: (_name, _extension, fullpath) => fullpath.split(path.sep).slice(4).join('/'),
|
|
},
|
|
],
|
|
hook: 'writeBundle',
|
|
}),
|
|
],
|
|
output: {
|
|
format: 'esm',
|
|
dir: path.dirname(pkg.publishConfig.module),
|
|
},
|
|
},
|
|
];
|