payload icon indicating copy to clipboard operation
payload copied to clipboard

fix: rework build to not rely on initing payload

Open JarrodMFlesch opened this issue 1 year ago • 1 comments

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 avatar Nov 06 '23 17:11 JarrodMFlesch

@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.

dominikzogg avatar Nov 15 '23 06:11 dominikzogg

@JarrodMFlesch we need to pick back up on this. Can we merge main and see what's left?

jmikrut avatar Jan 09 '24 19:01 jmikrut

@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.

JarrodMFlesch avatar Jan 10 '24 21:01 JarrodMFlesch

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

MarkKropf avatar Jan 12 '24 17:01 MarkKropf

Hey @MarkKropf Thanks for your report, we're looking to fix this ASAP

paulpopus avatar Jan 12 '24 17:01 paulpopus

@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.

JarrodMFlesch avatar Jan 12 '24 17:01 JarrodMFlesch

Thanks @paulpopus & @JarrodMFlesch 🙏

MarkKropf avatar Jan 12 '24 17:01 MarkKropf

I can confirm this now is resolved in the 2.8.1 tag.

thanks again!

MarkKropf avatar Jan 12 '24 18:01 MarkKropf