@kitchenshelf/serverless-rspack
Version:
[Serverless Framework](https://www.serverless.com) plugin for zero-config JavaScript and TypeScript code bundling using the high performance Rust-based JavaScript bundler [`rspack`](https://rspack.dev/guide/start/introduction)
29 lines • 1.71 kB
JavaScript
import { __awaiter } from "tslib";
import path from 'node:path';
export function Initialize() {
return __awaiter(this, void 0, void 0, function* () {
var _a;
this.pluginOptions = this.getPluginOptions();
if ((_a = this.pluginOptions.config) === null || _a === void 0 ? void 0 : _a.path) {
const configPath = path.join(this.serviceDirPath, this.pluginOptions.config.path);
if (!this.serverless.utils.fileExistsSync(configPath)) {
throw new this.serverless.classes.Error(`Rspack config does not exist at path: ${configPath}`);
}
const configFn = (yield import(configPath)).default;
if (typeof configFn !== 'function') {
throw new this.serverless.classes.Error(`Config located at ${configPath} does not return a function. See for reference: https://github.com/kitchenshelf/serverless-rspack/blob/main/README.md#config-file`);
}
this.providedRspackConfig = yield configFn(this.serverless);
}
const functions = this.serverless.service.getAllFunctions();
this.functionEntries = this.buildFunctionEntries(functions);
if (!this.functionEntries ||
Object.entries(this.functionEntries).length === 0) {
throw new this.serverless.classes.Error(`No functions detected in service - you can remove this plugin from your service`);
}
this.log.verbose('[sls-rspack] Function Entries:', this.functionEntries);
this.functionScripts = this.buildFunctionScripts(functions);
this.log.verbose('[sls-rspack] Function Scripts:', this.functionScripts);
});
}
//# sourceMappingURL=initialize.js.map