diff --git a/dev-packages/e2e-tests/test-applications/package-types/.gitignore b/dev-packages/e2e-tests/test-applications/package-types/.gitignore new file mode 100644 index 000000000000..562ebe0503a1 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/.gitignore @@ -0,0 +1,2 @@ +dist +generated diff --git a/dev-packages/e2e-tests/test-applications/package-types/README.md b/dev-packages/e2e-tests/test-applications/package-types/README.md new file mode 100644 index 000000000000..dad10ede347c --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/README.md @@ -0,0 +1,28 @@ +# Package Types Test + +This test "app" checks that the types of all `@sentry/*` packages match their JS files, for Node's `require`, Node's +`import` and bundlers. + +- `scripts/check-entries.mjs` checks that the app depends on every published package with types, and that every + exports entry without types is in `JS_ONLY_ENTRIES`. The other checks skip entries without types. +- `scripts/check-attw.mjs` checks every package with [attw](https://github.com/arethetypeswrong/arethetypeswrong.github.io). + It fails for a problem that is not in `KNOWN_PROBLEMS`, and for a known problem that attw does not report any more. +- `scripts/check-types.mjs` imports every exports entry that has types, with TypeScript 5.0, 5.9, 6.0 and 7.0, in + `nodenext`, `bundler` and `node10` mode, and with the `react-native` condition. A default import must be an error + where the runtime loads an ESM file without a default export, and must be `module.exports` where it loads a CJS file. +- `scripts/check-runtime.mjs` checks that a CJS file sets `__esModule` only if its entry has a default export, and + runs the fixtures in `src` (see https://github.com/getsentry/sentry-javascript/issues/3105). + +The checks need the `overrides` and the `SENTRY_E2E_WORKSPACE_ROOT` variable that the E2E runner adds, so run them +with `pnpm run test:run package-types` in `dev-packages/e2e-tests`. + +## How to add a new package + +Add the package as a dependency. The checks find its exports entries in its `package.json`. + +## How to add an entry + +- Entry with types: nothing to do. +- Entry with a default export: add it to `DEFAULT_EXPORT_ENTRIES` in `scripts/entries.mjs`. +- Entry without types (a hook, a loader or a file that a build tool injects): add it to `JS_ONLY_ENTRIES` in + `scripts/entries.mjs`. diff --git a/dev-packages/e2e-tests/test-applications/package-types/package.json b/dev-packages/e2e-tests/test-applications/package-types/package.json new file mode 100644 index 000000000000..ed92a4216750 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/package.json @@ -0,0 +1,68 @@ +{ + "name": "package-types", + "version": "0.0.0", + "private": true, + "type": "module", + "scripts": { + "build": "node node_modules/typescript-7.0/bin/tsc -p tsconfig.runtime.json", + "test:build": "pnpm install && pnpm build", + "test:assert": "node scripts/check-entries.mjs && node scripts/check-attw.mjs && node scripts/check-types.mjs && node scripts/check-runtime.mjs" + }, + "dependencies": { + "@sentry/angular": "file:../../packed/sentry-angular-packed.tgz", + "@sentry/astro": "file:../../packed/sentry-astro-packed.tgz", + "@sentry/aws-serverless": "file:../../packed/sentry-aws-serverless-packed.tgz", + "@sentry/browser": "file:../../packed/sentry-browser-packed.tgz", + "@sentry/browser-utils": "file:../../packed/sentry-browser-utils-packed.tgz", + "@sentry/bun": "file:../../packed/sentry-bun-packed.tgz", + "@sentry/bundler-plugins": "file:../../packed/sentry-bundler-plugins-packed.tgz", + "@sentry/cloudflare": "file:../../packed/sentry-cloudflare-packed.tgz", + "@sentry/core": "file:../../packed/sentry-core-packed.tgz", + "@sentry/deno": "file:../../packed/sentry-deno-packed.tgz", + "@sentry/effect": "file:../../packed/sentry-effect-packed.tgz", + "@sentry/elysia": "file:../../packed/sentry-elysia-packed.tgz", + "@sentry/ember": "file:../../packed/sentry-ember-packed.tgz", + "@sentry/esbuild-plugin": "file:../../packed/sentry-esbuild-plugin-packed.tgz", + "@sentry/feedback": "file:../../packed/sentry-feedback-packed.tgz", + "@sentry/gatsby": "file:../../packed/sentry-gatsby-packed.tgz", + "@sentry/google-cloud-serverless": "file:../../packed/sentry-google-cloud-serverless-packed.tgz", + "@sentry/hono": "file:../../packed/sentry-hono-packed.tgz", + "@sentry/nestjs": "file:../../packed/sentry-nestjs-packed.tgz", + "@sentry/nextjs": "file:../../packed/sentry-nextjs-packed.tgz", + "@sentry/nitro": "file:../../packed/sentry-nitro-packed.tgz", + "@sentry/node": "file:../../packed/sentry-node-packed.tgz", + "@sentry/node-native": "file:../../packed/sentry-node-native-packed.tgz", + "@sentry/nuxt": "file:../../packed/sentry-nuxt-packed.tgz", + "@sentry/opentelemetry": "file:../../packed/sentry-opentelemetry-packed.tgz", + "@sentry/profiling-node": "file:../../packed/sentry-profiling-node-packed.tgz", + "@sentry/react": "file:../../packed/sentry-react-packed.tgz", + "@sentry/react-router": "file:../../packed/sentry-react-router-packed.tgz", + "@sentry/remix": "file:../../packed/sentry-remix-packed.tgz", + "@sentry/replay": "file:../../packed/sentry-replay-packed.tgz", + "@sentry/replay-canvas": "file:../../packed/sentry-replay-canvas-packed.tgz", + "@sentry/rollup-plugin": "file:../../packed/sentry-rollup-plugin-packed.tgz", + "@sentry/server-runtime-injection": "file:../../packed/sentry-server-runtime-injection-packed.tgz", + "@sentry/server-utils": "file:../../packed/sentry-server-utils-packed.tgz", + "@sentry/solid": "file:../../packed/sentry-solid-packed.tgz", + "@sentry/solidstart": "file:../../packed/sentry-solidstart-packed.tgz", + "@sentry/svelte": "file:../../packed/sentry-svelte-packed.tgz", + "@sentry/sveltekit": "file:../../packed/sentry-sveltekit-packed.tgz", + "@sentry/tanstackstart-react": "file:../../packed/sentry-tanstackstart-react-packed.tgz", + "@sentry/vercel-edge": "file:../../packed/sentry-vercel-edge-packed.tgz", + "@sentry/vite-plugin": "file:../../packed/sentry-vite-plugin-packed.tgz", + "@sentry/vue": "file:../../packed/sentry-vue-packed.tgz", + "@sentry/wasm": "file:../../packed/sentry-wasm-packed.tgz", + "@sentry/webpack-plugin": "file:../../packed/sentry-webpack-plugin-packed.tgz" + }, + "devDependencies": { + "@arethetypeswrong/core": "0.18.5", + "@types/node": "^20.19.0", + "typescript-5.0": "npm:typescript@5.0.4", + "typescript-5.9": "npm:typescript@5.9.3", + "typescript-6.0": "npm:typescript@6.0.3", + "typescript-7.0": "npm:typescript@7.0.2" + }, + "volta": { + "extends": "../../package.json" + } +} diff --git a/dev-packages/e2e-tests/test-applications/package-types/pnpm-workspace.yaml b/dev-packages/e2e-tests/test-applications/package-types/pnpm-workspace.yaml new file mode 100644 index 000000000000..4f65eb844464 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/pnpm-workspace.yaml @@ -0,0 +1,6 @@ +allowBuilds: + '@sentry/node-cpu-profiler': false + '@sentry/node-native-stacktrace': false +minimumReleaseAge: 0 +# The checks read only the files of the Sentry packages, so the framework peer dependencies are not needed. +autoInstallPeers: false diff --git a/dev-packages/e2e-tests/test-applications/package-types/scripts/check-attw.mjs b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-attw.mjs new file mode 100644 index 000000000000..a1cd418a9cff --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-attw.mjs @@ -0,0 +1,127 @@ +/** + * Checks the types of every `@sentry/*` package with "Are the types wrong?" (attw), for Node's `require`, Node's + * `import` and bundlers. It fails for every problem that is not in `KNOWN_PROBLEMS`, and for every entry in + * `KNOWN_PROBLEMS` that attw does not report any more. + */ +import { checkPackage, Package } from '@arethetypeswrong/core'; +import { problemAffectsEntrypointResolution } from '@arethetypeswrong/core/problems'; +import fs from 'node:fs'; +import path from 'node:path'; +import { getPackageDir, getPackageJson, getPackageNames, getTypedEntries } from './entries.mjs'; + +const RESOLUTION_KINDS = ['node16-cjs', 'node16-esm', 'bundler']; + +/** What attw reports for `require` of an entry that has no CJS build. */ +const ESM_ONLY_PROBLEMS = new Set(['CJSResolvesToESM', 'NoResolution']); + +/** Problems in the published packages that are not fixed yet. Keys are ` `. */ +const KNOWN_PROBLEMS = { + '@sentry/angular node16-cjs InternalResolutionError': + 'ng-packagr writes ESM declaration files with relative imports that have no file extension.', + '@sentry/angular node16-esm InternalResolutionError': + 'ng-packagr writes ESM declaration files with relative imports that have no file extension.', + '@sentry/astro node16-cjs InternalResolutionError': + 'The package has "type": "module", so its declaration files are ESM, and their relative imports have no file extension.', + '@sentry/astro node16-esm InternalResolutionError': + 'The package has "type": "module", so its declaration files are ESM, and their relative imports have no file extension.', + '@sentry/astro/integration node16-cjs InternalResolutionError': + 'The package has "type": "module", so its declaration files are ESM, and their relative imports have no file extension.', + '@sentry/astro/integration node16-esm InternalResolutionError': + 'The package has "type": "module", so its declaration files are ESM, and their relative imports have no file extension.', + '@sentry/deno node16-cjs InternalResolutionError': + 'The declaration files are in the ESM build folder, and their relative imports have no file extension.', + '@sentry/deno node16-esm InternalResolutionError': + 'The declaration files are in the ESM build folder, and their relative imports have no file extension.', + '@sentry/ember node16-cjs UnexpectedModuleSyntax': + 'dist/index.js has ESM syntax in a package without "type": "module". Only the Ember build loads it.', + '@sentry/ember node16-esm UnexpectedModuleSyntax': + 'dist/index.js has ESM syntax in a package without "type": "module". Only the Ember build loads it.', + '@sentry/nextjs node16-esm NamedExports': + "Node's `import` loads the CJS build (`node` condition), and Node does not detect some of its named exports, for example `logger`.", + '@sentry/nuxt/module/plugins node16-esm UnexpectedModuleSyntax': + 'The plugin files have ESM syntax in a package without "type": "module". Only the Nuxt build loads them.', + '@sentry/remix node16-esm NamedExports': + "Node's `import` loads the CJS build (`node` condition), and Node does not detect some of its named exports, for example `growthbookIntegration`.", +}; + +const unexpected = new Map(); +const found = new Set(); + +for (const name of getPackageNames()) { + const entries = getTypedEntries(name); + const typedSubpaths = new Set(entries.map(entry => entry.subpath)); + const esmOnlySubpaths = new Set( + entries.filter(entry => entry.formats.nodeRequire !== 'cjs').map(entry => entry.subpath), + ); + const { exports, version } = getPackageJson(name); + + const analysis = await checkPackage(new Package(readPackageFiles(name), name, version), { + // Entries without types are JS-only (hooks, loaders, injected files). + excludeEntrypoints: Object.keys(exports).filter(subpath => !typedSubpaths.has(subpath)), + }); + + if (!analysis.types) { + unexpected.set(name, 'The package has no types.'); + continue; + } + + for (const problem of analysis.problems) { + for (const subpath of Object.keys(analysis.entrypoints)) { + for (const resolutionKind of RESOLUTION_KINDS) { + if (!problemAffectsEntrypointResolution(problem, subpath, resolutionKind, analysis)) { + continue; + } + if (resolutionKind === 'node16-cjs' && esmOnlySubpaths.has(subpath) && ESM_ONLY_PROBLEMS.has(problem.kind)) { + continue; + } + + const key = `${name}${subpath === '.' ? '' : subpath.slice(1)} ${resolutionKind} ${problem.kind}`; + found.add(key); + if (!KNOWN_PROBLEMS[key] && !unexpected.has(key)) { + unexpected.set(key, JSON.stringify(problem)); + } + } + } + } +} + +const fixed = Object.keys(KNOWN_PROBLEMS).filter(key => !found.has(key)); + +if (unexpected.size) { + console.error(`attw found ${unexpected.size} new problems:\n`); + for (const [key, details] of unexpected) { + console.error(`${key}\n ${details}`); + } + console.error('\nSee https://github.com/arethetypeswrong/arethetypeswrong.github.io/tree/main/docs/problems\n'); +} +if (fixed.length) { + console.error( + `attw does not report these known problems any more, remove them from KNOWN_PROBLEMS:\n${fixed.join('\n')}`, + ); +} +if (unexpected.size || fixed.length) { + process.exit(1); +} + +console.log(`attw: ${getPackageNames().length} packages, no new problems.`); + +/** Reads the files of an installed package in the format of `Package` (paths start with `/node_modules//`). */ +function readPackageFiles(name) { + const packageDir = getPackageDir(name); + const files = {}; + const walk = dir => { + for (const dirent of fs.readdirSync(dir, { withFileTypes: true })) { + const filePath = path.join(dir, dirent.name); + if (dirent.isDirectory()) { + if (dirent.name !== 'node_modules') { + walk(filePath); + } + } else { + const relativePath = path.relative(packageDir, filePath).split(path.sep).join('/'); + files[`/node_modules/${name}/${relativePath}`] = new Uint8Array(fs.readFileSync(filePath)); + } + } + }; + walk(packageDir); + return files; +} diff --git a/dev-packages/e2e-tests/test-applications/package-types/scripts/check-entries.mjs b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-entries.mjs new file mode 100644 index 000000000000..b6a03e26eed5 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-entries.mjs @@ -0,0 +1,51 @@ +/** + * Checks that the other checks cover every package and every entry: + * - The app depends on every `@sentry/*` package of the repository that has types. + * - Every exports entry without types is in `JS_ONLY_ENTRIES`, because the other checks skip entries without types. + */ +import fs from 'node:fs'; +import path from 'node:path'; +import { getEntriesWithoutTypes, getPackageNames, JS_ONLY_ENTRIES, PACKAGES_WITHOUT_TYPES } from './entries.mjs'; + +// The E2E runner and CI set it to the repository root. +const workspaceRoot = process.env.SENTRY_E2E_WORKSPACE_ROOT; +if (!workspaceRoot) { + console.error('SENTRY_E2E_WORKSPACE_ROOT is not set. Run the app with `pnpm run test:run package-types`.'); + process.exit(1); +} + +const failed = []; +const dependencies = new Set(getPackageNames()); + +const packagesDir = path.join(workspaceRoot, 'packages'); +for (const dirent of fs.readdirSync(packagesDir, { withFileTypes: true })) { + const packageJsonPath = path.join(packagesDir, dirent.name, 'package.json'); + if (!dirent.isDirectory() || !fs.existsSync(packageJsonPath)) { + continue; + } + const { name } = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')); + if (name.startsWith('@sentry/') && !dependencies.has(name) && !PACKAGES_WITHOUT_TYPES.has(name)) { + failed.push(`${name} is not a dependency of this app. Add it to package.json.`); + } +} + +const entriesWithoutTypes = new Set([...dependencies].flatMap(name => getEntriesWithoutTypes(name))); +for (const specifier of entriesWithoutTypes) { + if (!JS_ONLY_ENTRIES.has(specifier)) { + failed.push( + `${specifier} has no types. Add types, or add it to JS_ONLY_ENTRIES if it is a hook, loader or injected file.`, + ); + } +} +for (const specifier of JS_ONLY_ENTRIES) { + if (!entriesWithoutTypes.has(specifier)) { + failed.push(`${specifier} is in JS_ONLY_ENTRIES, but it has types or does not exist. Remove it from the list.`); + } +} + +if (failed.length) { + console.error(failed.join('\n')); + process.exit(1); +} + +console.log(`Entries: ${dependencies.size} packages, ${JS_ONLY_ENTRIES.size} entries without types.`); diff --git a/dev-packages/e2e-tests/test-applications/package-types/scripts/check-runtime.mjs b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-runtime.mjs new file mode 100644 index 000000000000..7a07fb44d293 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-runtime.mjs @@ -0,0 +1,47 @@ +/** + * Checks the JS files that Node loads: + * - A CJS file sets `__esModule` only if its entry has a default export. With `__esModule`, a default import + * compiled by TypeScript (`esModuleInterop`) or a bundler reads `exports.default`, which is `undefined` for an entry + * without a default export (https://github.com/getsentry/sentry-javascript/issues/3105). + * - The fixtures in `src`, compiled to `dist`, run without errors. + */ +import { execFileSync } from 'node:child_process'; +import fs from 'node:fs'; +import { createRequire } from 'node:module'; +import path from 'node:path'; +import { APP_DIR, getPackageNames, getTypedEntries } from './entries.mjs'; + +const ES_MODULE_MARKER_REGEX = + /Object\.defineProperty\(\s*exports\s*,\s*['"]__esModule['"]|Object\.defineProperties\(\s*exports\s*,\s*\{\s*__esModule\s*:|exports\.__esModule\s*=/; + +const require = createRequire(path.join(APP_DIR, 'package.json')); +const failed = []; + +for (const entry of getPackageNames().flatMap(name => getTypedEntries(name))) { + if (entry.formats.nodeRequire !== 'cjs') { + continue; + } + + const file = require.resolve(entry.specifier); + const hasMarker = ES_MODULE_MARKER_REGEX.test(fs.readFileSync(file, 'utf8')); + if (hasMarker !== entry.hasDefaultExport) { + failed.push( + `${entry.specifier}: ${path.relative(APP_DIR, file)} ${hasMarker ? 'sets' : 'does not set'} __esModule, but the entry ${entry.hasDefaultExport ? 'has' : 'has no'} default export.`, + ); + } +} + +for (const fixture of ['default-import.cjs', 'namespace-import.mjs']) { + try { + execFileSync(process.execPath, [path.join(APP_DIR, 'dist', fixture)], { stdio: 'inherit' }); + } catch { + failed.push(`dist/${fixture} failed.`); + } +} + +if (failed.length) { + console.error(failed.join('\n')); + process.exit(1); +} + +console.log('Runtime: all checks passed.'); diff --git a/dev-packages/e2e-tests/test-applications/package-types/scripts/check-types.mjs b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-types.mjs new file mode 100644 index 000000000000..8be197fcd324 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/scripts/check-types.mjs @@ -0,0 +1,171 @@ +/** + * Type-checks a namespace import and a default import of every typed entry of every `@sentry/*` package, with + * several TypeScript versions and module settings. + * + * The expected result of a default import comes from the JS file that the runtime loads: + * - ESM file: TypeScript must report an error, unless the entry has a real default export. + * - CJS file: the default import is `module.exports`, or the real default export where the runtime reads + * `__esModule` (TypeScript's `esModuleInterop` and bundlers, but not Node's `import`). + */ +import { execFileSync } from 'node:child_process'; +import fs from 'node:fs'; +import path from 'node:path'; +import { APP_DIR, getPackageJson, getPackageNames, getTypedEntries } from './entries.mjs'; + +const GENERATED_DIR = path.join(APP_DIR, 'generated'); + +const COMPILER_OPTIONS = { + strict: true, + noEmit: true, + skipLibCheck: true, + target: 'es2022', + lib: ['es2022', 'dom'], + types: ['node'], +}; + +const CONFIGS = { + nodenext: { compilerOptions: { module: 'nodenext', moduleResolution: 'nodenext' }, files: ['esm.mts', 'cjs.cts'] }, + bundler: { compilerOptions: { module: 'esnext', moduleResolution: 'bundler' }, files: ['bundler.ts'] }, + // TypeScript reports a missing default export of an ESM file in bundler mode only since 5.6. + 'bundler-no-default': { + compilerOptions: { module: 'esnext', moduleResolution: 'bundler' }, + files: ['bundler-no-default.ts'], + }, + // The setup of https://github.com/getsentry/sentry-javascript/issues/3105. TypeScript 7 removed `node10`. + node10: { + compilerOptions: { module: 'commonjs', moduleResolution: 'node10', esModuleInterop: true }, + files: ['node10.ts'], + }, + // The setup of `@react-native/typescript-config`. Like `bundler-no-default`, it needs TypeScript 5.6 or higher. + 'react-native': { + compilerOptions: { module: 'esnext', moduleResolution: 'bundler', customConditions: ['react-native'] }, + files: ['react-native.ts'], + }, +}; + +const TYPESCRIPT_VERSIONS = { + // The lowest version that the SDK supports. + 'typescript-5.0': { configs: ['nodenext', 'bundler', 'node10'] }, + 'typescript-5.9': { configs: ['nodenext', 'bundler', 'bundler-no-default', 'node10', 'react-native'] }, + 'typescript-6.0': { + configs: ['nodenext', 'bundler', 'bundler-no-default', 'node10', 'react-native'], + args: ['--ignoreDeprecations', '6.0'], + }, + 'typescript-7.0': { configs: ['nodenext', 'bundler', 'bundler-no-default', 'react-native'] }, +}; + +// A type from a dependency that the app does not install (for example a framework) is `any`, so both checks accept it. +const HEADER = `// Generated by scripts/check-types.mjs. +type IsAny = 0 extends 1 & T ? true : false; +/** \`true\` if the default import has all named exports, like \`module.exports\` of a CJS module. */ +type IsWholeModule = + IsAny extends true ? true : [Exclude] extends [keyof Default] ? true : false; +/** \`true\` if the default import has a \`default\` property, like \`module.exports\` of a CJS module with a default export. */ +type HasDefaultProperty = IsAny extends true ? false : 'default' extends keyof Default ? true : false; +`; + +/** Returns the code that imports an entry and checks what its default import is. */ +function importCode(entry, index, defaultImport) { + const ns = `ns${index}`; + const def = `default${index}`; + const lines = [`import * as ${ns} from '${entry.specifier}';`]; + + if (defaultImport === 'error') { + lines.push( + '// @ts-expect-error -- The ESM build has no default export.', + `import ${def} from '${entry.specifier}';`, + ); + } else if (defaultImport === 'module') { + lines.push( + `import ${def} from '${entry.specifier}';`, + `const check${index}: IsWholeModule = true;`, + ); + } else if (defaultImport === 'real') { + lines.push( + `import ${def} from '${entry.specifier}';`, + `const check${index}: HasDefaultProperty = false;`, + ); + } + + return lines.join('\n'); +} + +/** + * What a default import gives for a JS file of `format`: `error`, `module` (`module.exports`) or `real` (the + * default export). `readsEsModule` is true where the import reads the `__esModule` marker of a CJS file. + */ +function defaultImportOf(entry, format, readsEsModule) { + if (format === 'esm') { + return entry.hasDefaultExport ? 'real' : 'error'; + } + return entry.hasDefaultExport && readsEsModule ? 'real' : 'module'; +} + +const entries = getPackageNames().flatMap(name => getTypedEntries(name)); +const files = { + 'esm.mts': [], + 'cjs.cts': [], + 'bundler.ts': [], + 'bundler-no-default.ts': [], + 'node10.ts': [], + 'react-native.ts': [], +}; + +entries.forEach((entry, index) => { + const { nodeImport, nodeRequire, bundler, reactNative } = entry.formats; + + if (nodeImport) { + files['esm.mts'].push(importCode(entry, index, defaultImportOf(entry, nodeImport, false))); + } + if (nodeRequire === 'cjs') { + files['cjs.cts'].push(importCode(entry, index, defaultImportOf(entry, nodeRequire, true))); + // `node10` ignores `exports` and reads only the `types` field. + if (entry.subpath === '.' && getPackageJson(entry.packageName).types) { + files['node10.ts'].push(importCode(entry, index, defaultImportOf(entry, nodeRequire, true))); + } + } + if (bundler) { + const defaultImport = defaultImportOf(entry, bundler, true); + files['bundler.ts'].push(importCode(entry, index, defaultImport === 'error' ? 'none' : defaultImport)); + if (defaultImport === 'error') { + files['bundler-no-default.ts'].push(importCode(entry, index, 'error')); + } + } + if (reactNative && entry.hasReactNativeCondition) { + files['react-native.ts'].push(importCode(entry, index, defaultImportOf(entry, reactNative, true))); + } +}); + +fs.rmSync(GENERATED_DIR, { recursive: true, force: true }); +fs.mkdirSync(GENERATED_DIR); +for (const [file, blocks] of Object.entries(files)) { + fs.writeFileSync(path.join(GENERATED_DIR, file), `${HEADER}\n${blocks.join('\n\n')}\n\nexport {};\n`); +} +for (const [name, { compilerOptions, files: configFiles }] of Object.entries(CONFIGS)) { + const tsconfig = { compilerOptions: { ...COMPILER_OPTIONS, ...compilerOptions }, files: configFiles }; + fs.writeFileSync(path.join(GENERATED_DIR, `tsconfig.${name}.json`), `${JSON.stringify(tsconfig, null, 2)}\n`); +} + +const failed = []; +for (const [typescript, { configs, args = [] }] of Object.entries(TYPESCRIPT_VERSIONS)) { + const tsc = path.join(APP_DIR, 'node_modules', typescript, 'bin', 'tsc'); + for (const config of configs) { + const label = `${typescript} ${config}`; + try { + execFileSync(process.execPath, [tsc, '-p', path.join(GENERATED_DIR, `tsconfig.${config}.json`), ...args], { + stdio: 'inherit', + }); + console.log(`${label}: ok`); + } catch { + console.error(`${label}: failed`); + failed.push(label); + } + } +} + +if (failed.length) { + console.error(`\nType checks failed: ${failed.join(', ')}`); + process.exit(1); +} + +console.log(`\nTypes: ${entries.length} entries, all type checks passed.`); diff --git a/dev-packages/e2e-tests/test-applications/package-types/scripts/entries.mjs b/dev-packages/e2e-tests/test-applications/package-types/scripts/entries.mjs new file mode 100644 index 000000000000..525335e4085f --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/scripts/entries.mjs @@ -0,0 +1,162 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +export const APP_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); + +/** Entries with a real default export. All other entries with types have no default export. */ +export const DEFAULT_EXPORT_ENTRIES = new Set([ + '@sentry/astro', + '@sentry/astro/integration', + '@sentry/bundler-plugins/babel-plugin', + '@sentry/bundler-plugins/bun', + '@sentry/bundler-plugins/esbuild', + '@sentry/cloudflare/orchestrion-diagnostics-channel', + '@sentry/esbuild-plugin', + '@sentry/nuxt/module', +]); + +/** Entries without types: hooks, loaders and files that a build tool injects. All other entries must have types. */ +export const JS_ONLY_ENTRIES = new Set([ + '@sentry/astro/import', + '@sentry/aws-serverless/awslambda-auto', + '@sentry/aws-serverless/dist/awslambda-auto', + '@sentry/aws-serverless/import', + '@sentry/aws-serverless/run-lambda-handler', + '@sentry/bundler-plugins/sentry-esbuild-debugid-injection-file', + '@sentry/bundler-plugins/sentry-release-injection-file', + '@sentry/bundler-plugins/webpack-loader', + '@sentry/deno/import', + '@sentry/ember/addon-main.js', + '@sentry/google-cloud-serverless/import', + '@sentry/nextjs/async-storage-shim', + '@sentry/nextjs/import', + '@sentry/nextjs/orchestrion-runtime/*', + '@sentry/node-native/event-loop-block-watchdog', + '@sentry/node/import', + '@sentry/remix/import', + '@sentry/remix/v3/node', + '@sentry/server-runtime-injection/hook', + '@sentry/server-runtime-injection/import-hook', + '@sentry/server-utils/orchestrion/webpack-loader', + '@sentry/tanstackstart-react/import', +]); + +/** Published packages that have no types, so this app does not depend on them. */ +export const PACKAGES_WITHOUT_TYPES = new Set([ + '@sentry/eslint-config-sdk', + '@sentry/eslint-plugin-sdk', + '@sentry/typescript', +]); + +/** Conditions of Node's `import`, Node's `require`, a bundler that builds for the browser, and Metro (React Native). */ +const RESOLVERS = { + nodeImport: ['node', 'import'], + nodeRequire: ['node', 'require'], + bundler: ['browser', 'import'], + reactNative: ['react-native', 'import'], +}; + +export function getPackageNames() { + const packageJson = readJson(path.join(APP_DIR, 'package.json')); + return Object.keys(packageJson.dependencies).filter(name => name.startsWith('@sentry/')); +} + +export function getPackageDir(name) { + return fs.realpathSync(path.join(APP_DIR, 'node_modules', name)); +} + +export function getPackageJson(name) { + return readJson(path.join(getPackageDir(name), 'package.json')); +} + +/** + * Lists the exports entries of a package that have types. For each resolver, `formats` holds the module format + * (`esm` or `cjs`) of the JS file that it loads, or `undefined` if the entry has no JS file for it. + * `hasReactNativeCondition` is true if the entry has a `react-native` condition. + */ +export function getTypedEntries(name) { + const packageDir = getPackageDir(name); + const { exports } = getPackageJson(name); + + return Object.entries(exports) + .filter( + ([subpath, value]) => subpath !== './package.json' && !subpath.includes('*') && hasCondition(value, 'types'), + ) + .map(([subpath, value]) => { + const specifier = toSpecifier(name, subpath); + const formats = Object.fromEntries( + Object.entries(RESOLVERS).map(([resolver, conditions]) => { + const target = resolveTarget(value, conditions); + return [resolver, target && getModuleFormat(packageDir, target)]; + }), + ); + return { + packageName: name, + specifier, + subpath, + formats, + hasDefaultExport: DEFAULT_EXPORT_ENTRIES.has(specifier), + hasReactNativeCondition: hasCondition(value, 'react-native'), + }; + }); +} + +/** Lists the specifiers of the exports entries of a package that have no types. */ +export function getEntriesWithoutTypes(name) { + return Object.entries(getPackageJson(name).exports) + .filter(([subpath, value]) => subpath !== './package.json' && !hasCondition(value, 'types')) + .map(([subpath]) => toSpecifier(name, subpath)); +} + +function toSpecifier(name, subpath) { + return subpath === '.' ? name : `${name}${subpath.slice(1)}`; +} + +function hasCondition(value, condition) { + return ( + !!value && + typeof value === 'object' && + Object.entries(value).some(([key, v]) => key === condition || hasCondition(v, condition)) + ); +} + +/** Resolves an exports value like Node does, but ignores `types`. */ +function resolveTarget(value, conditions) { + if (typeof value === 'string') { + return value; + } + + for (const [key, nested] of Object.entries(value ?? {})) { + if (key !== 'types' && (key === 'default' || conditions.includes(key))) { + const target = resolveTarget(nested, conditions); + if (target !== undefined) { + return target; + } + } + } + + return undefined; +} + +function getModuleFormat(packageDir, target) { + if (target.endsWith('.mjs')) { + return 'esm'; + } + if (target.endsWith('.cjs')) { + return 'cjs'; + } + + for (let dir = path.dirname(path.join(packageDir, target)); dir.startsWith(packageDir); dir = path.dirname(dir)) { + const packageJsonPath = path.join(dir, 'package.json'); + if (fs.existsSync(packageJsonPath)) { + return readJson(packageJsonPath).type === 'module' ? 'esm' : 'cjs'; + } + } + + return 'cjs'; +} + +function readJson(filePath) { + return JSON.parse(fs.readFileSync(filePath, 'utf8')); +} diff --git a/dev-packages/e2e-tests/test-applications/package-types/src/default-import.cts b/dev-packages/e2e-tests/test-applications/package-types/src/default-import.cts new file mode 100644 index 000000000000..dc393d1c3e94 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/src/default-import.cts @@ -0,0 +1,9 @@ +// The setup of https://github.com/getsentry/sentry-javascript/issues/3105: a default import, compiled to CJS. +import assert from 'node:assert'; +import SentryBrowser from '@sentry/browser'; +import SentryCore from '@sentry/core'; +import SentryNode from '@sentry/node'; + +assert.equal(typeof SentryBrowser.init, 'function'); +assert.equal(typeof SentryCore.captureException, 'function'); +assert.equal(typeof SentryNode.init, 'function'); diff --git a/dev-packages/e2e-tests/test-applications/package-types/src/namespace-import.mts b/dev-packages/e2e-tests/test-applications/package-types/src/namespace-import.mts new file mode 100644 index 000000000000..2cf4f0b55bdb --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/src/namespace-import.mts @@ -0,0 +1,13 @@ +import assert from 'node:assert'; +import * as SentryBrowser from '@sentry/browser'; +import * as SentryCore from '@sentry/core'; +import * as SentryNode from '@sentry/node'; + +for (const namespace of [SentryBrowser, SentryCore, SentryNode]) { + // The types of these entries report a default import as an error, because the ESM builds have no default export. + assert.ok(!('default' in namespace)); +} + +assert.equal(typeof SentryBrowser.init, 'function'); +assert.equal(typeof SentryCore.captureException, 'function'); +assert.equal(typeof SentryNode.init, 'function'); diff --git a/dev-packages/e2e-tests/test-applications/package-types/tsconfig.runtime.json b/dev-packages/e2e-tests/test-applications/package-types/tsconfig.runtime.json new file mode 100644 index 000000000000..b16cd4754b10 --- /dev/null +++ b/dev-packages/e2e-tests/test-applications/package-types/tsconfig.runtime.json @@ -0,0 +1,13 @@ +{ + "compilerOptions": { + "module": "nodenext", + "moduleResolution": "nodenext", + "target": "es2022", + "strict": true, + "skipLibCheck": true, + "types": ["node"], + "rootDir": "src", + "outDir": "dist" + }, + "files": ["src/default-import.cts", "src/namespace-import.mts"] +} diff --git a/dev-packages/rollup-utils/write-esm-types.mjs b/dev-packages/rollup-utils/write-esm-types.mjs new file mode 100644 index 000000000000..554e1816d1c8 --- /dev/null +++ b/dev-packages/rollup-utils/write-esm-types.mjs @@ -0,0 +1,59 @@ +/** + * Writes every `.d.mts` file that the `exports` map of `./package.json` references. Each one re-exports the + * `.d.ts` file next to it. + * + * TypeScript reads our `.d.ts` files as CommonJS, so for the `import` condition it allows + * `import Sentry from '@sentry/'`, although the ESM build has no default export. + * The `.d.mts` file is an ESM module, so TypeScript reports the missing default export. + * + * Run it in the package directory after `tsc` has emitted the declarations. + * Pass folders (for example `build/module`) to write only the `.d.mts` files in them. + */ +import fs from 'node:fs'; +import path from 'node:path'; + +const DEFAULT_EXPORT_REGEX = /^export (?:default\b|(?:declare )?\{[^}]*\b(?:as default|default\s*[,}]))/m; + +function collectDtsMtsPaths(exportsValue, paths = new Set()) { + if (typeof exportsValue === 'string') { + if (exportsValue.endsWith('.d.mts')) { + paths.add(path.normalize(exportsValue)); + } + } else if (exportsValue && typeof exportsValue === 'object') { + Object.values(exportsValue).forEach(value => collectDtsMtsPaths(value, paths)); + } + + return paths; +} + +function esmTypes(baseName, hasDefaultExport) { + const lines = [`export * from './${baseName}.js';`]; + + // `export *` skips `default`, and `export { default } from` would give the whole CJS module under `nodenext`, + // because TypeScript types the default import of a CJS file as `module.exports` there. + if (hasDefaultExport) { + lines.push( + `import type * as cjs from './${baseName}.js';`, + 'type DefaultExport = typeof cjs extends { default: { default: infer D } } ? D : typeof cjs extends { default: infer D } ? D : never;', + 'declare const _default: DefaultExport;', + 'export default _default;', + ); + } + + return `${lines.join('\n')}\n`; +} + +const folders = process.argv.slice(2).map(folder => `${path.normalize(folder)}${path.sep}`); +const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8')); + +for (const dtsMtsPath of collectDtsMtsPaths(packageJSON.exports)) { + if (folders.length && !folders.some(folder => dtsMtsPath.startsWith(folder))) { + continue; + } + + const baseName = path.basename(dtsMtsPath, '.d.mts'); + const dtsPath = path.join(path.dirname(dtsMtsPath), `${baseName}.d.ts`); + const hasDefaultExport = DEFAULT_EXPORT_REGEX.test(fs.readFileSync(dtsPath, 'utf-8')); + + fs.writeFileSync(dtsMtsPath, esmTypes(baseName, hasDefaultExport)); +} diff --git a/docs/new-sdk-release-checklist.md b/docs/new-sdk-release-checklist.md index b6c58e3f62d5..da7da25d9c36 100644 --- a/docs/new-sdk-release-checklist.md +++ b/docs/new-sdk-release-checklist.md @@ -44,6 +44,7 @@ differ slightly for other SDKs depending on how they are structured and how they - [ ] Make sure `build.yml` CI script is correctly set up to cover tests for the new package - [ ] Ensure unit tests run correctly - [ ] If it is a browser SDK, add it to `BROWSER_TEST_PACKAGES` in `scripts/ci-unit-tests.ts` + - [ ] Add it as a dependency of the `package-types` E2E app, which checks the types of every package - [ ] Make sure the file paths in the ["Upload Artifacts" job](https://github.com/getsentry/sentry-javascript/blob/e5c1486eed236b878f2c49d6a04be86093816ac9/.github/workflows/build.yml#L314-L349) diff --git a/packages/aws-serverless/package.json b/packages/aws-serverless/package.json index 9ca445d6fa29..3d806b85d288 100644 --- a/packages/aws-serverless/package.json +++ b/packages/aws-serverless/package.json @@ -21,7 +21,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/npm/types/index.d.ts", + "types": "./build/npm/types/index.d.mts", "default": "./build/npm/esm/index.js" }, "require": { @@ -53,7 +53,7 @@ }, "./esbuild": { "import": { - "types": "./build/npm/types/bundler-plugin/esbuild.d.ts", + "types": "./build/npm/types/bundler-plugin/esbuild.d.mts", "default": "./build/npm/esm/bundler-plugin/esbuild.js" }, "require": { @@ -85,7 +85,7 @@ "build:dev": "run-p build:transpile build:types", "build:transpile": "run-s build:transpile:npm build:extension", "build:transpile:npm": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/browser-utils/package.json b/packages/browser-utils/package.json index ebfdc40be99a..143286271041 100644 --- a/packages/browser-utils/package.json +++ b/packages/browser-utils/package.json @@ -20,7 +20,7 @@ ".": { "react-native": "./build/esm/index.js", "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -44,7 +44,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/browser/package.json b/packages/browser/package.json index c63397ee82ba..cf7798739469 100644 --- a/packages/browser/package.json +++ b/packages/browser/package.json @@ -18,7 +18,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/npm/types/index.d.ts", + "types": { + "import": "./build/npm/types/index.d.mts", + "default": "./build/npm/types/index.d.ts" + }, "react-native": "./build/npm/esm/prod/index.js", "development": { "import": "./build/npm/esm/dev/index.js", @@ -55,7 +58,7 @@ "build:dev": "run-p build:transpile build:types", "build:bundle": "rolldown -c rollup.bundle.config.mjs", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch build:bundle:watch", "build:dev:watch": "run-p build:transpile:watch", "build:bundle:watch": "rolldown -c rollup.bundle.config.mjs --watch", diff --git a/packages/bun/package.json b/packages/bun/package.json index 8d5aa84401c6..5a406dd774cc 100644 --- a/packages/bun/package.json +++ b/packages/bun/package.json @@ -20,7 +20,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -30,7 +30,7 @@ }, "./plugin": { "import": { - "types": "./build/types/plugin.d.ts", + "types": "./build/types/plugin.d.mts", "default": "./build/esm/plugin.js" }, "require": { @@ -57,7 +57,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/bundler-plugins/package.json b/packages/bundler-plugins/package.json index a4abe848d02c..5d0352827e8a 100644 --- a/packages/bundler-plugins/package.json +++ b/packages/bundler-plugins/package.json @@ -20,42 +20,66 @@ "exports": { "./package.json": "./package.json", "./webpack": { - "types": "./build/types/webpack/index.d.ts", + "types": { + "import": "./build/types/webpack/index.d.mts", + "default": "./build/types/webpack/index.d.ts" + }, "import": "./build/esm/webpack/index.js", "require": "./build/cjs/webpack/index.js" }, "./rollup": { - "types": "./build/types/rollup/index.d.ts", + "types": { + "import": "./build/types/rollup/index.d.mts", + "default": "./build/types/rollup/index.d.ts" + }, "import": "./build/esm/rollup/index.js", "require": "./build/cjs/rollup/index.js" }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" }, "./esbuild": { - "types": "./build/types/esbuild/index.d.ts", + "types": { + "import": "./build/types/esbuild/index.d.mts", + "default": "./build/types/esbuild/index.d.ts" + }, "import": "./build/esm/esbuild/index.js", "require": "./build/cjs/esbuild/index.js" }, "./bun": { - "types": "./build/types/bun/index.d.ts", + "types": { + "import": "./build/types/bun/index.d.mts", + "default": "./build/types/bun/index.d.ts" + }, "import": "./build/esm/bun/index.js", "require": "./build/cjs/bun/index.js" }, "./core": { - "types": "./build/types/core/index.d.ts", + "types": { + "import": "./build/types/core/index.d.mts", + "default": "./build/types/core/index.d.ts" + }, "import": "./build/esm/core/index.js", "require": "./build/cjs/core/index.js" }, "./loader-utils": { - "types": "./build/types/loader-utils/index.d.ts", + "types": { + "import": "./build/types/loader-utils/index.d.mts", + "default": "./build/types/loader-utils/index.d.ts" + }, "import": "./build/esm/loader-utils/index.js", "require": "./build/cjs/loader-utils/index.js" }, "./babel-plugin": { - "types": "./build/types/babel-plugin/index.d.ts", + "types": { + "import": "./build/types/babel-plugin/index.d.mts", + "default": "./build/types/babel-plugin/index.d.ts" + }, "import": "./build/esm/babel-plugin/index.js", "require": "./build/cjs/babel-plugin/index.js" }, @@ -76,7 +100,7 @@ "build:dev": "pnpm run build", "build:version": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/core/version.ts", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/cloudflare/package.json b/packages/cloudflare/package.json index 00523b4e4a39..f5b99ffc8842 100644 --- a/packages/cloudflare/package.json +++ b/packages/cloudflare/package.json @@ -18,7 +18,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "development": { "import": "./build/esm/dev/index.js", "require": "./build/cjs/dev/index.js" @@ -33,17 +36,26 @@ } }, "./request": { - "types": "./build/types/request.d.ts", + "types": { + "import": "./build/types/request.d.mts", + "default": "./build/types/request.d.ts" + }, "import": "./build/esm/prod/request.js", "require": "./build/cjs/prod/request.js" }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/prod/vite/index.js", "require": "./build/cjs/prod/vite/index.js" }, "./orchestrion-diagnostics-channel": { - "types": "./build/types/orchestrion-diagnostics-channel.d.ts", + "types": { + "import": "./build/types/orchestrion-diagnostics-channel.d.mts", + "default": "./build/types/orchestrion-diagnostics-channel.d.ts" + }, "import": "./build/esm/prod/orchestrion-diagnostics-channel.js", "require": "./build/cjs/prod/orchestrion-diagnostics-channel.js" } @@ -87,7 +99,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/core/package.json b/packages/core/package.json index 92c4ebc10bd8..be04c1bf18fe 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -23,11 +23,11 @@ "./package.json": "./package.json", "./server": { "react-native": { - "types": "./build/types/server.d.ts", + "types": "./build/types/server.d.mts", "default": "./build/esm/server.js" }, "import": { - "types": "./build/types/server.d.ts", + "types": "./build/types/server.d.mts", "default": "./build/esm/server.js" }, "require": { @@ -37,11 +37,11 @@ }, "./browser": { "react-native": { - "types": "./build/types/browser.d.ts", + "types": "./build/types/browser.d.mts", "default": "./build/esm/browser.js" }, "import": { - "types": "./build/types/browser.d.ts", + "types": "./build/types/browser.d.mts", "default": "./build/esm/browser.js" }, "require": { @@ -51,11 +51,11 @@ }, ".": { "react-native": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -71,7 +71,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/effect/package.json b/packages/effect/package.json index 58ecc48eb5ac..44b8fe0290c3 100644 --- a/packages/effect/package.json +++ b/packages/effect/package.json @@ -19,7 +19,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "browser": { "import": "./build/esm/index.client.js", "require": "./build/cjs/index.client.js" @@ -30,12 +33,18 @@ } }, "./server": { - "types": "./build/types/index.server.d.ts", + "types": { + "import": "./build/types/index.server.d.mts", + "default": "./build/types/index.server.d.ts" + }, "import": "./build/esm/index.server.js", "require": "./build/cjs/index.server.js" }, "./client": { - "types": "./build/types/index.client.d.ts", + "types": { + "import": "./build/types/index.client.d.mts", + "default": "./build/types/index.client.d.ts" + }, "import": "./build/esm/index.client.js", "require": "./build/cjs/index.client.js" } @@ -66,7 +75,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/elysia/package.json b/packages/elysia/package.json index f647f32bb9dc..8b251295e777 100644 --- a/packages/elysia/package.json +++ b/packages/elysia/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -53,7 +53,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/esbuild-plugin/package.json b/packages/esbuild-plugin/package.json index 5c2075d58fe9..8987b4033f62 100644 --- a/packages/esbuild-plugin/package.json +++ b/packages/esbuild-plugin/package.json @@ -27,7 +27,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" } @@ -36,7 +39,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/feedback/package.json b/packages/feedback/package.json index fffb9e6b72b2..1f20c524e78f 100644 --- a/packages/feedback/package.json +++ b/packages/feedback/package.json @@ -20,7 +20,7 @@ ".": { "react-native": "./build/npm/esm/index.js", "import": { - "types": "./build/npm/types/index.d.ts", + "types": "./build/npm/types/index.d.mts", "default": "./build/npm/esm/index.js" }, "require": { @@ -44,7 +44,7 @@ "build:transpile": "rolldown -c rollup.npm.config.mjs", "build:bundle": "rolldown -c rollup.bundle.config.mjs", "build:dev": "run-p build:transpile build:types", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch build:bundle:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "pnpm run build:transpile --watch", diff --git a/packages/gatsby/package.json b/packages/gatsby/package.json index bd76356eecef..6c617d67986b 100644 --- a/packages/gatsby/package.json +++ b/packages/gatsby/package.json @@ -25,7 +25,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -58,7 +58,7 @@ "build:plugin": "tsc -p tsconfig.plugin.json", "build:transpile": "run-p build:rollup build:plugin", "build:rollup": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/google-cloud-serverless/package.json b/packages/google-cloud-serverless/package.json index c14d67945949..745ef0a7ae64 100644 --- a/packages/google-cloud-serverless/package.json +++ b/packages/google-cloud-serverless/package.json @@ -18,7 +18,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -62,7 +62,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/hono/package.json b/packages/hono/package.json index 9a1cb3e0c245..e6d19220147a 100644 --- a/packages/hono/package.json +++ b/packages/hono/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -29,7 +29,7 @@ }, "./cloudflare": { "import": { - "types": "./build/types/index.cloudflare.d.ts", + "types": "./build/types/index.cloudflare.d.mts", "default": "./build/esm/index.cloudflare.js" }, "require": { @@ -39,7 +39,7 @@ }, "./node": { "import": { - "types": "./build/types/index.node.d.ts", + "types": "./build/types/index.node.d.mts", "default": "./build/esm/index.node.js" }, "require": { @@ -49,7 +49,7 @@ }, "./bun": { "import": { - "types": "./build/types/index.bun.d.ts", + "types": "./build/types/index.bun.d.mts", "default": "./build/esm/index.bun.js" }, "require": { @@ -59,7 +59,7 @@ }, "./deno": { "import": { - "types": "./build/types/index.deno.d.ts", + "types": "./build/types/index.deno.d.mts", "default": "./build/esm/index.deno.js" }, "require": { @@ -117,7 +117,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/nestjs/.gitignore b/packages/nestjs/.gitignore index 3e89751310a5..4853812f20f7 100644 --- a/packages/nestjs/.gitignore +++ b/packages/nestjs/.gitignore @@ -1,2 +1,3 @@ /*.d.ts +/*.d.mts /*.d.ts.map diff --git a/packages/nestjs/package.json b/packages/nestjs/package.json index 746c48f365e6..1d79794e36bc 100644 --- a/packages/nestjs/package.json +++ b/packages/nestjs/package.json @@ -12,6 +12,7 @@ "files": [ "/build", "/*.d.ts", + "/*.d.mts", "/*.d.ts.map" ], "main": "build/cjs/index.js", @@ -21,7 +22,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -31,7 +32,7 @@ }, "./setup": { "import": { - "types": "./setup.d.ts", + "types": "./setup.d.mts", "default": "./build/esm/setup.js" }, "require": { @@ -41,7 +42,7 @@ }, "./webpack": { "import": { - "types": "./build/types/bundler-plugin/webpack.d.ts", + "types": "./build/types/bundler-plugin/webpack.d.mts", "default": "./build/esm/bundler-plugin/webpack.js" }, "require": { @@ -74,14 +75,14 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core build:types:setup", + "build:types": "run-s build:types:core build:types:setup && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:types:setup": "tsc -p tsconfig.setup-types.json", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:tarball": "pnpm pack", - "clean": "node ../../scripts/rm.mjs build coverage sentry-nestjs-*.tgz ./*.d.ts ./*.d.ts.map", + "clean": "node ../../scripts/rm.mjs build coverage sentry-nestjs-*.tgz ./*.d.ts ./*.d.mts ./*.d.ts.map", "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", @@ -103,6 +104,7 @@ "outputs": [ "{projectRoot}/build/types", "{projectRoot}/*.d.ts", + "{projectRoot}/*.d.mts", "{projectRoot}/*.d.ts.map" ], "cache": true diff --git a/packages/nextjs/package.json b/packages/nextjs/package.json index 7dde0daa81d2..0bf7b132af67 100644 --- a/packages/nextjs/package.json +++ b/packages/nextjs/package.json @@ -18,7 +18,11 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "node": "./build/types/index.types.d.ts", + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "edge": { "import": "./build/esm/edge/index.js", "require": "./build/cjs/edge/index.js", @@ -55,7 +59,10 @@ "import": "./build/esm/index.server.js" }, "./cloudflare": { - "types": "./build/types/cloudflare/index.d.ts", + "types": { + "import": "./build/types/cloudflare/index.d.mts", + "default": "./build/types/cloudflare/index.d.ts" + }, "import": "./build/esm/cloudflare/index.js", "require": "./build/cjs/cloudflare/index.js" }, @@ -64,7 +71,10 @@ "default": "./build/cjs/config/index.js" }, "./tunnel": { - "types": "./build/types/tunnel/index.d.ts", + "types": { + "import": "./build/types/tunnel/index.d.mts", + "default": "./build/types/tunnel/index.d.ts" + }, "import": "./build/esm/tunnel/index.js", "require": "./build/cjs/tunnel/index.js" }, @@ -132,7 +142,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "tsx --tsconfig tsconfig.tsnode.json scripts/buildRollup.ts", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts", diff --git a/packages/nitro/package.json b/packages/nitro/package.json index 873f0893d713..da792860aecc 100644 --- a/packages/nitro/package.json +++ b/packages/nitro/package.json @@ -24,7 +24,7 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" } }, @@ -52,7 +52,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core", + "build:types": "run-s build:types:core && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:watch": "run-p build:transpile:watch build:types:watch", "build:dev:watch": "pnpm run build:watch", diff --git a/packages/node-native/package.json b/packages/node-native/package.json index 880063f1ea53..29331ae460c0 100644 --- a/packages/node-native/package.json +++ b/packages/node-native/package.json @@ -13,7 +13,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -48,7 +48,7 @@ "lint:fix": "oxlint . --fix --type-aware", "build": "pnpm run build:types && pnpm run build:transpile", "build:transpile": "pnpm exec rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:dev": "pnpm clean && pnpm run build", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:watch": "run-p build:transpile:watch", diff --git a/packages/node/package.json b/packages/node/package.json index 16a511f2f9e6..2ba3928c0089 100644 --- a/packages/node/package.json +++ b/packages/node/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -34,7 +34,7 @@ }, "./vite": { "import": { - "types": "./build/types/bundler-plugin/vite.d.ts", + "types": "./build/types/bundler-plugin/vite.d.mts", "default": "./build/esm/bundler-plugin/vite.js" }, "require": { @@ -44,7 +44,7 @@ }, "./rollup": { "import": { - "types": "./build/types/bundler-plugin/rollup.d.ts", + "types": "./build/types/bundler-plugin/rollup.d.mts", "default": "./build/esm/bundler-plugin/rollup.js" }, "require": { @@ -54,7 +54,7 @@ }, "./webpack": { "import": { - "types": "./build/types/bundler-plugin/webpack.d.ts", + "types": "./build/types/bundler-plugin/webpack.d.mts", "default": "./build/esm/bundler-plugin/webpack.js" }, "require": { @@ -64,7 +64,7 @@ }, "./esbuild": { "import": { - "types": "./build/types/bundler-plugin/esbuild.d.ts", + "types": "./build/types/bundler-plugin/esbuild.d.mts", "default": "./build/esm/bundler-plugin/esbuild.js" }, "require": { @@ -93,7 +93,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/nuxt/package.json b/packages/nuxt/package.json index 1d7750057282..6d933d3dca0a 100644 --- a/packages/nuxt/package.json +++ b/packages/nuxt/package.json @@ -19,7 +19,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "browser": { "import": "./build/esm/index.client.js", "require": "./build/cjs/index.client.js" @@ -32,7 +35,7 @@ "require": "./build/cjs/index.server.js" }, "./module": { - "types": "./build/module/types.d.ts", + "types": "./build/module/types.d.mts", "import": "./build/module/module.mjs" }, "./module/plugins": { @@ -82,9 +85,9 @@ "scripts": { "build": "run-s build:types build:transpile", "build:dev": "pnpm run build", - "build:nuxt-module": "rolldown -c rollup.module.config.mjs && tsc -p tsconfig.module.json && node scripts/build-module-meta.mjs", + "build:nuxt-module": "rolldown -c rollup.module.config.mjs && tsc -p tsconfig.module.json && node scripts/build-module-meta.mjs && node ../../dev-packages/rollup-utils/write-esm-types.mjs build/module", "build:transpile": "rolldown -c rollup.npm.config.mjs && pnpm run build:nuxt-module", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs build/types", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/opentelemetry/package.json b/packages/opentelemetry/package.json index 380fe0d71354..f072bdfcf2df 100644 --- a/packages/opentelemetry/package.json +++ b/packages/opentelemetry/package.json @@ -18,7 +18,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" } @@ -41,7 +44,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/profiling-node/package.json b/packages/profiling-node/package.json index 02a916ccbf0a..600b37905b6b 100644 --- a/packages/profiling-node/package.json +++ b/packages/profiling-node/package.json @@ -13,7 +13,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -40,7 +40,7 @@ "lint:fix": "oxlint . --fix --type-aware", "build": "pnpm run build:types && pnpm run build:transpile", "build:transpile": "pnpm exec rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:dev": "pnpm clean && pnpm run build", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:watch": "run-p build:transpile:watch", diff --git a/packages/react-router/package.json b/packages/react-router/package.json index 341ee22d26d8..814948f1eb79 100644 --- a/packages/react-router/package.json +++ b/packages/react-router/package.json @@ -19,7 +19,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "workerd": { "import": "./build/esm/cloudflare/index.js", "require": "./build/cjs/cloudflare/index.js", @@ -40,13 +43,19 @@ } }, "./cloudflare": { + "types": { + "import": "./build/types/cloudflare/index.d.mts", + "default": "./build/types/cloudflare/index.d.ts" + }, "import": "./build/esm/cloudflare/index.js", "require": "./build/cjs/cloudflare/index.js", - "types": "./build/types/cloudflare/index.d.ts", "default": "./build/esm/cloudflare/index.js" }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" } @@ -86,7 +95,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core", + "build:types": "run-s build:types:core && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", diff --git a/packages/react/package.json b/packages/react/package.json index 1400559fbc1c..84865d78c90f 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -19,11 +19,11 @@ "./package.json": "./package.json", ".": { "react-native": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -33,11 +33,11 @@ }, "./react-router": { "react-native": { - "types": "./build/types/react-router.d.ts", + "types": "./build/types/react-router.d.mts", "default": "./build/esm/react-router.js" }, "import": { - "types": "./build/types/react-router.d.ts", + "types": "./build/types/react-router.d.mts", "default": "./build/esm/react-router.js" }, "require": { @@ -92,7 +92,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/remix/package.json b/packages/remix/package.json index 9ee8d87c357c..c44fb899d347 100644 --- a/packages/remix/package.json +++ b/packages/remix/package.json @@ -24,7 +24,11 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "node": "./build/types/index.types.d.ts", + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "browser": { "import": "./build/esm/index.client.js", "require": "./build/cjs/index.client.js", @@ -38,13 +42,19 @@ } }, "./cloudflare": { + "types": { + "import": "./build/types/cloudflare/index.d.mts", + "default": "./build/types/cloudflare/index.d.ts" + }, "import": "./build/esm/cloudflare/index.js", "require": "./build/cjs/cloudflare/index.js", - "types": "./build/types/cloudflare/index.d.ts", "default": "./build/esm/cloudflare/index.js" }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" }, @@ -55,13 +65,13 @@ }, "./v3": { "import": { - "types": "./build/types/v3/index.server.d.ts", + "types": "./build/types/v3/index.server.d.mts", "default": "./build/esm/v3/index.server.js" } }, "./v3/client": { "import": { - "types": "./build/types/v3/index.client.d.ts", + "types": "./build/types/v3/index.client.d.mts", "default": "./build/esm/v3/client-bundle.js" } }, @@ -111,7 +121,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/replay-canvas/package.json b/packages/replay-canvas/package.json index 7abc0cc76ce6..27ecb8a6d1a3 100644 --- a/packages/replay-canvas/package.json +++ b/packages/replay-canvas/package.json @@ -10,7 +10,7 @@ ".": { "react-native": "./build/npm/esm/index.js", "import": { - "types": "./build/npm/types/index.d.ts", + "types": "./build/npm/types/index.d.mts", "default": "./build/npm/esm/index.js" }, "require": { @@ -28,7 +28,7 @@ "build:transpile": "rolldown -c rollup.npm.config.mjs", "build:bundle": "rolldown -c rollup.bundle.config.mjs", "build:dev": "run-p build:transpile build:types", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch build:bundle:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "pnpm run build:transpile --watch", diff --git a/packages/replay-internal/package.json b/packages/replay-internal/package.json index 0dec99748bb4..80109ec93fea 100644 --- a/packages/replay-internal/package.json +++ b/packages/replay-internal/package.json @@ -10,7 +10,7 @@ "./worker-bundler": { "react-native": "./build/npm/esm/worker-bundler.js", "import": { - "types": "./build/npm/types/worker-bundler.d.ts", + "types": "./build/npm/types/worker-bundler.d.mts", "default": "./build/npm/esm/worker-bundler.js" }, "require": { @@ -21,7 +21,7 @@ ".": { "react-native": "./build/npm/esm/index.js", "import": { - "types": "./build/npm/types/index.d.ts", + "types": "./build/npm/types/index.d.mts", "default": "./build/npm/esm/index.js" }, "require": { @@ -42,7 +42,7 @@ "build:transpile": "rolldown -c rollup.npm.config.mjs", "build:bundle": "rolldown -c rollup.bundle.config.mjs", "build:dev": "run-p build:transpile build:types", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch build:bundle:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "pnpm run build:transpile --watch", diff --git a/packages/rollup-plugin/package.json b/packages/rollup-plugin/package.json index 2b2f0b2241f1..2f86d495d363 100644 --- a/packages/rollup-plugin/package.json +++ b/packages/rollup-plugin/package.json @@ -28,7 +28,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" } @@ -37,7 +40,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/server-runtime-injection/package.json b/packages/server-runtime-injection/package.json index ef8b0b9e2cf8..b53bfa7a32ea 100644 --- a/packages/server-runtime-injection/package.json +++ b/packages/server-runtime-injection/package.json @@ -18,12 +18,18 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/register.d.ts", + "types": { + "import": "./build/types/register.d.mts", + "default": "./build/types/register.d.ts" + }, "import": "./build/esm/register.js", "require": "./build/cjs/register.js" }, "./register": { - "types": "./build/types/register.d.ts", + "types": { + "import": "./build/types/register.d.mts", + "default": "./build/types/register.d.ts" + }, "import": "./build/esm/register.js", "require": "./build/cjs/register.js" }, @@ -61,7 +67,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/server-utils/package.json b/packages/server-utils/package.json index 182ba3b08e5f..6ea1f6f59145 100644 --- a/packages/server-utils/package.json +++ b/packages/server-utils/package.json @@ -18,37 +18,58 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" }, "./no-diagnostic-channels": { - "types": "./build/types/index.no-diagnostic-channels.d.ts", + "types": { + "import": "./build/types/index.no-diagnostic-channels.d.mts", + "default": "./build/types/index.no-diagnostic-channels.d.ts" + }, "import": "./build/esm/index.no-diagnostic-channels.js", "require": "./build/cjs/index.no-diagnostic-channels.js" }, "./request-handler": { - "types": "./build/types/index.request-handler.d.ts", + "types": { + "import": "./build/types/index.request-handler.d.mts", + "default": "./build/types/index.request-handler.d.ts" + }, "import": "./build/esm/index.request-handler.js", "require": "./build/cjs/index.request-handler.js" }, "./orchestrion/config": { - "types": "./build/types/orchestrion/config/index.d.ts", + "types": { + "import": "./build/types/orchestrion/config/index.d.mts", + "default": "./build/types/orchestrion/config/index.d.ts" + }, "import": "./build/esm/orchestrion/config/index.js", "require": "./build/cjs/orchestrion/config/index.js" }, "./orchestrion/vite": { - "types": "./build/types/orchestrion/bundler/vite.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/vite.d.mts", + "default": "./build/types/orchestrion/bundler/vite.d.ts" + }, "import": "./build/esm/orchestrion/bundler/vite.js", "require": "./build/cjs/orchestrion/bundler/vite.js" }, "./orchestrion/rollup": { - "types": "./build/types/orchestrion/bundler/rollup.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/rollup.d.mts", + "default": "./build/types/orchestrion/bundler/rollup.d.ts" + }, "import": "./build/esm/orchestrion/bundler/rollup.js", "require": "./build/cjs/orchestrion/bundler/rollup.js" }, "./orchestrion/webpack": { - "types": "./build/types/orchestrion/bundler/webpack.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/webpack.d.mts", + "default": "./build/types/orchestrion/bundler/webpack.d.ts" + }, "import": "./build/esm/orchestrion/bundler/webpack.js", "require": "./build/cjs/orchestrion/bundler/webpack.js" }, @@ -57,17 +78,26 @@ "require": "./build/cjs/orchestrion/bundler/webpack-loader.js" }, "./orchestrion/load-hook": { - "types": "./build/types/orchestrion/bundler/load-hook.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/load-hook.d.mts", + "default": "./build/types/orchestrion/bundler/load-hook.d.ts" + }, "import": "./build/esm/orchestrion/bundler/load-hook.js", "require": "./build/cjs/orchestrion/bundler/load-hook.js" }, "./orchestrion/esbuild": { - "types": "./build/types/orchestrion/bundler/esbuild.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/esbuild.d.mts", + "default": "./build/types/orchestrion/bundler/esbuild.d.ts" + }, "import": "./build/esm/orchestrion/bundler/esbuild.js", "require": "./build/cjs/orchestrion/bundler/esbuild.js" }, "./orchestrion/bun": { - "types": "./build/types/orchestrion/bundler/bun.d.ts", + "types": { + "import": "./build/types/orchestrion/bundler/bun.d.mts", + "default": "./build/types/orchestrion/bundler/bun.d.ts" + }, "import": "./build/esm/orchestrion/bundler/bun.js", "require": "./build/cjs/orchestrion/bundler/bun.js" } @@ -118,7 +148,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/solid/.gitignore b/packages/solid/.gitignore index 3e89751310a5..4853812f20f7 100644 --- a/packages/solid/.gitignore +++ b/packages/solid/.gitignore @@ -1,2 +1,3 @@ /*.d.ts +/*.d.mts /*.d.ts.map diff --git a/packages/solid/package.json b/packages/solid/package.json index 1b1cb8bd1f22..6258ade10e09 100644 --- a/packages/solid/package.json +++ b/packages/solid/package.json @@ -12,6 +12,7 @@ "files": [ "/build", "/*.d.ts", + "/*.d.mts", "/*.d.ts.map" ], "main": "build/cjs/index.js", @@ -21,7 +22,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -31,7 +32,7 @@ }, "./solidrouter": { "import": { - "types": "./solidrouter.d.ts", + "types": "./solidrouter.d.mts", "default": "./build/esm/solidrouter.js" }, "require": { @@ -41,7 +42,7 @@ }, "./tanstackrouter": { "import": { - "types": "./tanstackrouter.d.ts", + "types": "./tanstackrouter.d.mts", "default": "./build/esm/tanstackrouter.js" }, "require": { @@ -87,14 +88,14 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core build:types:routers", + "build:types": "run-s build:types:core build:types:routers && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:types:routers": "tsc -p tsconfig.routers-types.json", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:tarball": "pnpm pack", - "clean": "node ../../scripts/rm.mjs build coverage sentry-solid-*.tgz ./*.d.ts ./*.d.ts.map", + "clean": "node ../../scripts/rm.mjs build coverage sentry-solid-*.tgz ./*.d.ts ./*.d.mts ./*.d.ts.map", "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", @@ -109,6 +110,7 @@ "outputs": [ "{projectRoot}/build/types", "{projectRoot}/*.d.ts", + "{projectRoot}/*.d.mts", "{projectRoot}/*.d.ts.map" ] } diff --git a/packages/solidstart/.gitignore b/packages/solidstart/.gitignore index 9d5e99bfb5a5..552962a52630 100644 --- a/packages/solidstart/.gitignore +++ b/packages/solidstart/.gitignore @@ -2,4 +2,5 @@ /client /server /*.d.ts +/*.d.mts /*.d.ts.map diff --git a/packages/solidstart/package.json b/packages/solidstart/package.json index d6a88ef69c46..9445f093a882 100644 --- a/packages/solidstart/package.json +++ b/packages/solidstart/package.json @@ -14,6 +14,7 @@ "/client", "/server", "/*.d.ts", + "/*.d.mts", "/*.d.ts.map" ], "main": "build/cjs/index.server.js", @@ -29,7 +30,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "sentry-solidstart-runtime": { "import": "./build/esm/server/index.js", "require": "./build/cjs/server/index.js" @@ -48,7 +52,10 @@ } }, "./solidrouter": { - "types": "./solidrouter.d.ts", + "types": { + "import": "./solidrouter.d.mts", + "default": "./solidrouter.d.ts" + }, "browser": { "types": "./solidrouter.d.ts", "import": "./build/esm/solidrouter.client.js", @@ -66,7 +73,10 @@ } }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" } @@ -113,14 +123,14 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core build:types:subexports", + "build:types": "run-s build:types:core build:types:subexports && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:types:subexports": "tsc -p tsconfig.subexports-types.json", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:tarball": "pnpm pack", - "clean": "node ../../scripts/rm.mjs build coverage sentry-solidstart-*.tgz ./*.d.ts ./*.d.ts.map ./client ./server", + "clean": "node ../../scripts/rm.mjs build coverage sentry-solidstart-*.tgz ./*.d.ts ./*.d.mts ./*.d.ts.map ./client ./server", "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", @@ -138,6 +148,7 @@ "{projectRoot}/client", "{projectRoot}/server", "{projectRoot}/*.d.ts", + "{projectRoot}/*.d.mts", "{projectRoot}/*.d.ts.map" ] } diff --git a/packages/svelte/package.json b/packages/svelte/package.json index e8cdcf514716..9edd4ef6b2cd 100644 --- a/packages/svelte/package.json +++ b/packages/svelte/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -51,7 +51,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/sveltekit/package.json b/packages/sveltekit/package.json index 0b91191f427b..d85d1914bf55 100644 --- a/packages/sveltekit/package.json +++ b/packages/sveltekit/package.json @@ -19,12 +19,18 @@ "exports": { "./package.json": "./package.json", "./browser-tracing-variant": { - "types": "./build/types/client/svelte4BrowserTracing.d.ts", + "types": { + "import": "./build/types/client/svelte4BrowserTracing.d.mts", + "default": "./build/types/client/svelte4BrowserTracing.d.ts" + }, "import": "./build/esm/client/svelte4BrowserTracing.js", "require": "./build/cjs/client/svelte4BrowserTracing.js" }, ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "workerd": { "import": "./build/esm/index.workerd.js", "require": "./build/cjs/index.workerd.js" @@ -47,12 +53,18 @@ } }, "./opentelemetry-api": { - "types": "./build/types/opentelemetryApi.d.ts", + "types": { + "import": "./build/types/opentelemetryApi.d.mts", + "default": "./build/types/opentelemetryApi.d.ts" + }, "import": "./build/esm/opentelemetryApi.js", "require": "./build/cjs/opentelemetryApi.js" }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" } @@ -97,7 +109,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/tanstackstart-react/package.json b/packages/tanstackstart-react/package.json index 5fd1b50fbbb2..5ca92df90271 100644 --- a/packages/tanstackstart-react/package.json +++ b/packages/tanstackstart-react/package.json @@ -18,7 +18,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.types.d.ts", + "types": { + "import": "./build/types/index.types.d.mts", + "default": "./build/types/index.types.d.ts" + }, "workerd": { "import": "./build/esm/index.server.js", "require": "./build/cjs/index.server.js" @@ -42,7 +45,10 @@ } }, "./vite": { - "types": "./build/types/vite/index.d.ts", + "types": { + "import": "./build/types/vite/index.d.mts", + "default": "./build/types/vite/index.d.ts" + }, "import": "./build/esm/vite/index.js", "require": "./build/cjs/vite/index.js" } @@ -70,7 +76,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "nodemon --ext ts --watch src scripts/buildRollup.ts", diff --git a/packages/vercel-edge/package.json b/packages/vercel-edge/package.json index 7b1eb06ae1db..911da01b8780 100644 --- a/packages/vercel-edge/package.json +++ b/packages/vercel-edge/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -45,7 +45,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/vite-plugin/package.json b/packages/vite-plugin/package.json index 0a4a7f8ad4f8..ea304ca433eb 100644 --- a/packages/vite-plugin/package.json +++ b/packages/vite-plugin/package.json @@ -27,7 +27,10 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" } @@ -36,7 +39,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", diff --git a/packages/vue/.gitignore b/packages/vue/.gitignore index 3e89751310a5..4853812f20f7 100644 --- a/packages/vue/.gitignore +++ b/packages/vue/.gitignore @@ -1,2 +1,3 @@ /*.d.ts +/*.d.mts /*.d.ts.map diff --git a/packages/vue/package.json b/packages/vue/package.json index 76b557061200..adc7d0f9b67b 100644 --- a/packages/vue/package.json +++ b/packages/vue/package.json @@ -12,6 +12,7 @@ "files": [ "/build", "/*.d.ts", + "/*.d.mts", "/*.d.ts.map" ], "main": "build/cjs/index.js", @@ -21,7 +22,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/types/index.d.ts", + "types": "./build/types/index.d.mts", "default": "./build/esm/index.js" }, "require": { @@ -31,7 +32,7 @@ }, "./tanstackrouter": { "import": { - "types": "./tanstackrouter.d.ts", + "types": "./tanstackrouter.d.mts", "default": "./build/esm/tanstackrouter.js" }, "require": { @@ -70,14 +71,14 @@ "build": "run-p build:transpile build:types", "build:dev": "run-p build:transpile build:types", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "run-s build:types:core build:types:router", + "build:types": "run-s build:types:core build:types:router && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:types:core": "tsc -p tsconfig.types.json", "build:types:router": "tsc -p tsconfig.router-types.json", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "run-p build:transpile:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch", "build:tarball": "pnpm pack", - "clean": "node ../../scripts/rm.mjs build coverage sentry-vue-*.tgz", + "clean": "node ../../scripts/rm.mjs build coverage sentry-vue-*.tgz ./*.d.ts ./*.d.mts ./*.d.ts.map", "lint:fix": "oxlint . --fix --type-aware", "lint": "oxlint . --type-aware", "lint:types": "oxlint src --type-aware --type-check", @@ -93,6 +94,7 @@ "outputs": [ "{projectRoot}/build/types", "{projectRoot}/*.d.ts", + "{projectRoot}/*.d.mts", "{projectRoot}/*.d.ts.map" ] } diff --git a/packages/wasm/package.json b/packages/wasm/package.json index cd18e858109d..28b83e7f4044 100644 --- a/packages/wasm/package.json +++ b/packages/wasm/package.json @@ -19,7 +19,7 @@ "./package.json": "./package.json", ".": { "import": { - "types": "./build/npm/types/index.d.ts", + "types": "./build/npm/types/index.d.mts", "default": "./build/npm/esm/index.js" }, "require": { @@ -43,7 +43,7 @@ "build:bundle": "rolldown --config rollup.bundle.config.mjs", "build:dev": "run-p build:transpile build:types", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch build:bundle:watch", "build:bundle:watch": "rolldown --config rollup.bundle.config.mjs --watch", "build:dev:watch": "run-p build:transpile:watch", diff --git a/packages/webpack-plugin/package.json b/packages/webpack-plugin/package.json index 207a41039015..c8fea2d5cd74 100644 --- a/packages/webpack-plugin/package.json +++ b/packages/webpack-plugin/package.json @@ -27,12 +27,18 @@ "exports": { "./package.json": "./package.json", ".": { - "types": "./build/types/index.d.ts", + "types": { + "import": "./build/types/index.d.mts", + "default": "./build/types/index.d.ts" + }, "import": "./build/esm/index.js", "require": "./build/cjs/index.js" }, "./webpack5": { - "types": "./build/types/webpack5.d.ts", + "types": { + "import": "./build/types/webpack5.d.mts", + "default": "./build/types/webpack5.d.ts" + }, "import": "./build/esm/webpack5.js", "require": "./build/cjs/webpack5.js" } @@ -41,7 +47,7 @@ "build": "run-p build:transpile build:types", "build:dev": "pnpm run build", "build:transpile": "rolldown -c rollup.npm.config.mjs", - "build:types": "tsc -p tsconfig.types.json", + "build:types": "tsc -p tsconfig.types.json && node ../../dev-packages/rollup-utils/write-esm-types.mjs", "build:watch": "run-p build:transpile:watch", "build:dev:watch": "pnpm run build:watch", "build:transpile:watch": "rolldown -c rollup.npm.config.mjs --watch",