Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ yarn-error.log
node_modules/
dist/
dist-basic/
.dts-tmp-*/

.vitrine/*
!.vitrine/project.json
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
14 changes: 14 additions & 0 deletions .yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
diff --git a/dist/types-usage-evaluator.js b/dist/types-usage-evaluator.js
index a09f141f087b152c34ad9c88e66ed516f8294865..b3eb7f6a799992fe6c15b7caaa17a7eecde24478 100644
--- a/dist/types-usage-evaluator.js
+++ b/dist/types-usage-evaluator.js
@@ -111,6 +111,9 @@ class TypesUsageEvaluator {
if (ts.isExportDeclaration(node) && node.exportClause !== undefined && ts.isNamedExports(node.exportClause)) {
for (const exportElement of node.exportClause.elements) {
const exportElementSymbol = (0, typescript_1.getImportExportReferencedSymbol)(exportElement, this.typeChecker);
+ if (exportElementSymbol === undefined) {
+ continue;
+ }
// i.e. `import * as NS from './local-module'`
const namespaceImportForElement = (0, typescript_1.getDeclarationsForSymbol)(exportElementSymbol).find(ts.isNamespaceImport);
if (namespaceImportForElement !== undefined) {
2 changes: 1 addition & 1 deletion LICENSES-3rdparty.csv
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ diff,npm,BSD-3-Clause,(https://www.npmjs.com/package/diff)
diff-sequences,npm,MIT,(https://www.npmjs.com/package/diff-sequences)
dir-glob,npm,MIT,Kevin Mårtensson (github.com/kevva)
doctrine,npm,Apache-2.0,(https://github.com/eslint/doctrine)
dts-bundle-generator,patch,MIT,Evgeniy Timokhov (https://github.com/timocov/dts-bundle-generator)
eastasianwidth,npm,MIT,Masaki Komagata (https://www.npmjs.com/package/eastasianwidth)
ecc-jsbn,npm,MIT,Jeremie Miller (https://github.com/quartzjer/ecc-jsbn)
ejs,npm,Apache-2.0,Matthew Eernisse (https://github.com/mde/ejs)
Expand Down Expand Up @@ -696,7 +697,6 @@ retry,npm,MIT,Tim Koschützki (https://github.com/tim-kos/node-retry)
reusify,npm,MIT,Matteo Collina (https://github.com/mcollina/reusify#readme)
rimraf,npm,ISC,Isaac Z. Schlueter (http://blog.izs.me/)
rollup,npm,MIT,Rich Harris (https://rollupjs.org/)
rollup-plugin-dts,virtual,LGPL-3.0-only,Arpad Borsos (https://github.com/Swatinem/rollup-plugin-dts#readme)
rollup-plugin-esbuild,virtual,MIT,EGOIST (https://www.npmjs.com/package/rollup-plugin-esbuild)
rollup-plugin-import-css,virtual,MIT,Jacob Leeson (https://github.com/jleeson/rollup-plugin-import-css#readme)
run-parallel,npm,MIT,Feross Aboukhadijeh (https://github.com/feross/run-parallel)
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
"typescript": "5.4.3"
},
"resolutions": {
"rollup": "4.45.1"
"rollup": "4.45.1",
"dts-bundle-generator/typescript": "5.4.3",
"dts-bundle-generator@npm:9.5.1": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch"
},
"packageManager": "yarn@4.10.3"
}
16 changes: 8 additions & 8 deletions packages/plugins/apps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"directory": "packages/plugins/apps"
},
"buildPlugin": {
"hideFromRootReadme": true
},
"toBuild": {
"apps-runtime": {
"entry": "./src/built/apps-runtime.ts",
"format": [
"esm"
]
"hideFromRootReadme": true,
"toBuild": {
"apps-runtime": {
"entry": "./src/built/apps-runtime.ts",
"format": [
"esm"
]
}
}
},
"exports": {
Expand Down
29 changes: 17 additions & 12 deletions packages/plugins/rum/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
"directory": "packages/plugins/rum"
},
"buildPlugin": {
"hideFromRootReadme": true
},
"toBuild": {
"rum-browser-sdk": {
"entry": "./src/built/rum-browser-sdk.ts"
},
"privacy-helpers": {
"format": [
"cjs",
"esm"
],
"entry": "./src/built/privacy-helpers.ts"
"hideFromRootReadme": true,
"inlinedLibraries": [
"@datadog/browser-core",
"@datadog/browser-rum-core"
],
"toBuild": {
"rum-browser-sdk": {
"entry": "./src/built/rum-browser-sdk.ts"
},
"privacy-helpers": {
"format": [
"cjs",
"esm"
],
"entry": "./src/built/privacy-helpers.ts"
}
}
},
"exports": {
Expand All @@ -40,6 +44,7 @@
},
"devDependencies": {
"@datadog/browser-rum": "6.26.0",
"@datadog/browser-rum-core": "6.26.0",
"typescript": "5.4.3"
}
}
5 changes: 5 additions & 0 deletions packages/plugins/rum/src/browserSdkTypes.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

export type { RumPublicApi, RumInitConfiguration } from '@datadog/browser-rum-core';
3 changes: 2 additions & 1 deletion packages/plugins/rum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import type { PluginOptions, GetPlugins } from '@dd/core/types';
import { InjectPosition } from '@dd/core/types';
import path from 'path';

import type { RumInitConfiguration, RumPublicApi } from './browserSdkTypes';
import { CONFIG_KEY, PLUGIN_NAME } from './constants';
import { getSourceCodeContextSnippet } from './getSourceCodeContextSnippet';
import { getPrivacyPlugin } from './privacy';
import { getInjectionValue } from './sdk';
import type { RumOptions, RumOptionsWithSdk, RumPublicApi, RumInitConfiguration } from './types';
import type { RumOptions, RumOptionsWithSdk } from './types';
import { validateOptions } from './validate';

export { CONFIG_KEY, PLUGIN_NAME };
Expand Down
8 changes: 1 addition & 7 deletions packages/plugins/rum/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import type {
datadogRum,
RumInitConfiguration as ExpRumInitConfiguration,
} from '@datadog/browser-rum';
import type { Assign } from '@dd/core/types';

import type { RumInitConfiguration } from './browserSdkTypes';
import type { PrivacyOptions, PrivacyOptionsWithDefaults } from './privacy/types';

export type SourceCodeContextOptions = {
Expand All @@ -22,9 +19,6 @@ export type RumOptions = {
sourceCodeContext?: SourceCodeContextOptions;
};

export type RumPublicApi = typeof datadogRum;
export type RumInitConfiguration = ExpRumInitConfiguration;

export type SDKOptions = Assign<
RumInitConfiguration,
{
Expand Down
2 changes: 1 addition & 1 deletion packages/published/esbuild-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/rollup-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/rspack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/vite-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/published/webpack-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@
"@rollup/plugin-terser": "0.4.4",
"@types/babel__core": "^7",
"@types/babel__preset-env": "^7",
"dts-bundle-generator": "patch:dts-bundle-generator@npm%3A9.5.1#~/.yarn/patches/dts-bundle-generator-npm-9.5.1-0927b6826f.patch",
"esbuild": "0.25.8",
"rollup": "4.45.1",
"rollup-plugin-dts": "6.1.1",
"rollup-plugin-esbuild": "6.1.1",
"typescript": "5.4.3"
},
Expand Down
3 changes: 3 additions & 0 deletions packages/tools/src/commands/integrity/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Integrity extends Command {
const { updateDependencies } = await import('./dependencies');
const { updateFiles } = await import('./files');
const { updateReadmes, injectTocsInAllReadmes, verifyLinks } = await import('./readme');
const { updateTsconfigPaths } = await import('./tsconfig');
const { getWorkspaces } = await import('@dd/tools/helpers');

const workspaces = await getWorkspaces();
Expand All @@ -51,6 +52,8 @@ class Integrity extends Command {
errors.push(...(await verifyLinks()));
// Update the files that need to be updated.
errors.push(...(await updateFiles(plugins)));
// Sync @dd/* paths in the root tsconfig with each workspace's package.json exports.
updateTsconfigPaths(workspaces);
// Run auto-fixes to ensure the code is correct.
errors.push(...(await runAutoFixes()));

Expand Down
55 changes: 55 additions & 0 deletions packages/tools/src/commands/integrity/tsconfig.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Unless explicitly stated otherwise all files in this repository are licensed under the MIT License.
// This product includes software developed at Datadog (https://www.datadoghq.com/).
// Copyright 2019-Present Datadog, Inc.

import { outputJsonSync, readJsonSync } from '@dd/core/helpers/fs';
import { ROOT } from '@dd/tools/constants';
import { green } from '@dd/tools/helpers';
import type { Workspace } from '@dd/tools/types';
import path from 'path';

type PackageExports = Record<string, string | Record<string, string>>;

const buildExpectedPaths = (workspaces: Workspace[]): Record<string, string[]> => {
const paths: Record<string, string[]> = {};
for (const workspace of workspaces) {
if (!workspace.name.startsWith('@dd/')) {
continue;
}
const pkg = readJsonSync(path.resolve(ROOT, workspace.location, 'package.json'));
const pkgExports: PackageExports | undefined = pkg.exports;
if (!pkgExports) {
continue;
}
const location = workspace.location.replace(/\\/g, '/');
const mainExport = pkgExports['.'];
if (typeof mainExport === 'string') {
paths[workspace.name] = [`${location}/${mainExport.replace(/^\.\//, '')}`];
}
const wildcardExport = pkgExports['./*'];
if (typeof wildcardExport === 'string') {
const target = wildcardExport.replace(/^\.\//, '').replace(/\*\.ts$/, '*');
paths[`${workspace.name}/*`] = [`${location}/${target}`];
}
}
return paths;
};

const sortObject = <T>(obj: Record<string, T>): Record<string, T> => {
return Object.fromEntries(Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)));
};

export const updateTsconfigPaths = (workspaces: Workspace[]) => {
const tsconfigPath = path.resolve(ROOT, 'tsconfig.json');
const tsconfig = readJsonSync(tsconfigPath);
const expected = sortObject(buildExpectedPaths(workspaces));
const current = tsconfig.compilerOptions?.paths ?? {};

if (JSON.stringify(current) === JSON.stringify(expected)) {
return;
}

console.log(` Update ${green('@dd/*')} paths in ${green('tsconfig.json')}.`);
tsconfig.compilerOptions = { ...tsconfig.compilerOptions, paths: expected };
outputJsonSync(tsconfigPath, tsconfig);
};
Loading
Loading