-
-
Notifications
You must be signed in to change notification settings - Fork 781
Closed
Labels
featNew feature or requestNew feature or requestteamThe issue/pr is created by the member of Rspack.The issue/pr is created by the member of Rspack.
Description
What problem does this feature solve?
Currently, to utilize the builtin:swc-loader transformation capability in rspack, a complete rspack bundling compilation is required.
If rspack provides a standalone transform API, it can be used directly to invoke rspack's builtin:swc-loader for some file transformations.
Potential scenarios:
- Loading of some configuration files. When rsbuild loads the configuration file, it needs to transform the configuration file from typescript to javascript.
- Rslib's bundleless scenario, currently requires a complete rspack compilation. However, it seems that only rspack's resolve and transform capabilities are needed.
What does the proposed API of configuration look like?
It may be an API on the rspack instance that reads rspack's configuration. Or a util method that calls rspack builtin:swc-loader alone.
import { rspack } from '@rspack/core';
import fs from 'node:fs'
const compiler = rspack({
// ...
});
const code = await compiler.transform('./index.ts');
fs.writeFileSync('./dist/index.js', code);or
import { swcTransform } from '@rspack/core';
import fs from 'node:fs'
const code = await swcTransform('./index.ts', swcLoaderOptions);
fs.writeFileSync('./dist/index.js', code);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featNew feature or requestNew feature or requestteamThe issue/pr is created by the member of Rspack.The issue/pr is created by the member of Rspack.