esm.sh icon indicating copy to clipboard operation
esm.sh copied to clipboard

The unit test success rate for esm.sh is lower after refactoring

Open zhoukekestar opened this issue 4 years ago • 9 comments

Hey, @ije nice try for esm.sh 's refactoring to transform node eval to ast parser. Better for some package like: /@lume/element, /@lume/variable. But bad for some packages too, here is the details:

Online Test for current esm.sh : 66.23% Xnip2021-04-02_14-55-33

Online Test for (esm.alibaba-inc.com) which is based on old version: 89.61% Xnip2021-04-02_14-57-05

zhoukekestar avatar Apr 02 '21 06:04 zhoukekestar

Maybe we need node eval and ast parser both for named export & packaging depends on different situations.

zhoukekestar avatar Apr 02 '21 07:04 zhoukekestar

@zhoukekestar i think the AST parser is ok, guess the main problem is that i updated esbuild to 0.11, the external module resolver needs to be updated too becuase i saw a lot require is not defined errors, i will fix it asap, thanks 🙏 btw the testing looks amazing, can you please share it with me?

ije avatar Apr 02 '21 12:04 ije

Thanks for your hard working, the unit test is very simple which is written in native JavaScript. I will open-source it if you need this so that we can deliver esm.sh with more confidence.

zhoukekestar avatar Apr 03 '21 02:04 zhoukekestar

Screenshot 2021-04-04 at 00 01 29 i added a simple testing page, do you have interest in improving it? thanks

ije avatar Apr 03 '21 16:04 ije

you can update it in here: https://github.com/postui/esm.sh/blob/master/embed/test/testing.js

ije avatar Apr 03 '21 16:04 ije

run the testing in http://localhost/?test

ije avatar Apr 03 '21 16:04 ije

btw, i added a build queue instead of the mutex lock that can use the multiple CPU units. in my computer (i7 8 cores) it got almost 7x build speed faster!

ije avatar Apr 03 '21 16:04 ije

Great, that's awesome!

zhoukekestar avatar Apr 06 '21 02:04 zhoukekestar

Some hack details maybe useful for you to pass all unit test:

  • named export solution PRed by @wleonardo
  • some npm packaged by webpack
  • some npm use browser entry directly. For example: https://unpkg.com/browse/[email protected]/browser.mjs
  • some necessary polyfill like: @jspm/core & entends it. For example: https://github.com/jspm/jspm-core/issues/13
  • some named export like arguments seems NO-SOLUTION for it, and may be the only way is use is.default.arguments. For example: https://github.com/postui/esm.sh/issues/28

zhoukekestar avatar Apr 07 '21 01:04 zhoukekestar