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

Rework to use the compiler directly and support svelte-preprocess #1

Open
bummzack opened this issue Jun 11, 2021 · 5 comments
Open

Comments

@bummzack
Copy link

I'm currently trying to integrate a fractal styleguide into a sveltekit project… one of the issues I'm facing is that this adapter doesn't seem to invoke the preprocessor.
Do you have any pointers/hints how this could be accomplished?

@aredridel
Copy link
Owner

Oh gosh! I've not tried, though my work may be moving toward using typescript so that might become an issue where I use this too.

@aredridel
Copy link
Owner

aredridel commented Jun 11, 2021

Ooh. It looks like this would be somewhat more than trivial: preprocess is an async process, and node's require is synchronous. That means reworking this to use the svelte compiler directly rather than the registered require hook. It's probably not too hard — the relevant code in rollup-plugin-svelte is not too bad, so I'd have to start with that to replace the require hook.

That would solve my cache invalidation problem too, so there's benefit to doing it. I don't have a lot of time to work on this right now, but I'd totally support you in making it happen and accept it as a pull request.

@aredridel aredridel changed the title Can this be used with svelte-preprocess? Rework to use the compiler directly and support svelte-preprocess Jun 11, 2021
@bummzack
Copy link
Author

Hm, interesting.

I also noticed that using ES modules (as it is default with sveltekit) clashes with the fractal engine, as it isn't compatible with ES modules, see: frctl/fractal#1024

So if I create a component that has an import statement in the <script> block, the fractal engine will throw an error.
Maybe this could be fixed by additionally transpiling ES6 to commonjs before handing it over to fractal 🤔

@aredridel
Copy link
Owner

That would probably work. That whole business is a bees nest, to be honest. Node went some difficult to manage places with its esm loader, so it's all just a big mess. Embedding rollup would probably work to do that conversion, but that's bringing in a LOT of infrastructure. It might be needed to run svelte code through rollup and rollup-plugin-svelte instead of just the svelte compiler to get commonjs output.

@aredridel
Copy link
Owner

That said, I actually use imports in our styleguide, within svelte. That's fine — it's modules that aren't svelte that use import where things start getting wild.

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

No branches or pull requests

2 participants