New example published:point_down::skin-tone-2: <ht...
# guide
m
s
The example works great in development! Should I be able to deploy this? I'm getting an error with the StaticSite construct when I try
Copy code
Using stage: sgeoghegan
Preparing your SST app
Building function src/triggers/preTokenGeneration.handler
Building function src/triggers/userMigration.handler
Building function src/private.handler
Building function src/public.handler
Building static site frontend
$ vite build
vite v2.9.5 building for production...
transforming...
āœ“ 1943 modules transformed.
'request' is not exported by __vite-browser-external, imported by node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js
file: /Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js:4:9
2: import { ProviderError } from "@aws-sdk/property-provider";
3: import { Buffer } from "buffer";
4: import { request } from "http";
            ^
5: /**
6:  * @internal
error during build:
Error: 'request' is not exported by __vite-browser-external, imported by node_modules/@aws-sdk/credential-provider-node/node_modules/@aws-sdk/credential-provider-imds/dist/es/remoteProvider/httpRequest.js
    at error (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:198:30)
    at Module.error (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:12521:16)
    at Module.traceVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:12879:29)
    at ModuleScope.findVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:11509:39)
    at FunctionScope.findVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:6477:38)
    at ChildScope.findVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:6477:38)
    at FunctionScope.findVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:6477:38)
    at ChildScope.findVariable (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:6477:38)
    at Identifier.bind (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:7768:40)
    at CallExpression.bind (/Users/sgeoghegan/dev/api-oauth-google/frontend/node_modules/rollup/dist/shared/rollup.js:5342:23)
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.

Error: There was a problem building the "Site" StaticSite.
    at ViteStaticSite.buildApp (/Users/sgeoghegan/dev/api-oauth-google/node_modules/@serverless-stack/resources/src/StaticSite.ts:195:15)
    at new StaticSite (/Users/sgeoghegan/dev/api-oauth-google/node_modules/@serverless-stack/resources/src/StaticSite.ts:97:10)
    at new ViteStaticSite (/Users/sgeoghegan/dev/api-oauth-google/node_modules/@serverless-stack/resources/src/ViteStaticSite.ts:37:5)
    at new MyStack (/Users/sgeoghegan/dev/api-oauth-google/stacks/MyStack.js:104:18)
    at Object.main (/Users/sgeoghegan/dev/api-oauth-google/stacks/index.js:9:3)
    at Object.<anonymous> (/Users/sgeoghegan/dev/api-oauth-google/.build/run.js:94:16)
    at Module._compile (node:internal/modules/cjs/loader:1109:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
    at Module.load (node:internal/modules/cjs/loader:989:32)
    at Function.Module._load (node:internal/modules/cjs/loader:829:14)


There was an error synthesizing your app.
error Command failed with exit code 1.
info Visit <https://yarnpkg.com/en/docs/cli/run> for documentation about this command.
Hmm, after digging around, I found this github issue. Digging through the comments, someone suggested a fix that worked for me, which involved updating the
vite.config.js
to this:
Copy code
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// <https://vitejs.dev/config/>
export default defineConfig({
  plugins: [react()],
  resolve: {
    alias: {
      './runtimeConfig': './runtimeConfig.browser',
    },
  },
})
I haven't taken the time to understand what any of this means, but the deploy worked with that change.
m
Thanks @Seth Geoghegan!
s
@manitej Happy to submit a PR for the example if it's useful.
m
I pushed an update already
maybe related to vite version issue
s
šŸ‘