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

Does not handle literal module specifier #713

Open
lachrist opened this issue Sep 13, 2024 · 1 comment · May be fixed by #714
Open

Does not handle literal module specifier #713

lachrist opened this issue Sep 13, 2024 · 1 comment · May be fixed by #714
Labels

Comments

@lachrist
Copy link

Motivation

Hi, thanks for the work!

It seems astring does not handle module specifier when they are literals and not identifiers.

import { parse } from "acorn";
import { generate } from "astring";

const root = parse("export { 'foo-bar' as 'qux-baz' } from 'source';", {
  sourceType: "module",
  ecmaVersion: 2024,
});

console.dir(root, { depth: 1 / 0 });

console.log(generate(root));
Node {
  type: 'Program',
  start: 0,
  end: 48,
  body: [
    Node {
      type: 'ExportNamedDeclaration',
      start: 0,
      end: 48,
      declaration: null,
      specifiers: [
        Node {
          type: 'ExportSpecifier',
          start: 9,
          end: 31,
          local: Node {
            type: 'Literal',
            start: 9,
            end: 18,
            value: 'foo-bar',
            raw: "'foo-bar'"
          },
          exported: Node {
            type: 'Literal',
            start: 22,
            end: 31,
            value: 'qux-baz',
            raw: "'qux-baz'"
          }
        }
      ],
      source: Node {
        type: 'Literal',
        start: 39,
        end: 47,
        value: 'source',
        raw: "'source'"
      }
    }
  ],
  sourceType: 'module'
}
export {undefined} from 'source';

Expected behavior

export { 'foo-bar' as 'qux-baz' } from 'source';

Actual behavior

export {undefined} from 'source';
@lachrist
Copy link
Author

tested on v1.9.0

zermelo-wisen added a commit to getappmap/appmap-node that referenced this issue Sep 16, 2024
Since davidbonnet/astring#713 is merged
we are bumping the astring dependency to upstream again.
dividedmind pushed a commit to getappmap/appmap-node that referenced this issue Sep 16, 2024
Since davidbonnet/astring#713 is merged
we are bumping the astring dependency to upstream again.
@fabiosantoscode fabiosantoscode linked a pull request Sep 17, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants