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

Incorrect exported for export * as "string" ... #200

Open
fisker opened this issue Feb 7, 2022 · 10 comments
Open

Incorrect exported for export * as "string" ... #200

fisker opened this issue Feb 7, 2022 · 10 comments
Assignees

Comments

@fisker
Copy link
Collaborator

fisker commented Feb 7, 2022

require('meriyah').parseModule('export * as "string" from "module"').body[0].exported
{ type: 'Identifier', name: 'string' }

Should be Literal instead.

@3cp
Copy link
Member

3cp commented Feb 7, 2022

Interesting syntax. BTW, how to use the exported "string" later in the code?

@fisker
Copy link
Collaborator Author

fisker commented Feb 7, 2022

Import {"string" as foo} from "foo" not sure if it works for javascript, this is designed for wasm, I think.

@fisker
Copy link
Collaborator Author

fisker commented Feb 7, 2022

Seems meriyah don't support this syntax above either. Babel added support for it last year. https://babeljs.io/blog/2020/10/15/7.12.0#imports-and-exports-with-string-names-12091httpsgithubcombabelbabelpull12091

@fisker
Copy link
Collaborator Author

fisker commented Feb 7, 2022

This syntax enabled by default in babel later babel/babel#13195

This syntax is effectively stage 4. It didn't go through the proposals process

@sosukesuzuki
Copy link

This syntax is added to ECMAScript by tc39/ecma262#2154

@sosukesuzuki
Copy link

sosukesuzuki commented Feb 7, 2022

Usecase: WebAssembly/esm-integration#39
ESTree update: estree/estree#269

@fisker
Copy link
Collaborator Author

fisker commented Feb 7, 2022

@sosukesuzuki Only imported and exported? Does it allow local use string? I saw your PR in estree. Thanks.

@3cp 3cp self-assigned this Mar 18, 2022
@3cp
Copy link
Member

3cp commented Mar 19, 2022

ExportSpecifier:
  ModuleExportName
  ModuleExportName as ModuleExportName

The spec means following?

export "string";
export "string" as "string2";

@3cp
Copy link
Member

3cp commented Mar 19, 2022

ModuleExportName is either Identifier or string Literal

@sosukesuzuki
Copy link

ExportSpecifier.local can be a string literal when only from clause exist.

// invalid
export { "string" as "string2" };

// valid
export { "string" as "string2" } from "mod";

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

No branches or pull requests

3 participants