Skip to content

Yoann/integration test#386

Closed
yoannmoinet wants to merge 22 commits into
masterfrom
yoann/integration-test
Closed

Yoann/integration test#386
yoannmoinet wants to merge 22 commits into
masterfrom
yoann/integration-test

Conversation

@yoannmoinet
Copy link
Copy Markdown
Member

What and why?

How?

yoannmoinet and others added 22 commits May 12, 2026 17:29
…equestData

Node.js pipe() immediately puts the source stream into flowing mode via
process.nextTick(), which starts reading file-backed blobs (from fs.openAsBlob)
in the background. When nock intercepts fetch and replies without consuming
the request body, the async chain completes and test cleanup deletes the output
directory before the scheduled blob read fires. This causes an unhandled
NotReadableError that dd-trace misattributes to the test.each registration
context, making it appear as a flaky test failure.

Replacing with Web Streams pipeThrough(new CompressionStream('gzip')) keeps
the pipeline lazy: reading only starts when the output stream is consumed,
so no I/O races with file cleanup.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses the native Web Streams DecompressionStream to decompress the
gzip output directly, eliminating the zlib import and the intermediate
readFully helper.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uses a two-pass approach to avoid DOM lib vs @types/node conflicts:
- Pass 1: TypeScript API emits .d.ts for all workspace files without DOM lib
- Pass 2: dts-bundle-generator bundles against emitted .d.ts files with DOM lib,
  skipping its own compilation pass (allFilesAreDeclarations shortcut)

Includes a Yarn patch for dts-bundle-generator to add a missing null check
in TypesUsageEvaluator when getImportExportReferencedSymbol returns undefined
(triggered by postcss.d.mts exporting from ./postcss.js in bundler mode).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Emit temp .d.ts files and tsconfigs to os.tmpdir() to avoid cluttering CWD
- Symlink project node_modules into the temp dir so TypeScript can resolve external packages from emitted files
- Use absolute paths for tsconfig extends since the temp configs live outside the project
- Configure inlinedLibraries (@datadog/browser-rum-core, @datadog/browser-core) vs importedLibraries (peer/runtime deps) for dts-bundle-generator
- Update LICENSES-3rdparty.csv to swap rollup-plugin-dts for dts-bundle-generator
- Emit temp files inside the project (`.dts-tmp-<pkg>/`) so TypeScript
  finds node_modules by walking up — drops the symlink hack.
- Hoist `dts-bundle-generator` and `typescript` to top-level imports.
- Drop the `generated` flag; Rollup calls `closeBundle` once per bundle.
- Wrap the whole mkdir → emit → bundle flow in `try/finally` so an
  error mid-build doesn't leak temp dirs.
- Co-locate both tsconfigs inside the temp dir, single cleanup target.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- Skip pass 1's tsconfig file write — feed the parsed root config to
  `ts.parseJsonConfigFileContent` directly and merge overrides in the
  `createProgram` call.
- Drop redundant `emitOnlyDtsFiles=true` (already implied by
  `emitDeclarationOnly`) and the explicit `createCompilerHost`
  (`createProgram` builds its own).
- Hoist `entrySrcPath` / `entryDtsPath` and drop `|| {}` defensives on
  `peerDependencies`/`dependencies` since the typedef declares them.
- Tighten the doc block and inline notes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dts-bundle-generator's default `exportReferencedTypes: true` was
preserving the `export` modifier on every type it inlined from
`@datadog/browser-rum-core` / `@datadog/browser-core`, leaking ~280
internal types (Site, BufferedObservable, Encoder, TraceContextInjection,
…) as part of our public API.

Setting it to `false` keeps the documented surface (`VitePluginOptions`,
`datadogVitePlugin`, `*Types`, `helpers`) exported and demotes everything
else to `declare`, so structural lookups like `RumTypes['RumInitConfiguration']`
still work but `import { Site } from '@datadog/vite-plugin'` no longer
compiles.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move the @dd/* `paths` map from a runtime `buildDdPaths()` fs walk in
the rollup config to a declarative block in the root tsconfig.json.
Both dts passes already extend the root config, so pass 1 inherits
the paths and pass 2 reads them off the parsed root config to compute
the .d.ts variant.

- Drops ~42 lines of node_modules-walking logic.
- Makes the workspace structure visible at a glance.
- Aligns paths with what tsc / typecheck already see.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Derives the expected @dd/* `paths` map from each workspace's
package.json `exports` and reconciles it with the root tsconfig.json.
The check is idempotent — if the existing paths match, the file is
not rewritten — and auto-fixes when a workspace is added/renamed/removed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Compare the existing paths block as-is — any out-of-order entry
triggers a rewrite so the on-disk file is always alphabetically
sorted.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- `toBuild` is now nested under each plugin's `buildPlugin` block,
  alongside the existing `hideFromRootReadme`.
- New `buildPlugin.inlinedLibraries` field lets plugins declare
  which npm packages should be inlined into the bundled .d.ts.
- `getDtsBundlePlugin` collects the union of `inlinedLibraries`
  from every plugin manifest at build time, replacing the
  hardcoded list in the rollup config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move `getDtsBundlePlugin` and its `collectInlinedLibraries` /
`buildDtsPaths` helpers from `rollupConfig.mjs` into a sibling
`dtsBundlePlugin.mjs`. `rollupConfig.mjs` now just imports the
plugin factory; the dts-specific deps (`dts-bundle-generator`,
`typescript`) only load on the consumer side.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant