Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
"eject": "react-scripts eject",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:build-ts3.8": "pnpm install && pnpm add [email protected] && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && pnpm build",
"test:assert": "pnpm -v"
},
Expand All @@ -43,13 +42,5 @@
},
"volta": {
"extends": "../../package.json"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build-ts3.8",
"label": "create-react-app (TS 3.8)"
}
]
}
}
2 changes: 0 additions & 2 deletions dev-packages/e2e-tests/test-applications/generic-ts3.8/.npmrc

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"test": "playwright test",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:build-ts3.8": "pnpm install && pnpm add [email protected] && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && pnpm build",
"test:assert": "pnpm test"
},
Expand Down Expand Up @@ -51,13 +50,5 @@
},
"volta": {
"extends": "../../package.json"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build-ts3.8",
"label": "react-router-6 (TS 3.8)"
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"test": "playwright test",
"clean": "npx rimraf node_modules pnpm-lock.yaml",
"test:build": "pnpm install && pnpm build",
"test:build-ts3.8": "pnpm install && pnpm add [email protected] && pnpm build",
"test:build-canary": "pnpm install && pnpm add react@canary react-dom@canary && pnpm build",
"test:assert": "pnpm test"
},
Expand All @@ -49,14 +48,6 @@
"volta": {
"extends": "../../package.json"
},
"sentryTest": {
"variants": [
{
"build-command": "pnpm test:build-ts3.8",
"label": "react-router-7-spa (TS 3.8)"
}
]
},
"pnpm": {
"overrides": {
"esbuild": "0.24.0"
Expand Down
15 changes: 13 additions & 2 deletions dev-packages/rollup-utils/npmHelpers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ import * as path from 'path';
import { fileURLToPath } from 'url';
import deepMerge from 'deepmerge';
import { defineConfig } from 'rolldown';
import { dts as makeDtsPlugin } from 'rolldown-plugin-dts';
import {
makeDebugBuildStatementReplacePlugin,
makeProductionReplacePlugin,
makeRrwebBuildPlugin,
} from './plugins/index.mjs';
import { makePackageNodeEsm } from './plugins/make-esm-plugin.mjs';
import { makeMoveDtsPlugin } from './plugins/move-dts-plugin.mjs';
import { mergePlugins } from './utils.mjs';

const __dirname = path.dirname(fileURLToPath(import.meta.url));
Expand Down Expand Up @@ -131,6 +133,12 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
}

if (emitEsm) {
const hasTypes = fs.existsSync(path.resolve(process.cwd(), './tsconfig.types.json'));
const dts = makeDtsPlugin({
tsconfig: path.resolve(process.cwd(), hasTypes ? './tsconfig.types.json' : './tsconfig.json'),
tsgo: true,
});

if (splitDevProd) {
variantSpecificConfigs.push({
output: {
Expand All @@ -139,19 +147,22 @@ export function makeNPMConfigVariants(baseConfig, options = {}) {
plugins: [makePackageNodeEsm()],
},
});

variantSpecificConfigs.push({
plugins: [dts],
output: {
format: 'esm',
dir: path.join(baseConfig.output.dir, 'esm/prod'),
plugins: [makeProductionReplacePlugin(), makePackageNodeEsm()],
plugins: [makeProductionReplacePlugin(), makePackageNodeEsm(), makeMoveDtsPlugin()],
},
});
} else {
variantSpecificConfigs.push({
plugins: [dts],
output: {
format: 'esm',
dir: path.join(baseConfig.output.dir, 'esm'),
plugins: [makePackageNodeEsm()],
plugins: [makePackageNodeEsm(), makeMoveDtsPlugin()],
},
});
}
Expand Down
73 changes: 73 additions & 0 deletions dev-packages/rollup-utils/plugins/move-dts-plugin.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import fs from 'node:fs';
import fsPromises from 'node:fs/promises';
import path from 'node:path';

/**
* Plugin that moves all .d.ts and .d.ts.map files from build/esm to build/types after the build completes.
* This preserves the directory structure within the types directory.
* Optimized for speed with parallel file operations.
*/
export function makeMoveDtsPlugin() {
return {
name: 'move-dts-files',
async writeBundle() {
const buildEsmDir = path.resolve(process.cwd(), 'build/esm');
const buildTypesDir = path.resolve(process.cwd(), 'build/types');

// Check if build/esm exists
if (!fs.existsSync(buildEsmDir)) {
return;
}

// Ensure build/types directory exists (recursive handles existing dirs)
await fsPromises.mkdir(buildTypesDir, { recursive: true });

/**
* Recursively find all .d.ts and .d.ts.map files in a directory
* @param {string} dir - Directory to search
* @param {string} baseDir - Base directory for relative path calculation
* @returns {Array<{relativePath: string, fullPath: string, targetPath: string}>} Array of file info objects
*/
function findDtsFiles(dir, baseDir = dir) {
const files = [];
const entries = fs.readdirSync(dir, { withFileTypes: true });

for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
const relativePath = path.relative(baseDir, fullPath);

if (entry.isDirectory()) {
files.push(...findDtsFiles(fullPath, baseDir));
} else if (entry.isFile() && (entry.name.endsWith('.d.ts') || entry.name.endsWith('.d.ts.map'))) {
const targetPath = path.join(buildTypesDir, relativePath);
files.push({ relativePath, fullPath, targetPath });
}
}

return files;
}

const dtsFiles = findDtsFiles(buildEsmDir);

// Early exit if no files to move
if (dtsFiles.length === 0) {
return;
}

// Collect all unique directories that need to be created
const dirsToCreate = new Set();
for (const { targetPath } of dtsFiles) {
const targetDir = path.dirname(targetPath);
if (targetDir !== buildTypesDir) {
dirsToCreate.add(targetDir);
}
}

// Create all directories in parallel
await Promise.all(Array.from(dirsToCreate).map(dir => fsPromises.mkdir(dir, { recursive: true })));

// Move all files in parallel
await Promise.all(dtsFiles.map(({ fullPath, targetPath }) => fsPromises.rename(fullPath, targetPath)));
},
};
}
2 changes: 2 additions & 0 deletions dev-packages/rollup-utils/plugins/npmPlugins.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import { replacePlugin } from 'rolldown/plugins';

export { makeMoveDtsPlugin } from './move-dts-plugin.mjs';

/**
* Create a plugin which can be used to pause the build process at the given hook.
*
Expand Down
9 changes: 2 additions & 7 deletions nx.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,8 @@
},
"build:types": {
"inputs": ["production", "^production"],
"dependsOn": ["^build:types"],
"outputs": [
"{projectRoot}/build/types",
"{projectRoot}/build/types-ts3.8",
"{projectRoot}/build/npm/types",
"{projectRoot}/build/npm/types-ts3.8"
]
"dependsOn": ["build:transpile", "^build:transpile", "^build:types"],
"outputs": ["{projectRoot}/build/types", "{projectRoot}/build/npm/types"]
},
"lint": {
"inputs": ["default"],
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@
"@size-limit/webpack": "~11.1.6",
"@types/jsdom": "^21.1.6",
"@types/node": "^18.19.1",
"@typescript/native-preview": "^7.0.0-dev.20251210.1",
"@vitest/coverage-v8": "^3.2.4",
"deepmerge": "^4.2.2",
"downlevel-dts": "~0.11.0",
"es-check": "^7.2.1",
"eslint": "8.57.0",
"jsdom": "^21.1.2",
Expand All @@ -122,6 +122,7 @@
"prettier-plugin-astro": "^0.14.1",
"rimraf": "^5.0.10",
"rolldown": "^1.0.0-beta.55",
"rolldown-plugin-dts": "^0.18.3",
"size-limit": "~11.1.6",
"ts-node": "10.9.1",
"typescript": "~5.8.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"require": "./build/cjs/index.server.js"
},
"./middleware": {
"types": "./build/types/integration/middleware/index.types.d.ts",
"types": "./build/types/integration/middleware/index.d.ts",
"node": "./build/esm/integration/middleware/index.js",
"import": "./build/esm/integration/middleware/index.js",
"require": "./build/cjs/integration/middleware/index.js"
Expand Down Expand Up @@ -69,11 +69,10 @@
"build": "run-p build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rolldown -c rollup.npm.config.mjs",
"build:types": "tsc -p tsconfig.types.json",
"build:types": "echo \"Types included with build\"",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"circularDepCheck": "madge --circular src/index.client.ts && madge --circular src/index.server.ts && madge --circular src/index.types.ts",
"clean": "rimraf build coverage sentry-astro-*.tgz",
Expand Down
7 changes: 6 additions & 1 deletion packages/astro/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ import { makeBaseNPMConfig, makeNPMConfigVariants, makeOtelLoaders } from '@sent

const variants = makeNPMConfigVariants(
makeBaseNPMConfig({
entrypoints: ['src/index.server.ts', 'src/index.client.ts', 'src/integration/middleware/index.ts'],
entrypoints: [
'src/index.server.ts',
'src/index.client.ts',
'src/index.types.ts',
'src/integration/middleware/index.ts',
],
packageSpecificConfig: {
output: {
dynamicImportInCjs: true,
Expand Down
16 changes: 3 additions & 13 deletions packages/aws-serverless/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,6 @@
}
}
},
"typesVersions": {
"<5.0": {
"build/npm/types/index.d.ts": [
"build/npm/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
Expand All @@ -79,17 +72,14 @@
"@vercel/nft": "^0.29.4"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build": "run-s build:transpile build:types",
"build:layer": "rimraf build/aws && rolldown -c rollup.lambda-extension.config.mjs && yarn ts-node scripts/buildLambdaLayer.ts",
"build:dev": "run-p build:transpile build:types",
"build:dev": "run-s build:transpile build:types",
"build:transpile": "rolldown -c rollup.npm.config.mjs && yarn build:layer",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/npm/types build/npm/types-ts3.8 --to ts3.8",
"build:types": "echo \"Types included with build\"",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "yarn build:watch",
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"circularDepCheck": "madge --circular src/index.ts",
"clean": "rimraf build dist-awslambda-layer coverage sentry-serverless-*.tgz",
Expand Down
14 changes: 2 additions & 12 deletions packages/browser-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,30 +28,20 @@
}
}
},
"typesVersions": {
"<5.0": {
"build/types/index.d.ts": [
"build/types-ts3.8/index.d.ts"
]
}
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@sentry/core": "10.32.1"
},
"scripts": {
"build": "run-p build:transpile build:types",
"build": "run-s build:transpile build:types",
"build:dev": "yarn build",
"build:transpile": "rolldown -c rollup.npm.config.mjs",
"build:types": "run-s build:types:core build:types:downlevel",
"build:types:core": "tsc -p tsconfig.types.json",
"build:types:downlevel": "yarn downlevel-dts build/types build/types-ts3.8 --to ts3.8",
"build:types": "echo \"Types included with build\"",
"build:watch": "run-p build:transpile:watch build:types:watch",
"build:dev:watch": "run-p build:transpile:watch build:types:watch",
"build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",
"build:types:watch": "tsc -p tsconfig.types.json --watch",
"build:tarball": "npm pack",
"clean": "rimraf build coverage sentry-internal-browser-utils-*.tgz",
"fix": "eslint . --format stylish --fix",
Expand Down
Loading
Loading