Replies: 9 comments 13 replies
-
Totally agree with moving away from webpack. There are nice alternatives like you mentioned. Imo, the Turbo Kitchen Sink example would be nice for Payload. An example of how the project could be layed out based on the example: Apps and Packages
To be added by the dev, one or more of: This seems ideal to me - you get all the TurboRepo goodness when you are willing to structure your app to follow the turbo setup. But if you want a setup more similar to the current one you just run the Payload app/package separately. Turbo can be a little too intimidating/prescriptive of your setup for all people. |
Beta Was this translation helpful? Give feedback.
-
I suggest RSPack. 1-1 port of webpack to Rust. |
Beta Was this translation helpful? Give feedback.
-
I haven't used turbo, but all Vite based frameworks I have worked with are extremely pleasant to use (For example Astro or Sveltekit, …) |
Beta Was this translation helpful? Give feedback.
-
Have you been able to reach a resolution on which bundler to support? |
Beta Was this translation helpful? Give feedback.
-
Follow your heart and use Vite. |
Beta Was this translation helpful? Give feedback.
-
+1 for turbo pack: https://turbo.build/pack/docs/comparisons/vite |
Beta Was this translation helpful? Give feedback.
-
What are the plans for server-side code not making it into the client bundle for security and performance reasons? I'm particularly thinking of plugins which can't predict what bundler each project will use, currently in our plugins we just extend webpack and that just about works enough. Maybe if we had an interface? Or if it could be automated |
Beta Was this translation helpful? Give feedback.
-
Most projects except for Vercel and co are standardizing on Vite/esBuild. Even Bun and Deno. |
Beta Was this translation helpful? Give feedback.
-
So we have landed on a new bundler pattern. By default (for now) we are attaching the webpack bundler in the sanitize function here. You can see how it imports the bundler from You can see how this works with the current webpack bundler here. No matter the bundler, the gist of mocking the bundler file looks like this: import path from 'path';
const mockModulePath = path.resolve(__dirname, 'relative-path-to-mock-module');
const bundlerPath = path.resolve(__dirname, 'relative-path-to-bundler');
const getBaseConfig = () => {
return {
// ... rest of config
resolve: {
alias: {
[bundlerPath]: mockModulePath,
},
},
};
}; Currently I cannot seem to get this working for vite OR rspack. If we could get this working this would unblock us greatly and swift progress could be made. If anyone has any experience or insights as to how these bundlers handle alias resolutions, please chime in! We have reached out to the contributors of rspack and we think there may be a bug with how module resolutions are handled. You can follow along with that here. For those curious, the new WIP bundler branches are: THE (first) GOAL: be able to use a new bundler and run yarn dev fields. Currently we get errors when running this command, both with vite and rspack. If you have any questions please let me know, I have spent a bit of time on this and will keep attempting to get this working. THE (second) GOAL: be able to link a project with payload, build payload core and then build the linked project successfully. Draft PR for Vite bundler can be found here |
Beta Was this translation helpful? Give feedback.
-
We need to move away from Webpack to optimize for DX. A user should be able to select their bundler and pass it to Payload on initialization.
We should decide if we want to support Vite or Turbopack first.
Adapter pattern
The first step to implementing support for additional bundlers is to abstract out everything that Webpack is currently used for into a new adapter-style pattern.
For example, we could create a new config property called
bundler
that accepts a class or object which provides the following properties:First quick pass tells me that this might be all that we'd need. Usage would look like this:
Pre-breaking change implementation
In order to test / implement future bundlers, we should keep Webpack within Payload's existing dependencies until we release a breaking change w/ major version (right now, that'd be 2.0.0).
But we could support the new
bundler
config property in advance, and then users could opt-in to passing their own bundler, which, if present, Payload would defer to it instead of using its built-in Webpack dependencies. These external bundlers could come with all dependencies they need (Vite, Turbopack, etc.) so that Payload itself does not need to install them unless they are used.Beta Was this translation helpful? Give feedback.
All reactions