-
Notifications
You must be signed in to change notification settings - Fork 33
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
Create-Plugin: Transform known ES modules in jest config #145
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! 👏
@@ -5,6 +5,8 @@ | |||
*/ | |||
|
|||
const path = require('path'); | |||
// Jest will throw errors if it tries to load an es module with it being transformed first | |||
const esModules = ['ol', 'react-colorful'].join('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it would make sense to update the comment and the name of the variable to reflect more what problems one can solve with adding package names here and when it should be used? Probably it would also make sense to export it so plugin devs can extend it in their own config more easily?
const esModules = ['ol', 'react-colorful'].join('|'); | |
// Just an idea, maybe we can find a better name | |
const esModuleNpmPackages = ['ol', 'react-colorful'].join('|'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
🚀 PR was released in |
@jackw This causes some issues, maybe something missing in the migration script?
https://drone.grafana.net/grafana/clock-panel/35/1/5 |
Thanks for the heads up @tolzhabayev I'll get it fixed! 🙏 |
What this PR does / why we need it:
The previous PR that addressed issues with loading es modules by transforming all modules in node_modules introduced an issue where SWC will error if a package contains code the typescript compiler doesn't appreciate.
One example of this is reassignment of a class (something we do in grafana/data).
I'm not sure if there's a better way to solve this but I'm now leaning towards maintaining a list of packages as a solution mentioned in #111.
Which issue(s) this PR fixes:
Fixes #111
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via:
npm install @grafana/create-plugin@0.5.2-canary.145.6b7c318.0 # or yarn add @grafana/create-plugin@0.5.2-canary.145.6b7c318.0