wmr icon indicating copy to clipboard operation
wmr copied to clipboard

Switch CommonJS transform to cjs-module-lexer

Open developit opened this issue 5 years ago • 1 comments

Now that cjs-module-lexer is battle-tested (it powers CommonJS in Node as of 14.17), we should switch to it. This gives us a clean way to support CJS-->ESM transformations like we're already doing, but without the horrible regex-based implementation I cobbled together.

  • [ ] inline my forked copy of cjs-module-lexer's JS version with require() tracking
  • [ ] create a new lib/transform-cjs.js module that wraps cjs-module-lexer (similar to lib/transform-imports.js)
  • [ ] replace fast-cjs-plugin.js implementation with a call to the new library
  • [x] add/improve CommonJS tests (improved in #156)

developit avatar Sep 30 '20 18:09 developit

Looks like cjs-module-lexer won't land my require() tracking fix: https://github.com/guybedford/cjs-module-lexer/pull/10/

I published the dist files (both JS and WASM) to a branch which we can vendor.

developit avatar Oct 10 '20 14:10 developit