Skip to content
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

Fix typescript compilation #1429

Merged
merged 5 commits into from May 6, 2021
Merged

Conversation

MonkeyDo
Copy link
Contributor

@MonkeyDo MonkeyDo commented May 5, 2021

My previous PR #1402 inadvertently broke production build due to a missing configuration option for Typescript transpilation.

Not exactly 100% sure why this didn't show up during dev builds at all, but I have some theories (post processing steps like minification or sourcemaps generation).

I also moved the babel configuration to babel.config.js (which already existed) to avoid confusion of having two separate configs.

Added allowDeclareFields: true option, otherwise we get compilation errors and failure.
Moved all babel compilation options to babel.config.js to avoid duplicate configs
this plugin should already be part of @babel/preset-env, but ¯\_(ツ)_/¯
@amCap1712
Copy link
Member

amCap1712 commented May 5, 2021

I have pushed the minimal changes that worked for me to this branch. I do not understand why we needed both the preset and the plugin. It might be possible to reduce this to just doing it once but I do not know babel well enough to do that.

I have rearranged the presets to match how they are specified in https://github.com/bookbrainz/bookbrainz-site/blob/master/.babelrc. When it still didn't work, I added it in the plugin as well. After doing that I began to encounter babel/babel#11038, I applied the suggested workaround to pin 2.3.3.

@MonkeyDo
Copy link
Contributor Author

MonkeyDo commented May 6, 2021

For posterity, the issue revolves around a bleeding-edge typescript feature (type-only class fields e.g. here) and the interaction of the various presets and plugins we use when compiling.

The feature seems to be bit in flux at the moment, so the simple solution of this commit will be enough until Babel v8 comes out, which will support all this a lot better.

In short, this solution changes the order in which plugins are run and adds allowDeclareFields setting (which will be true by default in Babel v8).

I tried updating our various packages but found some more caveats.
Let's revisit this when Babel v8 comes out and it's more stable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants