[Feature]: Svelte library support
What problem does this feature solve?
Rslib is an amazing tool but it lacks support for building libraries for svelte, currently we need to have a sveltekit project for building libraries, can't really split it into modules, making it messy
What does the proposed API look like?
A svelte preprocess plugin can be provided, like which preprocesses the .svelte files and emits uncompiled svelte files which is necessary for svelte libraries + a dts plugin for svelte files
Code can be taken from: https://github.com/sveltejs/kit/tree/main/packages/package
You can use @rsbuild/plugin-svelte to compile svelte files, but we do not provide transform-only mode for svelte now.
our manpower is limited, and we definitely want to support Svelet, whereas this is not our current superior goal. contribution is welcomed if anyone is interested in implementing this feature. and we're glad to help.
our manpower is limited, and we definitely want to support Svelet, whereas this is not our current superior goal. contribution is welcomed if anyone is interested in implementing this feature. and we're glad to help.
I can make a plugin for it, but I need help with that
Like first, I want to preprocess the .svelte file and emit .svelte file, is there possible, how can I do that
Second, svelte files require other way for generating .d.ts files, how do I integrate it with the default rslib dts plugin
- Implement a loader for .svelte file.
- I recommend to write a separate plugin to emit svelte dts files, maybe named
rsbuild-plugin-svelte-dts.
Implement a loader for .svelte file.
- I recommend to write a separate plugin to emit svelte dts files, maybe named
rsbuild-plugin-svelte-dts.
i tried this but not worked
import type { RsbuildPlugin } from '@rsbuild/core';
export const pluginSvelteEmit = (): RsbuildPlugin => {
return {
name: 'rslib-plugin-svelte',
setup(api) {
api.modifyRspackConfig((config, { mergeConfig }) => {
return mergeConfig(config, {
module: {
rules: [
{
test: /\.svelte$/,
type: 'asset/resource',
parser: {
parse: undefined
}
}
]
},
resolve: {
extensions: [
'.svelte',
...(config.resolve?.extensions || [])
]
}
});
});
}
};
};
export default pluginSvelteEmit;
I don't think this configuration is necessary, module.parser is an object.
parser: {
parse: undefined
}
Additionally, I suggest you first clarify the input and output of your svelte file after processing by the loader. assets/resource are similar to file-loader which will not perform any preprocessing on the svelte files.
I don't think this configuration is necessary,
module.parseris an object.parser: { parse: undefined }Additionally, I suggest you first clarify the input and output of your svelte file after processing by the loader.
assets/resourceare similar tofile-loaderwhich will not perform any preprocessing on the svelte files.
Btw do u have any such plugin for rslib from which I can use for reference?