Merge branch 'main' into ash/react-19-again

This commit is contained in:
Ashley Harrison
2026-01-05 15:11:45 +00:00
1019 changed files with 50998 additions and 15934 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "commonjs"
"moduleResolution": "nodenext",
"module": "NodeNext"
},
"extends": "../../tsconfig.json",
"ts-node": {
+19 -92
View File
@@ -1,108 +1,35 @@
//@ts-check
import PackageJson from '@npmcli/package-json';
import { mkdir } from 'node:fs/promises';
const cwd = process.cwd();
try {
const pkgJson = await PackageJson.load(cwd);
const cjsIndex = pkgJson.content.publishConfig?.main ?? pkgJson.content.main;
const esmIndex = pkgJson.content.publishConfig?.module ?? pkgJson.content.module;
const typesIndex = pkgJson.content.publishConfig?.types ?? pkgJson.content.types;
const pkgJsonExports = pkgJson.content.exports;
const exports = {
'./package.json': './package.json',
'.': {
import: {
types: typesIndex,
default: esmIndex,
},
require: {
types: typesIndex,
default: cjsIndex,
},
},
};
// Fix so scenes can access `@grafana/schema` nested dist import paths e.g.
// import {} from '@grafana/schema/dist/esm/raw/composable/bargauge/panelcfg/x/BarGaugePanelCfg_types.gen'
if (pkgJson.content.name === '@grafana/schema') {
exports['./dist/*'] = {
types: './dist/*',
default: './dist/*',
};
}
// Fix for @grafana/i18n so eslint-plugin can be imported by consumers
if (pkgJson.content.name === '@grafana/i18n') {
exports['./eslint-plugin'] = {
types: './dist/eslint/index.d.ts',
import: './dist/eslint/index.cjs',
require: './dist/eslint/index.cjs',
};
}
pkgJson.update({
main: cjsIndex,
types: typesIndex,
module: esmIndex,
exports,
});
await pkgJson.save();
// If an alias package name is provided we add an exports entry for the alias
// then generate an additional "nested" package.json for typescript resolution that
// doesn't use the exports property in package.json.
if (process.env.ALIAS_PACKAGE_NAME) {
const aliasNames = process.env.ALIAS_PACKAGE_NAME.split(',');
const additionalExports = aliasNames.reduce((acc, alias) => {
acc[`./${alias}`] = {
import: {
types: typesIndex.replace('index', alias),
default: esmIndex.replace('index', alias),
},
require: {
types: typesIndex.replace('index', alias),
default: cjsIndex.replace('index', alias),
},
};
return acc;
}, {});
// skip packages without exports otherwise consumers cannot import anything from the package
if (pkgJsonExports && typeof pkgJsonExports === 'object') {
// Remove all exports that only contain a single key '@grafana-app/source'
// as these will not resolve when validating packages with attw because the
// source code is not available in the tarball.
for (const [key, val] of Object.entries(pkgJsonExports)) {
if (
val !== null &&
typeof val === 'object' &&
Object.keys(val).length === 1 &&
Object.keys(val)[0] === '@grafana-app/source'
) {
delete pkgJsonExports[key];
}
}
pkgJson.update({
exports: {
...pkgJson.content.exports,
...additionalExports,
},
files: [...pkgJson.content.files, ...aliasNames],
exports: pkgJsonExports,
});
await pkgJson.save();
for await (const aliasName of aliasNames) {
await createAliasPackageJsonFiles(pkgJson.content, aliasName);
}
await pkgJson.save();
}
} catch (e) {
console.error(e);
process.exit(1);
}
async function createAliasPackageJsonFiles(packageJsonContent, aliasName) {
const pkgName = `${packageJsonContent.name}/${aliasName}`;
try {
console.log(`📦 Writing alias package.json for ${pkgName}.`);
const pkgJsonPath = `${cwd}/${aliasName}`;
await mkdir(pkgJsonPath, { recursive: true });
const pkgJson = await PackageJson.create(pkgJsonPath, {
data: {
name: pkgName,
types: `../dist/types/${aliasName}.d.ts`,
main: `../dist/cjs/${aliasName}.cjs`,
module: `../dist/esm/${aliasName}.mjs`,
},
});
await pkgJson.save();
} catch (error) {
throw new Error(`Error generating package.json for ${pkgName}`, error);
}
}
+1
View File
@@ -4,6 +4,7 @@
"alwaysStrict": true,
"strict": true,
"allowSyntheticDefaultImports": true,
"customConditions": ["@grafana-app/source"],
"downlevelIteration": true,
"esModuleInterop": true,
"experimentalDecorators": true,
+1 -1
View File
@@ -17,7 +17,7 @@ for file in "$ARTIFACTS_DIR"/*.tgz; do
fi
# shellcheck disable=SC2086
if ! yarn attw "$file" --ignore-rules "false-cjs" $ATTW_FLAGS; then
if ! NODE_OPTIONS="-C @grafana-app/source" yarn attw "$file" --ignore-rules "false-cjs" $ATTW_FLAGS; then
echo "attw check failed for $file"
echo ""
failed_checks+=("$file - yarn attw")
+1
View File
@@ -22,6 +22,7 @@ module.exports = {
publicPath: 'public/build/',
},
resolve: {
conditionNames: ['@grafana-app/source', '...'],
extensions: ['.ts', '.tsx', '.es6', '.js', '.json', '.svg'],
alias: {
// some of data source plugins use global Prism object to add the language definition