Im upgrading from SST 3.2 to 3.11 but as soon as I use the deploy command, I get the following error: Your sst.config.ts has top level imports - this is not allowed. Move imports inside the function they are used and do a dynamic import: const mod = await import("./mod")
This is my old .config file:
import { settings } from 'path/to/settings';
const type = 'test';
export default $config(settings(type));
I have tried to change the config file like this:
const type = 'test';
export default $config(async () => {
const { settings } = await import('path/to/settings');
return settings(type);
});
But I get this error Unexpected error occurred. Please run with --print-logs or check .sst/log/sst.log if available. with an empty log folder.
I have tried to search for documentation on this but I have not been able to find anything. Has anyone experienced something similar when upgrading?
Have a look at the reference docs for sst.config.ts.
The $config function doesn't accept a function, instead it wants an object conforming to the Config type with app, run and console properties.
Looks like app is the right callback to use for configuration however what you use depends on the return type of settings().
For example...
/// <reference path="./.sst/platform/config.d.ts" />
const type = 'test';
export default $config({
// Your app's config
async app(input) {
const { settings } = await import('path/to/settings');
const { app } = settings(type);
return app(input);
},
// Your app's resources
async run() {
const { settings } = await import('path/to/settings');
const { run } = settings(type);
return run();
},
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With