ampproject / ampproject/rollup-plugin-closure-compiler

TypeError: baseVisitor[type] is not a function when encountering ChainExpression

Open
#464 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
293
Forks
28
PR merge metrics
No merged PRs in 30d

Description

## What's the issue?

TypeError: baseVisitor[type] is not a function when encountering ChainExpression

## How do we reproduce the issue?
1. Create a js file that contains [Optional chaining ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining)
2. and run rollup-plugin-closure-compiler

We'll likely need to know:
1. Your Rollup configuration.
```
import pkg from '../package.json';
import typescript from '@rollup/plugin-typescript';
import compiler from '@ampproject/rollup-plugin-closure-compiler';
const externalPackages = [
...Object.keys(pkg.dependencies),
...Object.keys(pkg.peerDependencies),
];
function external(id) {
return externalPackages.some(externalPackage => id.startsWith(externalPackage));
}
export default [{
input: 'src/index.ts',
output: [{
format: 'esm',
dir: 'lib',
preserveModules: true,
preserveModulesRoot: 'src',
},
],
external,
plugins: [
typescript(),
compiler()
],
}];
```
4. Error logs from your console when invoking Rollup with this plugin present.
```
[!] (plugin closure-compiler) TypeError: baseVisitor[type] is not a function
TypeError: baseVisitor[type] is not a function
at c (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:29:24)
at Object.skipThrough (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:186:39)
at c (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:29:24)
at Object.base.BinaryExpression.base.LogicalExpression (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:377:5)
at c (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:29:24)
at Object.skipThrough (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:186:39)
at c (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:29:24)
at Object.base.IfStatement (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:206:5)
at c (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:29:24)
at Object.skipThrough (/projects/sheet-formula-sdk/node_modules/@ampproject/rollup-plugin-closure-compiler/node_modules/acorn-walk/dist/walk.js:186:39)

```
5. Error logs when this plugin is removed from your Rollup configuration.

If this is a feature request you can use this section to point to a prototype/mockup that will help us understand the request.

## Additional context
The newest `acorn-walk` fix this problem. Maybe considering using range instead of specific version in package json?

Contributor guide

Open the contributing guide

Research direction

Start with package.json and the acorn-walk dependency implicated by the stack trace, then reproduce the failure using optional chaining and the supplied Rollup configuration. Done means the plugin processes that input without the baseVisitor TypeError and the dependency change is verified against the reported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.