Change startupjs
and all @startupjs/*
dependencies in your package.json
to ^0.23
.
-
Update babel, metro and webpack config files:
-
Change their extensions to
.cjs
:babel.config.js
->babel.config.cjs
metro.config.js
->metro.config.cjs
webpack.server.config.js
->webpack.server.config.cjs
webpack.web.config.js
->webpack.web.config.cjs
-
change the
require
of bundler inside all of them to have an explicit.cjs
extension:require('startupjs/bundler')
->require('startupjs/bundler.cjs')
-
add
.cjs
extension to the'startupjs/babel'
preset inbabel.config.cjs
:'startupjs/babel'
->'startupjs/babel.cjs'
module.exports = { presets: [ ['startupjs/babel.cjs', { alias: {} }] ] }
-
-
Update startupjs config file:
-
Change its extension to
.cjs
:startupjs.config.js
->startupjs.config.cjs
-
Update it's
require
of config to a new CJS file:require('@startupjs/ui/config')
->require('@startupjs/ui/config-cjs/index.cjs')
-
-
Add
vite.config.cjs
file to your project root with the following content:const config = require('startupjs/bundler.cjs').viteConfig module.exports = config
-
Update server:
-
Change
server.js
to:import run from './server/index.js' run()
-
Add the following to the end of
server/index.js
:export default function run () {}
-
-
Update
package.json
.-
Add after
"name"
:"type": "module", "sideEffects": [],
-
Change
postinstall
script to:"scripts": { "postinstall": "startupjs patch-package" }
-
Change
build
script to:"scripts": { "build": "startupjs build --async" }
Note that this will start building production bundle splitting all your components into separate chunks. You have to have
http2
enabled on your load-balancer and cache all your.js
files to have this working correctly. -
Put
/* @asyncImports */
comment to the top of yourmain/pages/index.js
and to all other frontend-microservices*/pages/index.js
if you have any (likeadmin/pages/index.js
, etc.)This will transform imports in this files to be asynchronous for production. Which will greatly improve the initial loading speed.
-
Remove
postinstall-postinstall
andpatch-package
from yourdevDependencies
-
Fix
react-native-web
version in dependencies to0.12.3
:"dependencies": { "react-native-web": "0.12.3" }
-
-
Delete
patches
folder completely. -
Delete the file
clientHelpers/BASE_URL.web.js
if it exists. -
If you have
react-native.config.js
file, change its extension to.cjs
:react-native.config.js
->react-native.config.cjs
-
Change hot-reloading library on web to Fast Refresh. This simplifies the hot reloading setup and gets rid of the extra end-user dependency
@hot-loader/react-dom
. End-users must update their projects to remove the@hot-loader/react-dom
from theirpackage.json
and from theRoot/index.web.js
file.