Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The babel.config.js is exposed, but refers to a source file not available #202

Closed
Ontopic opened this issue Jun 20, 2021 · 3 comments · Fixed by #203
Closed

The babel.config.js is exposed, but refers to a source file not available #202

Ontopic opened this issue Jun 20, 2021 · 3 comments · Fixed by #203

Comments

@Ontopic
Copy link
Contributor

Ontopic commented Jun 20, 2021

Not sure if this is a bug, but feels like at least something NextJS offers in a way that is very convenient and that it's understable you guys may have missed this is as being a thing, like me, if you work locally on a full Payload repo, but not for others that just run the npm version of Payload breaking.

Bug Report

When setting up a babel.config.js that can work with both NextJs and Payload I was trying to import babel.config.js from both. That all seemed to work, since I was using my local fork of Payload, that contains the /src folder. When I however had other devs run it all hell broke loose. After some digging I found that Payload is exporting babel.config.js, but that it's a redirect to /src/babel.config.js, which is of course not available in the release version on npm

./babel.config.js

const config = require('./src/babel.config');
module.exports = config;

Expected Behavior

Return like NextJS the babel.config.js used so you can import it and extend it in your project

Current Behavior

No fun with the misleading babel.config.js sitting there as though I could use it, but just breaking things

Possible Solution

In the yarn run copyfiles step maybe add copying src/babel.config.js and change the require to match in ./babel.config.js

For now I fixed it with a good old copy past from the src folder into my project folder, so other devs could quickly continue, but something to hopefully not be necessary. Would be nice to just like with NextJS feel that I can customise babel.config.js without every release checking if I need to update my copy-pasted babel.config.js 😅

@jmikrut
Copy link
Member

jmikrut commented Jun 20, 2021

Good call!

Just opened a PR to address this. We actually need the babel.config.js to remain as-is, exporting from the /src folder—to accomplish development, exactly how you mentioned.

So, instead of changing that file, we've added a new file called payload/babel. With the change in that PR, you can now access the Babel config by doing the following:

import { config } from 'payload/babel'; 

How's that? We are going to be deploying a bunch of new stuff either later tonight or tomorrow - and this is definitely doable within that release!

@Ontopic
Copy link
Contributor Author

Ontopic commented Jun 21, 2021

Awesome! Just writing a reply in the discussion about module aliases (#201) that that is exactly what is needed for doing it through Babel in I feel a clean and stable enough way (also when upgrading NextJS or Payload). And... my import / require OCD is extra happy with it being a separately named payload/babel module, looks very pleasing next to next/babel 🙃

Copy link
Contributor

github-actions bot commented Sep 8, 2024

This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants