payload
payload copied to clipboard
fix: rework build to not rely on initing payload
Description
- [x] I have read and understand the CONTRIBUTING.md document in this repository.
Fixes https://github.com/payloadcms/payload/issues/3942
Moves the aliases from the db adapter packages into core. Removing the need to initialize before building.
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
Checklist:
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] Existing test suite passes locally with my changes
- [ ] I have made corresponding changes to the documentation
@JarrodMFlesch It seems your mocking some integrations on build, the problem i see with that, every extensions and other built it, like email (https://github.com/payloadcms/payload/issues/3942#issue-1969808189) would not be fixed that way. ENV vars should always be runtime, therefor no ENV variables should be use on built time or only those related to a build, like DEV/PROD build.
@JarrodMFlesch we need to pick back up on this. Can we merge main and see what's left?
@JarrodMFlesch It seems your mocking some integrations on build, the problem i see with that, every extensions and other built it, like email (#3942 (comment)) would not be fixed that way. ENV vars should always be runtime, therefor no ENV variables should be use on built time or only those related to a build, like DEV/PROD build.
I believe this should work, as we are no longer initing
payload on build so ENV's are not needed. ENV's with PAYLOAD_PUBLIC will appear in build, the rest will be their equivalent process.env.VARIABLE_NAME.
@jmikrut want to look this over? I tested by building a project locally with a built version of Payload with these changes.
This appears to not be working.
On a vanilla install using the web template, during the payload build, config is undefined and the build fails.
/payload/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/payload/dist/bin/build.js:21
await _.default.config.admin.bundler.build(config);
^
TypeError: Cannot read properties of undefined (reading 'admin')
at build (/payload/node_modules/.pnpm/[email protected]_@[email protected][email protected][email protected]/node_modules/payload/dist/bin/build.js:21:28)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Node.js v21.5.0
Hey @MarkKropf Thanks for your report, we're looking to fix this ASAP
@MarkKropf Thanks for reporting, I fixed this yesterday but never committed the change...? Just merged the fix in this PR, and we will release a new version ASAP.
Thanks @paulpopus & @JarrodMFlesch 🙏
I can confirm this now is resolved in the 2.8.1 tag.
thanks again!