You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to build my forest admin project with esbuild into a single js file. That's almost working perfectly.
However, I have defined actions in some collections. I would like to import statically these collections otherwise esbuild won't bundle them.
Actual behavior
Currently, the only way to import collections is by providing a configDir in LianaOptions. This will load dynamically (through a call to requireAll()) all the files in the provided directory.
constlianaOptions: LianaOptions={authSecret: readFromEnv('FOREST_AUTH_SECRET'),// configDir will load dynamically js files. It is replaced by the explicit import of ../forestconfigDir: `pathWhichMustNotExist${Math.random()}`,
connections,envSecret: readFromEnv('FOREST_ENV_SECRET'),
objectMapping,schemaDir: join(__dirname,'../..'),};require('../forest');app.use(awaitinit(lianaOptions));
require('../forest') imports a call to the function collection() like this:
Expected behavior
I would like to build my forest admin project with esbuild into a single js file. That's almost working perfectly.
However, I have defined actions in some collections. I would like to import statically these collections otherwise esbuild won't bundle them.
Actual behavior
Currently, the only way to import collections is by providing a
configDir
inLianaOptions
. This will load dynamically (through a call torequireAll()
) all the files in the provided directory.Failure Logs
N/A
Context
I'm using
[email protected]
which requires[email protected]
.Here is my attempt:
require('../forest')
imports a call to the functioncollection()
like this:It does not work because
Schemas.schemas
was not yet initialized and the collection is not loaded (see https://github.com/ForestAdmin/forest-express/blob/main/src/index.js#L402).If I require the collection after the initialization, the schema
.forestadmin-schema.json
has been written and does not include the actions.If we could have a (asynchronous) function to load the collections in addition to the
configDir
that would solve my problem.Maybe something like:
I would appreciate your help or feedbacks. If you like the idea, I can create a PR.
The text was updated successfully, but these errors were encountered: