sapcc / juno

Monorepo for the Juno microfrontend framework, microfrontend apps, design system and component library
Apache License 2.0
7 stars 2 forks source link

Build and host your own Juno application Issues #325

Open notandy opened 1 year ago

notandy commented 1 year ago

Hi, I followed the guide and found following issues:

esbuild not found

running first npm run start failes with:

[qa-de-1:monsoon3][~/go/src/github.com/sapcc/andromeda/web]$ npm run start                                                                                                                                                                *[main]

> andromeda@1.0.1 start
> PORT=$APP_PORT NODE_ENV=development node esbuild.config.js --serve --watch

node:internal/modules/cjs/loader:1085
  throw err;
  ^

Error: Cannot find module 'esbuild'
Require stack:
- /Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at Module._load (node:internal/modules/cjs/loader:928:27)
    at Module.require (node:internal/modules/cjs/loader:1149:19)
    at require (node:internal/modules/helpers:121:18)
    at Object.<anonymous> (/Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js:1:17)
    at Module._compile (node:internal/modules/cjs/loader:1267:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
    at Module.load (node:internal/modules/cjs/loader:1125:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js'
  ]
}

Node.js v20.0.0

fixed with npm install --save-dev esbuild

Cannot find module '../../helpers/appProps'

[qa-de-1:monsoon3][~/go/src/github.com/sapcc/andromeda/web]$ npm run start                                                                                                                                                                          *[main]

> andromeda@1.0.1 start
> PORT=$APP_PORT NODE_ENV=development node esbuild.config.js --serve --watch

node:internal/modules/cjs/loader:1085
  throw err;
  ^

Error: Cannot find module '../../helpers/appProps'
Require stack:
- /Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1082:15)
    at Module._load (node:internal/modules/cjs/loader:928:27)
    at Module.require (node:internal/modules/cjs/loader:1149:19)
    at require (node:internal/modules/helpers:121:18)
    at Object.<anonymous> (/Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js:9:18)
    at Module._compile (node:internal/modules/cjs/loader:1267:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1321:10)
    at Module.load (node:internal/modules/cjs/loader:1125:32)
    at Module._load (node:internal/modules/cjs/loader:965:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/d072895/go/src/github.com/sapcc/andromeda/web/esbuild.config.js'
  ]
}

fixed by copying appProps.js from juno helpers/appProps to base directory and adapting the path in esbuild.js to const appProps = require("./appProps")

npm serve always deletes contents of public/ folder

esbuild.config.js defines following lines:

  // delete build folder and re-create it as an empty folder
  await fs.rm(outdir, { recursive: true, force: true })
  await fs.mkdir(outdir, { recursive: true })

When using serve, it's deleting the contents of public which is not really nice since it should host the index.html and favicons.

edda commented 1 year ago

Regarding the last issue (public/ folder gets emptied). This was a regression in the esbuild.config of the example app. It's fixed in this commit: fcf3da5