Skip to content

feat(evasive-transform): expose createEvasiveTransformPass for use with @endo/parser-pipeline#3161

Draft
boneskull wants to merge 1 commit intoboneskull/module-source-pipelinefrom
boneskull/evasive-pipeline
Draft

feat(evasive-transform): expose createEvasiveTransformPass for use with @endo/parser-pipeline#3161
boneskull wants to merge 1 commit intoboneskull/module-source-pipelinefrom
boneskull/evasive-pipeline

Conversation

@boneskull
Copy link
Copy Markdown
Member

This exposes a new function, createEvasiveTransformPass(), which can be used with @endo/parser-pipeline to unify AST parsing.

Refactored out some common code to maximize logic reuse. Both the new function and the existing transformAst() use the new makeTransformCommentsVisitor() to build the visitors for @babel/traverse.

@boneskull
Copy link
Copy Markdown
Member Author

boneskull commented Apr 4, 2026

Warning

This PR is part of a stack and targets branch boneskull/module-source-pipeline, not master.
DO NOT MERGE until feat(module-source): expose createModuleSourcePasses() #3159 is merged into master.

📚 Pull Request Stack


Managed by gh-stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Apr 4, 2026

⚠️ No Changeset found

Latest commit: dff723b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@boneskull boneskull self-assigned this Apr 4, 2026
@boneskull boneskull force-pushed the boneskull/compartment-mapper-pipeline branch from ec8e135 to 0dbb69a Compare April 4, 2026 04:25
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 512228b to 4f3e8de Compare April 4, 2026 04:25
@boneskull boneskull changed the base branch from boneskull/compartment-mapper-pipeline to boneskull/module-source-pipeline April 4, 2026 23:26
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 4f3e8de to 558a283 Compare April 4, 2026 23:26
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from 0fb7919 to 93e7e2c Compare April 4, 2026 23:26
@boneskull boneskull requested a review from Copilot April 5, 2026 01:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes a new createEvasiveTransformPass() API from @endo/evasive-transform so it can be used as a TransformPass within @endo/parser-pipeline, while refactoring shared traversal logic into makeTransformCommentsVisitor().

Changes:

  • Added createEvasiveTransformPass() (+ types) and exported it from the package entry point.
  • Refactored AST traversal visitor construction into makeTransformCommentsVisitor() for reuse by both transformAst() and the new pass.
  • Added AVA coverage for the new transform pass behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/evasive-transform/test/transform-pass.test.js Adds tests validating the new parser-pipeline-compatible transform pass.
packages/evasive-transform/src/transform-pass.js Introduces createEvasiveTransformPass() that returns a Babel-traverse visitor wrapper.
packages/evasive-transform/src/transform-pass-types.ts Defines TransformPass and options types for the new API.
packages/evasive-transform/src/transform-code.js JSDoc type-import cleanup for Babel AST/visitor types.
packages/evasive-transform/src/transform-ast.js Extracts shared visitor logic into makeTransformCommentsVisitor() and reuses it in transformAst().
packages/evasive-transform/src/index.js Exports createEvasiveTransformPass() from the public entry point.
packages/evasive-transform/src/generate.js Adds a @ts-expect-error suppression around inputSourceMap.
packages/evasive-transform/package.json Adds Babel-related @types/* packages for typing support.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 89 to 94
{
sourceFileName: sourceUrl,
sourceMaps: Boolean(sourceUrl),
// @ts-expect-error - what is this, even
inputSourceMap,
retainLines: true,
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// @ts-expect-error here is brittle: once @babel/generator option types include inputSourceMap (or once inputSourceMap is correctly typed), tsc will fail due to an unused expect-error. Prefer fixing the underlying type mismatch by normalizing/casting inputSourceMap to the type expected by Babel generator (and updating the sourceMap option typedef accordingly), and remove the @ts-expect-error suppression.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is valid. I didn't find any such option. It may have been leftover from the Agoric fork of @babel/generator. @kriskowal does that ring a bell?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

n/m; I found the option in the source. It's just undocumented in the types, apparently.

Comment on lines 74 to 80
},
"dependencies": {
"@babel/generator": "^7.28.3",
"@babel/parser": "~7.28.3",
"@babel/traverse": "~7.28.3"
"@babel/traverse": "~7.28.3",
"@types/babel__traverse": "~7.28.0"
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@types/babel__traverse is a types-only package and is typically kept in devDependencies across this repo (e.g. packages/module-source/package.json). If the intent is to ship it for downstream type resolution, consider also whether @types/babel__generator should be treated the same way for consistency (since this package’s public JSDoc types reference @babel/generator). Otherwise, move @types/babel__traverse back to devDependencies to avoid expanding the runtime dependency set unnecessarily.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional; @types/babel__generator is only used in internal types. I've updated tsconfig.json to strip internal types.

@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 558a283 to 1cb974a Compare April 6, 2026 23:35
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from 93e7e2c to 656bc39 Compare April 7, 2026 22:49
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch 2 times, most recently from 673334b to 2f30d6c Compare April 7, 2026 22:53
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from 656bc39 to 7594c39 Compare April 7, 2026 22:57
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 2f30d6c to 101fc19 Compare April 7, 2026 22:57
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from 7594c39 to 84dd4ee Compare April 7, 2026 23:05
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 101fc19 to 3eecf83 Compare April 7, 2026 23:05
@boneskull boneskull added the enhancement New feature or request label Apr 7, 2026
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 3eecf83 to 8dbb8e4 Compare April 7, 2026 23:13
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from b1c50eb to 59ff80d Compare April 7, 2026 23:27
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from 8dbb8e4 to f5ab26d Compare April 7, 2026 23:27
…th @endo/parser-pipeline

This exposes a new function, `createEvasiveTransformPass()`, which can be used with
`@endo/parser-pipeline` to unify AST parsing.

Refactored out some common code to maximize logic reuse.  Both the new function and the existing
`transformAst()` use the new `makeTransformCommentsVisitor()` to build the visitors for
`@babel/traverse`.
@boneskull boneskull force-pushed the boneskull/module-source-pipeline branch from 59ff80d to 9d57d5e Compare April 7, 2026 23:33
@boneskull boneskull force-pushed the boneskull/evasive-pipeline branch from f5ab26d to dff723b Compare April 7, 2026 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants