Description
What's the issue?
In trying to add this package in https://github.com/MaxMilton/sapper-template-rollup/tree/feat/use-closure-compiler I ran into the issue of import()
not able to be be parsed processed by acorn, which is used through this package.
How do we reproduce the issue?
- Clone repo branch https://github.com/MaxMilton/sapper-template-rollup/tree/feat/use-closure-compiler.
- Install deps;
yarn install
. - Run build;
yarn run build
.
Result:
yarn run v1.9.4
warning package.json: No license field
$ sapper build
> Building...
> Error transforming chunk with 'closure-compiler' plugin: baseVisitor[type] is not a function
error Command failed with exit code 1.
After some debugging you'll find acorn is trying to do baseVisitor['Import']
, which is not available in acorn at the moment.
Additional context
By adding the acorn-dynamic-import
package it's possible to support parsing import()
. In fact this is exactly what closure-webpack-plugin is doing, as well as others like buble.
One other critical part of this is support in Closure Compiler itself for parser support for dynamic import: google/closure-compiler#2770. Although, it is possible for a rollup plugin to rewrite the import()
into something else before it ever hits Closure so this issue is not necessarily dependant upon Closure parser support.