-
Notifications
You must be signed in to change notification settings - Fork 1
Add GetDependentFiles to slim service. #14
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
Conversation
|
@nojaf Thanks, that looks useful, we can improve the current typecheck caching (see If we make the change to use the graph and improve the typecheck caching, do you still need this as a separate method? I'm not opposed to adding it, I'm sure you have some use for it in your plugin, just asking to make sure you need it. |
At first glance, I do think I will need it. I believe the rough outline for the Vite plugin: const { compileFSharp } = require('./some-great-compile-fsharp-module');
export default function fablePlugin() {
return {
name: 'fable-plugin',
async transform(code, id) {
// Check if the file has a .fs extension
if (id.endsWith('.fs')) {
// Use your compileFSharp function to transform the F# code to JavaScript
const { compiledCode, dependencies } = await compileFSharp(code);
// Create an array to hold the transformed dependencies
const transformedDependencies = [];
// Process and emit the dependencies as separate files
for (const depId of dependencies) {
const { compiledCode: depCode } = await compileFSharp(
// Load the content of the dependency using Rollup's `this.emitFile` function
this.emitFile({ type: 'chunk', id: depId }),
);
transformedDependencies.push(depCode);
}
// Return the transformed code for the current module
return {
code: compiledCode,
map: null, // You may provide source maps if needed
};
}
},
};
}I would need to call the |
This adds a method to the slim service to find the dependent files in a project using the new Graph-based type-checking code.
What the graph-based type-checking does is detect links between files using the untyped tree.
This turned out to be very reliable and helps to answer the question of what files should be reprocessed after the current file has changed.
More of the code could improve a bit, but I'm raising this more as a conversation starter. Would you be ok with having this?
This would be a puzzle piece in the work for fable-compiler/Fable#3552.