Switch to ESM#366
Conversation
|
@byara @ayusharma what do you think about these changes? There are several pieces needed for this plugin to be able to consume an ESM only prettier plugin, so I am trying to break all the pieces into their own PRs for easier review. |
|
Now that I am looking at this, it seems a lot of the snapshots changed, so I suppose sorting might not be working anymore 🤔 |
|
Hey @vladislavarsenev could you please take a look here? |
|
@vladislavarsenev I seem to have done something wrong here, as all the snapshots seem to have updated and the imports are no longer sorted. Please let me know if you have ideas to get things working again. |
Hi @RobbieTheWagner. Thank you for your effort! It seems, prettier failed in resolving plugin properly. It sees module, but cannot access default export. inside const plugin = require('../src');
function run_spec(dirname, parsers, options) {
options = Object.assign(
{
plugins: [plugin.default],
tabWidth: 4,
},
options,
); |
|
@vladislavarsenev ah, that worked, thank you! It looks like all the snapshots now correctly show being renamed, but no other changes. Would you mind giving this a review? Happy to make any tweaks required to get this in. |
|
@vladislavarsenev I reverted that file, but it still seems to not be sorting for svelte. Not sure why. Any ideas? |
Sorry for long delay in answer. The issue was the same as previously. in const plugin = require('../../src');
run_spec(__dirname, ["svelte"], {
importOrder: ['^@core/(.*)$', '^@server/(.*)', '^@ui/(.*)$', '^[./]'],
importOrderSeparation: true,
plugins: ['prettier-plugin-svelte', plugin.default],
overrides: [{ "files": "*.svelte", "options": { "parser": "svelte" } }]
});That should work. Jest doesn't handle ESM well, I'd rather switch to Vite someday, as it is faster and supports ESM out of the box. |
|
Ah thank you @vladislavarsenev! Svelte files seem to sort correctly now! Is there anything else we need to get this in? |
|
@RobbieTheWagner Looks good to me! Thank you |
|
Awesome, thanks for your help @vladislavarsenev! Please feel free to merge whenever you can and I can rebase my other PRs. |
|
@vladislavarsenev @byara any chance we could get this merged? It would be ideal to have it in and be able to rebase my other PRs before continuing on them. |
We will try to merge and release this soon 👍 |
CJS has some issues, so this attempts to convert everything to be ESM compatible.