Webpack alias workaround stops working on dev and build after build run #794
Replies: 2 comments 5 replies
-
Hey @old-zoomer — we try and keep our issues strictly limited to bugs, but here, this is just a problem with your configuration. I'm going to move this to a discussion. But, we do understand that this aliasing is not ideal, and we have longer-term plans to fix it similarly to how NextJS eliminates server-side code, but this is quite complex. It's nearing the top of our list of priorities. In the interim, I am 100% confident that there is just a small issue somewhere. Question What are the errors that you are seeing? Potential Fix 1 Ensure that your mock files are also present and copied over to your Potential Fix 2 This is more of a best practice than anything, but if you are mocking a module for webpack, the mock should represent the same shape of data that the actual file contains. So, your mock is an empty object, but your actual file is a function. I don't think this is an issue, but it could be. Potential Fix 3 Try and delete your Give those a shot! We'll get it sorted and thanks for hanging in there. A more permanent solution is on the way. |
Beta Was this translation helpful? Give feedback.
-
I'll try the fixes. Regarding Fix 2 - I don't think that's the problem, because everything is working fine until I do a build Here is the error I see
|
Beta Was this translation helpful? Give feedback.
-
Bug Report
Webpack alias workaround stops working on dev and build after build run. I think I am going crazy here 🤡 #678 #766
Expected Behavior
if
yarn dev
andyarn build
works with no errorsthen
cd dist
PAYLOAD_SECRET=secret MONGODB_URI=mongo node server.js
^C
cd ..
yarn dev
works with no errors
Current Behavior
yarn dev
andyarn build
works with no errorscd dist
PAYLOAD_SECRET=secret MONGODB_URI=mongo node server.js
webpack errorcd ..
yarn dev
webpack error, WTF 🤡rm -rf dist build
yarn dev
webpack error, WTF 🤡🤡🤡Possible Solution
In general this webpack alias workaround is driving me crazy and i spent more of time trying to get it work then actually configuring cms, this looks like v0.1 solution, not v1.0.
Please help me get this this running with some workaround for now.
Ideal solution would be to handle this in a more mature way (not sure if this possible or makes sense considering current setup)
Steps to Reproduce
Add files
src/server-side/storage.ts
src/mocks/empty.ts
src/collections/Media.ts
Edit file
src/payload.config.ts
yarn dev
- successyarn build
- successcd dist
PAYLOAD_SECRET=secret MONGODB_URI=mongo node server.js
webpack compiled with 45 errors and 1 warning
cd ..
yarn dev
webpack compiled with 45 errors and 1 warning
rm -rf dist build
yarn dev
webpack compiled with 45 errors and 1 warning
Beta Was this translation helpful? Give feedback.
All reactions