Closed dario-piotrowicz closed 5 months ago
Chatted with Igor about this and we agreed on what needs to be done, we actually need to implement factories of plugins that then instantiate the environment.
What I mean is that the current user facing config for the workerd remix example is:
plugins: [
remix({
ssrEnvironment: await workerdEnvironmentProvider({
config: './remix-wrangler.toml',
}),
}),
tsconfigPaths(),
],
and in order to still be able for the end user to specify the config to use (or any other possible workerd option) we need something like:
plugins: [
remix({
ssrEnvironment: await workerdEnvironmentPluginFactory({
config: './remix-wrangler.toml',
}),
}),
tsconfigPaths(),
],
the workerdEnvironmentPluginFactory
call will then generate a plugin that the Remix plugin then can use to instantiate the actual environment (basically the result of the workerdEnvironmentPluginFactory
call is the workerdEnvironmentPlugin
plugin I mentioned in my previous message 👆).
This allows us to move to the plugins structure suggested by Patak while still allowing the user to provide their own workerd options.
[!WARNING]
workerdEnvironmentPluginFactory
is NOT ok as the final user facing name, I've just used it in the example above since it is clearer to understand in this context, the final name should be something like justworkerd
,workerdEnv
, ... or something simple like that
The environment providers exported by the respective packages:
Are a bit too limiting, since their consumers can only use them in their config hook, for example: https://github.com/dario-piotrowicz/vite-environment-6.0.0-alpha-experimentations/blob/bb63a66604448fca5cb27afa712f18dd18b2723f/examples/dummy-framework/frameworkPlugin.ts#L19-L26
This prevents the environments to integrate with the vite pipeline (without the consumer manually adding plugins, etc...).
(for example if the workerd environment needed to always use some specific hook, say
resolveId
, that wouldn't be possible with theworkerdEnvironmentProvider
alone and the consumer would also have to separately register an extra plugins that configures theresolveId
hook)So replacing the above mentioned
xEnvironmentProvider
s withxEnvironmentPlugin
s would enable us to have the plugins both great the environments and also integrate them with the underlying vite pipeline.( usage example:
)
source discord message