guybedford / es-module-lexer

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

feat: string-literal imports/exports for esmodule #89

Closed richardo2016 closed 2 years ago

richardo2016 commented 2 years ago

This PR is trying to support string-literal imports/exports for esmodule.

See proposals detail: https://github.com/bmeck/proposal-arbitrary-module-namespace-identifiers

Please @guybedford review changes of this PR to help make sure it compliance with convention.


BTW, I have tried to do some code synchronization from guybedford/cjs-module-lexer as mentioned here, but I found it's HARD to synchronize due to code context changes mentioned here. So I just implement the feature as it should be in this repository.

richardo2016 commented 2 years ago

@guybedford Hi, there're some points we need to check:

  1. Is that necessary to keep same logic in ./lexer.js with ./src/lexer.c?
  2. in case below, should exports[0] equals to '"~123"' (string with double-quotes " ), or to '~123' (string only).
export { "~123" } from './mod0.js';

On the other hand, maybe you need to clone branch on which I take PR with, to check if all tests passed.

Maybe after this PR we could use github actions to run tests on PR or push of main branch. It's not hard, but require some nitty-gritty works. If es-module-lexer need it, I could make another PR to add CI.