The "Migrate to v1.0" docs say you can "optionally...
# help
t
The "Migrate to v1.0" docs say you can "optionally" adopt Functional stack. However, when I attempt to use the class-based mechanism to extend Stack, I get a build error of:
Copy code
TypeError: import_sst.MojoStack is not a constructor
Is using the functional version not optional after all?
t
can you share your code
t
This is a barebones setup so far, but gets across the idea. This is in our private library package that is then imported into other apps. The idea is that we can give it a distinct name, pass in a common Api and Table, and also pass in a unique config file. Then it will add more routes (and do other stuff like set up SNS topics and such.)
d
is
MojoConfig
coming from outside a package in a monorepo? Or…above the
sst.json
file?
whatever it is, feels like a node problem. I can verify that class stacks still work in a wide variety of circumstances.
t
I have the class stack working locally, now will move it back to the external package. Maybe I did something else wrong.
@Derek Kershner Importing the "MojoStack" class from a local file in the app works, importing the identical file from an npm package fails with this error:
Copy code
TypeError: import_sst2.MojoStack is not a constructor
    at /tmp/seed/source/stacks/index.ts:21:13
    at Array.forEach (<anonymous>)
    at Object.main (/tmp/seed/source/stacks/index.ts:19:36)
    at Object.<anonymous> (/tmp/seed/source/.build/run.js:92:16)
    at Module._compile (internal/modules/cjs/loader.js:1068:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:933:32)
    at Function.Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47
Notices refreshed
There was an error synthesizing your app.
error Command failed with exit code 1.
So perhaps yes, a node issue, maybe because of how the class is transpiled during the package build?
I've determined this error is only happening when a build is done on Seed, not when a build is done locally. So I have to go address it as a Seed issue for now.
f
Hey @Trey Overton, can you try triggering a force deploy on Seed? That will clear the node modules cache and start clean.
Copy code
import_sst2.MojoStack
sst2
makes me feel there might be 2 versions of SST in
node_modules
?
Also make sure the SST package version is pinned (without leading
^
) in package.json.
t
Only one version in node_modules (in my local version), pinned to 1.0.12. I can't try a force deploy because I already deleted the failing stack and recreated it.
I think I had tried the force deploy, but when I was looking at the output, there were messages noting that yarn.lock had changed, so it was skipping the restore from cache step for dependencies.
@Frank ^
f
I see. Let me know if this pops up again. I can get the team to purge the node_modules cache on our end to make sure build environment is as clean as deploying to a new stage.
t
OK, we'll try that if it comes up.