paperbits / paperbits-demo

This repository shows an example how developers can use Paperbits to build web apps with rich content authoring capabilities.
https://demo.paperbits.io
MIT License
300 stars 90 forks source link

Vercel Build fails; Gitpod & Local doesn't #222

Open skybird-dev opened 1 year ago

skybird-dev commented 1 year ago

Describe the bug Deployment on Vercel with Paperbits Demo results in "404" error page, but runs locally & on Gitpod just fine. Screen Shot 2022-12-12 at 9 49 17 PM

Screen Shot 2022-12-12 at 10 00 37 PM

WARNING in ./node_modules/ws/lib/buffer-util.js 113:23-44 Module not found: Error: Can't resolve 'bufferutil' in '/workspace/skybird.app/node_modules/ws/lib' @ ./node_modules/ws/lib/receiver.js 12:42-66 @ ./node_modules/ws/index.js 7:21-46 @ ./node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js 7:18-31 @ ./node_modules/jsdom/lib/jsdom/browser/Window.js 21:22-83 @ ./node_modules/jsdom/lib/api.js 13:25-61 @ ./node_modules/@paperbits/common/publishing/jsdomHtmlDocumentProvider.ts 4:16-32 @ ./node_modules/@paperbits/common/publishing/index.ts 27:13-51 @ ./node_modules/@paperbits/core/core.publish.module.ts 11:21-60 @ ./src/startup.publish.ts 7:30-76

WARNING in ./node_modules/ws/lib/validation.js 117:24-49 Module not found: Error: Can't resolve 'utf-8-validate' in '/workspace/skybird.app/node_modules/ws/lib' @ ./node_modules/ws/lib/receiver.js 13:43-66 @ ./node_modules/ws/index.js 7:21-46 @ ./node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js 7:18-31 @ ./node_modules/jsdom/lib/jsdom/browser/Window.js 21:22-83 @ ./node_modules/jsdom/lib/api.js 13:25-61 @ ./node_modules/@paperbits/common/publishing/jsdomHtmlDocumentProvider.ts 4:16-32 @ ./node_modules/@paperbits/common/publishing/index.ts 27:13-51 @ ./node_modules/@paperbits/core/core.publish.module.ts 11:21-60 @ ./src/startup.publish.ts 7:30-76

Are not the Terser & Terser Webpack plugins supposed to resolve issues with UTF-8 encoding? Typescript stopped requiring specifying character sets because UTF-8 is the default, but I don't see how that's even relevant.

Screenshots If applicable, add screenshots to help explain your problem. Screen Shot 2022-12-12 at 12 35 06 PM

Desktop (please complete the following information): macOS running Visual Studio Gitpod

Additional context Add any other context about the problem here. This is with or without firebase integration, using the default build and my slightly custom build. I've also tried Firebase hosting.

feranto commented 1 year ago

Hey @skybird-dev I'm not familiar with the Vercel platform you are running. But seems like your Vercel environment might be missing some dependencies on your stack, the most obvious ones are the modules shown in your screenshot.

I´ve run the paperbits demo in a vanilla environment in github codespaces and defining a base container image, in this tests I had to add extra packages to Ubuntu, and install extra packages globally using NPM to run the demo successfully:

## update and install some things we should probably have
apt-get update
apt-get install -y \
  curl \
  git \
  gnupg2 \
  jq \
  sudo \
  zsh \
  rename \
  icu-devtools

# setup and install oh-my-zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
cp -R /root/.oh-my-zsh /home/$USERNAME
cp /root/.zshrc /home/$USERNAME
sed -i -e "s/\/root\/.oh-my-zsh/\/home\/$USERNAME\/.oh-my-zsh/g" /home/$USERNAME/.zshrc
chown -R $USER_UID:$USER_GID /home/$USERNAME/.oh-my-zsh /home/$USERNAME/.zshrc

# node 14.x.x
curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

# install global npm libraries
npm i -g webpack webpack-cli webpack-dev-server http-server firebase-tools azure-functions-core-tools@3 --unsafe-perm true

My recommendation would be to check if you are missing something at the OS, Node layer in your Vercel environment?

skybird-dev commented 1 year ago

I have Node.js 16 set for Vercel; I'll try setting it for 14 instead.

FYI: Vercel is serverless, but I don't think that's the problem.