ampproject / ampproject/rollup-plugin-closure-compiler
SyntaxError: Unexpected keyword 'default'
- Dominant language
- TypeScript
- Stars
- 293
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
## What's the issue?
The build process crashed with a message:
```
node_modules/.pnpm/acorn@7.3.1/node_modules/acorn/dist/acorn.js:2927
var err = new SyntaxError(message);
^
SyntaxError: Unexpected keyword 'default' (18:16)
```
## How do we reproduce the issue?
```js
// rollup.config.js
import rollupResolve from '@rollup/plugin-node-resolve';
import rollupCommonjs from '@rollup/plugin-commonjs';
import rollupReplace from '@rollup/plugin-replace';
import rollupPostcss from 'rollup-plugin-postcss';
import rollupJson from '@rollup/plugin-json';
import rollupClosureCompiler from '@ampproject/rollup-plugin-closure-compiler';
export default {
input: 'src/index.js',
external: Array.from(external),
plugins: [
rollupResolve({
browser: true,
}),
rollupCommonjs(),
rollupPostcss({
extract: new URL(`./dist/${libName}.css`, import.meta.url).pathname,
minimize: true,
}),
rollupReplace({
values: {
'process.env.NODE_ENV': JSON.stringify(
isProduction ? 'production' : 'development'
),
},
preventAssignment: true,
}),
rollupJson(),
rollupClosureCompiler(),
],
output: {
format: 'es',
file: 'dist/lib.js',
},
};
```
And in `src/index.js`, there is something like this: `export default foobar;`
If I remove the rollup-plugin-closure-compiler plugin, I could run rollup build successfully.
Contributor guide
Research direction
Start by running the supplied rollup.config.js reproduction with src/index.js exporting a default value and @ampproject/rollup-plugin-closure-compiler enabled. Compare the build with that plugin removed and confirm that the error occurs only with it present; done means the same build succeeds while retaining the plugin and default export.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, rollup, typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100