Skip to content

feat(module-source): fix types, expose analyzer.js subpath#3218

Draft
boneskull wants to merge 1 commit intoboneskull/evasive-pipeline2from
boneskull/module-source-pipeline2
Draft

feat(module-source): fix types, expose analyzer.js subpath#3218
boneskull wants to merge 1 commit intoboneskull/evasive-pipeline2from
boneskull/module-source-pipeline2

Conversation

@boneskull
Copy link
Copy Markdown
Member

Introduces a low-level analysis primitive analyzeModule which is exported from the analyzer.js subpath.

  • Adds src/types/external.ts as a single re-export index for the public types (SourceMapHook, SourceMapHookDetails, SourceMapObject, ModuleSourceOptions) and the new analyzer types. src/external.types.d.ts now delegates to it.

  • Adds src/types/analyzer.ts with AnalysisContext<T>, ModuleAnalysisContext, AnalysisOptions, and VisitorPlugin — typed by tsc rather than inferred from JSDoc.

  • Adds src/shim.types.d.ts for the global ModuleSource augmentation used by the SES shim.

  • tsconfig.json is tightened: stripInternal removes @internal declarations from emitted .d.ts files.

  • Update typedoc.json to also consider the additional entry points

  • We no longer need to provide custom @babel/types exports to these functions. So, makeModulePlugins and makeCjsModulePlugins no longer return PluginFactory functions (({ types }) => ({ visitor })). Both now return plain { analyzePlugin: { visitor }, transformPlugin: { visitor } } objects with @babel/types imported at module scope. transform-source.js is updated accordingly.

  • Benchmark and test fixture updated for the new API shape.

  • Adds ./analyzer.js as a new package export. The analyzeModule(options?) function creates a fresh per-parse context with analyzePass / transformPass (plain Visitor objects) and buildRecord(code, location). The same function powers the ModuleSource constructor internally. This will be consumed by the forthcoming @endo/parser-pipeline.

@boneskull
Copy link
Copy Markdown
Member Author

boneskull commented Apr 30, 2026

Warning

This PR is part of a stack and targets branch boneskull/evasive-pipeline2, not master.
DO NOT MERGE until feat(evasive-transform): expose makeTransformCommentsVisitor #3217 is merged into master.

📚 Pull Request Stack


Managed by gh-stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 30, 2026

🦋 Changeset detected

Latest commit: c604f08

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@endo/module-source Minor
@endo/compartment-mapper Patch
@endo/bundle-source Patch
@endo/check-bundle Patch
@endo/daemon Patch
@endo/import-bundle Patch
@endo/test262-runner Patch
@endo/cli Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Introduces a low-level analysis primitive `analyzeModule` which is exported from the `analyzer.js` subpath.

- Adds `src/types/external.ts` as a single re-export index for the public types (`SourceMapHook`, `SourceMapHookDetails`, `SourceMapObject`, `ModuleSourceOptions`) and the new analyzer types. `src/external.types.d.ts` now delegates to it.
- Adds `src/types/analyzer.ts` with `AnalysisContext<T>`, `ModuleAnalysisContext`, `AnalysisOptions`, and `VisitorPlugin` — typed by `tsc` rather than inferred from JSDoc.
- Adds `src/shim.types.d.ts` for the global `ModuleSource` augmentation used by the SES shim.
- `tsconfig.json` is tightened: `stripInternal` removes `@internal` declarations from emitted `.d.ts` files.
- Update `typedoc.json` to also consider the additional entry points

- We no longer need to provide custom `@babel/types` exports to these functions. So, `makeModulePlugins` and `makeCjsModulePlugins` no longer return `PluginFactory` functions (`({ types }) => ({ visitor })`). Both now return plain `{ analyzePlugin: { visitor }, transformPlugin: { visitor } }` objects with `@babel/types` imported at module scope. `transform-source.js` is updated accordingly.
- Benchmark and test fixture updated for the new API shape.

- Adds `./analyzer.js` as a new package export. The `analyzeModule(options?)` function creates a fresh per-parse context with `analyzePass` / `transformPass` (plain `Visitor` objects) and `buildRecord(code, location)`. The same function powers the `ModuleSource` constructor internally. This will be consumed by the forthcoming `@endo/parser-pipeline`.
@boneskull boneskull force-pushed the boneskull/evasive-pipeline2 branch from 3f047de to 2b97a5e Compare May 5, 2026 20:07
@boneskull boneskull force-pushed the boneskull/module-source-pipeline2 branch from 29ff6f4 to c604f08 Compare May 5, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lavamoat

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant