guybedford / es-module-lexer

Low-overhead lexer dedicated to ES module parsing for fast analysis
MIT License
917 stars 48 forks source link

losing comment when parse dynamic import in >0.9.3 #117

Closed l1shu closed 2 years ago

l1shu commented 2 years ago
const { init, parse } = require('es-module-lexer');

const code = `
const routes = {
  a: () => import(/* webpackChunkName: "a" */ '@src/a/view.tsx'),
}
`;

(async () => {
  // either await init, or call parse asynchronously
  // this is necessary for the Web Assembly boot
  await init;

  const [imports, exports] = parse(code);

  console.log(imports);
})();

in 0.9.3:

image

>0.9.3:

image

when the version >0.9.3, it will losing the comment

guybedford commented 2 years ago

@l1shu this is correct and was a change made and reflected in the documentation. Instead ss and se can be used to extract the comment information.

l1shu commented 2 years ago

@l1shu this is correct and was a change made and reflected in the documentation. Instead ss and se can be used to extract the comment information.

thanks for replying