Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export * as namespace does not support string literals #4784

Closed
dnalborczyk opened this issue Jan 2, 2023 · 8 comments · Fixed by #5298
Closed

export * as namespace does not support string literals #4784

dnalborczyk opened this issue Jan 2, 2023 · 8 comments · Fixed by #5298

Comments

@lukastaegert
Copy link
Member

Ah, I overlooked you can do this with namespaces as well. The fix is probably very similar to what I did in #4770, if you want, you can have a shot at fixing this.

@lukastaegert
Copy link
Member

Actually forget what I said, I have overlooked it but if it is a Syntax error, then the acorn parser has also overlooked it and it needs to be fixed in acorn. Until then, there is little we can do about it in Rollup.

@dnalborczyk
Copy link
Contributor Author

dnalborczyk commented Jan 3, 2023

just tried acorn and it seems to be working:

export * as "foo" from "foo"

acorn

{
  "type": "Program",
  "start": 0,
  "end": 28,
  "body": [
    {
      "type": "ExportAllDeclaration",
      "start": 0,
      "end": 28,
      "exported": {
        "type": "Literal",
        "start": 12,
        "end": 17,
        "value": "foo",
        "raw": "\"foo\""
      },
      "source": {
        "type": "Literal",
        "start": 23,
        "end": 28,
        "value": "foo",
        "raw": "\"foo\""
      }
    }
  ],
  "sourceType": "module"
}

rollup

roll.js → bundle.js...
[!] RollupError: Unexpected token
roll.js (1:12)
1: export * as "foo" from "foo"
               ^
    at error (/node_module/rollup/dist/shared/rollup.js:210:30)
    at Module.error (/node_modules/rollup/dist/shared/rollup.js:13478:16)
    at Module.tryParse (/node_modules/rollup/dist/shared/rollup.js:13872:25)
    at Module.setSource (/node_modules/rollup/dist/shared/rollup.js:13763:39)
    at ModuleLoader.addModuleSource (/node_modules/rollup/dist/shared/rollup.js:23404:20)

@lukastaegert
Copy link
Member

Maybe we are not using the latest acorn version? I mean, tryParse from the stack trace is doing nothing but calling acorn.

@dnalborczyk
Copy link
Contributor Author

good point. debugged it a bit, and I'm fairly sure the parser error is being thrown by the import assertions plugin 😞

@lukastaegert
Copy link
Member

Fix at #5298.

Copy link

This issue has been resolved via #5298 as part of rollup@4.9.0. You can test it via npm install rollup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants