feat(evasive-transform): expose createEvasiveTransformPass for use with @endo/parser-pipeline#3161
Conversation
|
Warning This PR is part of a stack and targets branch 📚 Pull Request Stack
Managed by gh-stack |
|
ec8e135 to
0dbb69a
Compare
512228b to
4f3e8de
Compare
4f3e8de to
558a283
Compare
0fb7919 to
93e7e2c
Compare
There was a problem hiding this comment.
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 bothtransformAst()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.
| { | ||
| sourceFileName: sourceUrl, | ||
| sourceMaps: Boolean(sourceUrl), | ||
| // @ts-expect-error - what is this, even | ||
| inputSourceMap, | ||
| retainLines: true, |
There was a problem hiding this comment.
// @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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
n/m; I found the option in the source. It's just undocumented in the types, apparently.
| }, | ||
| "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" | ||
| } |
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
This is intentional; @types/babel__generator is only used in internal types. I've updated tsconfig.json to strip internal types.
558a283 to
1cb974a
Compare
93e7e2c to
656bc39
Compare
673334b to
2f30d6c
Compare
656bc39 to
7594c39
Compare
2f30d6c to
101fc19
Compare
7594c39 to
84dd4ee
Compare
101fc19 to
3eecf83
Compare
3eecf83 to
8dbb8e4
Compare
b1c50eb to
59ff80d
Compare
8dbb8e4 to
f5ab26d
Compare
…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`.
59ff80d to
9d57d5e
Compare
f5ab26d to
dff723b
Compare
This exposes a new function,
createEvasiveTransformPass(), which can be used with@endo/parser-pipelineto unify AST parsing.Refactored out some common code to maximize logic reuse. Both the new function and the existing
transformAst()use the newmakeTransformCommentsVisitor()to build the visitors for@babel/traverse.