diff --git a/packages/grafana-data/package.json b/packages/grafana-data/package.json index 6ae5450bf1f..c33053087f2 100644 --- a/packages/grafana-data/package.json +++ b/packages/grafana-data/package.json @@ -29,10 +29,10 @@ ], "scripts": { "build": "tsc -p ./tsconfig.build.json && rollup -c rollup.config.ts --configPlugin esbuild", - "clean": "rimraf ./dist ./compiled ./package.tgz", + "clean": "rimraf ./dist ./compiled ./unstable ./package.tgz", "typecheck": "tsc --emitDeclarationOnly false --noEmit", - "prepack": "cp package.json package.json.bak && node ../../scripts/prepare-npm-package.js", - "postpack": "mv package.json.bak package.json" + "prepack": "cp package.json package.json.bak && ALIAS_PACKAGE_NAME=unstable node ../../scripts/prepare-npm-package.js", + "postpack": "mv package.json.bak package.json && rimraf ./unstable" }, "dependencies": { "@braintree/sanitize-url": "7.0.1", diff --git a/packages/grafana-data/rollup.config.ts b/packages/grafana-data/rollup.config.ts index 5a913449466..f67f12e07d0 100644 --- a/packages/grafana-data/rollup.config.ts +++ b/packages/grafana-data/rollup.config.ts @@ -11,5 +11,23 @@ export default [ plugins, output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-data')], }, + { + input: 'src/unstable.ts', + plugins, + output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-data')], + }, tsDeclarationOutput(pkg), + tsDeclarationOutput(pkg, { + input: './compiled/unstable.d.ts', + output: [ + { + file: './dist/cjs/unstable.d.cts', + format: 'cjs', + }, + { + file: './dist/esm/unstable.d.mts', + format: 'es', + }, + ], + }), ]; diff --git a/packages/grafana-data/src/unstable.ts b/packages/grafana-data/src/unstable.ts new file mode 100644 index 00000000000..8a42447206f --- /dev/null +++ b/packages/grafana-data/src/unstable.ts @@ -0,0 +1,13 @@ +/** + * THESE APIS MUST NOT BE USED IN COMMUNITY PLUGINS. + * + * Unstable APIs are still in development and are subject to breaking changes + * at any point, like feature flags but for APIS. They must only be used in + * Grafana core and internal plugins where we can coordinate changes. + * + * Once mature, they will be moved to the main export, be available to plugins via the standard import path, + * and be subject to the standard policies + */ + +// This is a dummy export so typescript doesn't error importing an "empty module" +export const unstable = {}; diff --git a/packages/grafana-runtime/package.json b/packages/grafana-runtime/package.json index 058e41e4d49..4211e3d2387 100644 --- a/packages/grafana-runtime/package.json +++ b/packages/grafana-runtime/package.json @@ -31,10 +31,10 @@ "scripts": { "build": "tsc -p ./tsconfig.build.json && rollup -c rollup.config.ts --configPlugin esbuild", "bundle": "rollup -c rollup.config.ts --configPlugin esbuild", - "clean": "rimraf ./dist ./compiled ./package.tgz", + "clean": "rimraf ./dist ./compiled ./unstable ./package.tgz", "typecheck": "tsc --emitDeclarationOnly false --noEmit", - "prepack": "cp package.json package.json.bak && node ../../scripts/prepare-npm-package.js", - "postpack": "mv package.json.bak package.json" + "prepack": "cp package.json package.json.bak && ALIAS_PACKAGE_NAME=unstable node ../../scripts/prepare-npm-package.js", + "postpack": "mv package.json.bak package.json && rimraf ./unstable" }, "dependencies": { "@grafana/data": "11.6.0-pre", diff --git a/packages/grafana-runtime/rollup.config.ts b/packages/grafana-runtime/rollup.config.ts index 02f523deee1..dc9c05e1421 100644 --- a/packages/grafana-runtime/rollup.config.ts +++ b/packages/grafana-runtime/rollup.config.ts @@ -11,5 +11,23 @@ export default [ plugins, output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-runtime')], }, + { + input: 'src/unstable.ts', + plugins, + output: [cjsOutput(pkg), esmOutput(pkg, 'grafana-runtime')], + }, tsDeclarationOutput(pkg), + tsDeclarationOutput(pkg, { + input: './compiled/unstable.d.ts', + output: [ + { + file: './dist/cjs/unstable.d.cts', + format: 'cjs', + }, + { + file: './dist/esm/unstable.d.mts', + format: 'es', + }, + ], + }), ]; diff --git a/packages/grafana-runtime/src/unstable.ts b/packages/grafana-runtime/src/unstable.ts new file mode 100644 index 00000000000..8a42447206f --- /dev/null +++ b/packages/grafana-runtime/src/unstable.ts @@ -0,0 +1,13 @@ +/** + * THESE APIS MUST NOT BE USED IN COMMUNITY PLUGINS. + * + * Unstable APIs are still in development and are subject to breaking changes + * at any point, like feature flags but for APIS. They must only be used in + * Grafana core and internal plugins where we can coordinate changes. + * + * Once mature, they will be moved to the main export, be available to plugins via the standard import path, + * and be subject to the standard policies + */ + +// This is a dummy export so typescript doesn't error importing an "empty module" +export const unstable = {}; diff --git a/public/app/features/plugins/loader/sharedDependencies.ts b/public/app/features/plugins/loader/sharedDependencies.ts index c294491c6ac..3d0ae285034 100644 --- a/public/app/features/plugins/loader/sharedDependencies.ts +++ b/public/app/features/plugins/loader/sharedDependencies.ts @@ -49,7 +49,9 @@ export const sharedDependenciesMap = { '@emotion/css': () => import('@emotion/css'), '@emotion/react': () => import('@emotion/react'), '@grafana/data': grafanaData, + '@grafana/data/unstable': () => import('@grafana/data/src/unstable'), '@grafana/runtime': grafanaRuntime, + '@grafana/runtime/unstable': () => import('@grafana/runtime/src/unstable'), '@grafana/slate-react': () => import('slate-react'), '@grafana/ui': grafanaUI, '@grafana/ui/unstable': () => import('@grafana/ui/src/unstable'),