babel-plugin-transform-export-default-name icon indicating copy to clipboard operation
babel-plugin-transform-export-default-name copied to clipboard

Syntax error when filename contains invalid character

Open jstcki opened this issue 8 years ago • 1 comments

I stumbled upon this when using it with next.js.

Next.js sometimes tries to compile pages with the suffix ?entry which results in this error:

 error  in ./pages/foo?entry

Syntax Error: Unexpected token, expected ; (6:11)
  4 | import Link from "next/dist/lib/link.js";
  5 |
> 6 | var indexJs?entry = function indexJsEntry() {
    |            ^
  7 |   return React.createElement(
  8 |     "div",
  9 |     {

(/pages/foo is a directory with an index.js file)

As you see, the function name is correct but the var name still contains the ?.

I think the ideal behavior would be to strip the ?entry completely, so the function name would correctly resolve to the parent directory name.

jstcki avatar Apr 20 '17 09:04 jstcki

Looks like a bug/ deficiency. Would accept a PR.

gajus avatar Apr 20 '17 10:04 gajus