-
Notifications
You must be signed in to change notification settings - Fork 166
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
Auspice extensions are not being (fully) transpiled, causing ES6 code to be leaked into the bundle. #902
Comments
nextstrain/nextstrain.org#119 removes Obviously, the transpilation issue itself is not solved. I cannot even find why that happens. These |
This moves the "auspice" server code to `./src` so that all the auspice client code is in it's own directory (./auspice-client`). This helps prevent `auspice build` pulling in code it shouldn't and which it doesn't correctly transpile. Note that this is a work-around for the deeper problem explained at nextstrain/auspice#902. Moving server code to `./src` makes sense now that the nextstrain.org capabilities have advanced. Some file renaming may be in order here for clarity, and we should consider moving `authn.js` and `redirects.js` into `./src`.
Adding this to https://github.com/orgs/nextstrain/projects/5 in case webpack experts see this! Please reach out to myself or @ivan-aksamentov if you need a better description of nextstrain / auspice extensions |
Hey everyone, I actually built are-you-es5 specifically for finding out which node_modules aren't ES5 and getting a regex to include them in babel-loader's pipeline and have them be transpiled to ES5. @hydrosquall opened an issue (reference to it is right above this comment) to see if are-you-es5 could help with this and I'm happy to help out however I can. |
The reason why whitelisting attempt does not work here is because the module So whitelisting it like this:
Actually works pretty well. For a more general (but not fully general) solution that could help reducing guesswork for people developing extensions you might try something like:
To force default resolution to pretranspiled version for modules that have both (this is the case for |
Another minor thing I've noticed about this is the following: Auspice's webpack tries to source However, if you trying compiling auspice with extensions, and your extensions are in a separate folder, and contain To test it out you can:
Then serve it and see React fail with mention of "bad hooks" which turns out to be caused by 2 reacts. An easy patch for this is aliasing react explicitly in
But I'm not 100% sure that this hasn't some additional unintended effect. You might simply wanna add a mention somewhere that for the extensions to work |
This issue affects both nextstrain.org and auspice.
Description
Recently a dependency to 'iso-639-1' package was introduced in nextstrain.org, required for language picker functionality, implemented as a part of nextstrain's extension to auspice:
nextstrain/nextstrain.org/auspice/client/languageSelector.js#L2
This uncovered a defect in auspice extension system. The
iso-639-1
package distribution contains transpiled ES5 bundle and original ES6 modules:https://github.com/meikidd/iso-639-1/blob/master/package.json#L5-L6
Auspice's webpack somehow picks ES6 code and fails to transpile it, so that ES6 classes (in particular,
class
keyword), go (minified) straight into the bundle:This portion of code corresponds to
class ISO6391
:https://github.com/meikidd/iso-639-1/blob/master/src/index.js#L3
and its ES5 version is shipped here (but ignored by our webpack):
https://github.com/meikidd/iso-639-1/blob/master/build/index.js#L1574
This could be due to:
Now, normally, dependencies are excluded in
babel-loader
, but one may need to selectively whitelist some of the packages, if package module target does not meet the requirements. I tried to whitelistiso-639-1
, in auspice, but that did not work (see below).Note that in the case of nextstrain.or we know what to whitelist because the auspice and extension come from the same team. I am sure we will find a way to patch it. However, for a third party extensions, auspice can not know (at runtime) which packages are being used by the extension, therefore it can not know what to whitelist.
Basically, current users of the extension system have to ensure that their modules are compatible with their desired target browsers. One way is to transpile the modules as a separate step.
Attempted fix
Adding
.browserslistrc
and whitelisting
iso-639-1
for transpilation inwebpack.config.js
:That somehow did not work.
class
keyword is still in the bundle.I still only understand the extension system vaguely, and is puzzled right now.
Context
This was uncovered by @emmahodcroft as another "nextstrain.org is broken in Internet Explorer again" issue, but this time it is a bit deeper than usual and also affects at least all the users with browsers that do not support ES6 classes, which are all the browsers prior to ~2016-2017, (~7% of global share, see caniuse.com/es6-class).
Note how Firefox 45 is listed as green on caniuse for ES6 classes, but still fails to render, probably due to other untranspiled code fragments appearing in the bundle later on.
The text was updated successfully, but these errors were encountered: