-
Notifications
You must be signed in to change notification settings - Fork 32
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
Build: Migrate create-plugin to ESM #658
Conversation
…s package.json prop
6baaac4
to
dabaee1
Compare
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.
LGTM! Interesting since I tried to do the same thing with Levitate and manage to get everything working except the jest tests. But then the solution might be to migrate over to vitest.
Probably will make life much easier. Admittedly this is a small project but the Vitest migration was surprisingly straightforward. It was only mocks that needed any attention. Jest and ESM just don't very work well together. 😞 |
🚀 PR was released in |
What this PR does / why we need it:
This PR updates the create-plugin package to build only as an es module. The following changes have been made with reasoning on approaches:
.js
extension to imports. Note that auto barrel file resolution (from './commands/'
resolved tofrom './commands/index.js'
) no longer work with ESM. You have to reference a file. VsCode autocompletion seems to work out the box. I attempted to use a bundler ESbuild to prevent the need to change all these imports but hit a wall.import
overrequire
. I'm not sure whyutils.console.ts
used require but changing them led to complications with TS types and needing to patch the marked-terminal package and set overrides formarked
nested dependency.unstable_mockModule
which I didn't particularly like the sound of. Vitest migration was quite painless, only the mocks needed some attention.Which issue(s) this PR fixes:
Related #654
Special notes for your reviewer:
📦 Published PR as canary version:
Canary Versions
✨ Test out this PR locally via:
npm install @grafana/create-plugin@3.0.0-canary.658.52bb056.0 # or yarn add @grafana/create-plugin@3.0.0-canary.658.52bb056.0