-
Notifications
You must be signed in to change notification settings - Fork 92
Migration info v1 to v2
There are some breaking changes between v1 and v2 for lwc-services
. For new projects it's not relevant, for projects that you want to migrate you've to make some minor adjustments.
You'll see in a new created project that lwc-services
got moved to being a devDependency, as it's really only needed as that. You don't have to change that in existing projects, although you may want to.
The command lwc-services serve
has been removed.
You'll see in new projects that the serve
script in package.json
is still available, and fires up a standard Express config via node scripts/server.js
. The reason behind this change is that the previous built-in option provided some challenges in terms of customization. At the same time it's allowed to move lwc-services
from being a dependency to become a devDependency.
If you migrate from v1 to v2 you've to change the serve
script accordingly, and set up your own mechanism for serving the built output. Pro tip: copy over from a new project. ;-)
The commands lwc-services build
and lwc-services watch
have a new paramter -b
. This allows you to set which bundler you want to use. The default is webpack
, or you can use rollup
. Depending on what bundler you select during a new v2 project setup via create-lwc-app
the script commands in package.json
will be set accordingly.
If you want to play with it you can just add the new flag to your scripts in an existing v1 project. Note that the Rollup bundling process is not customizable (compared to the webpack bundling process).
In case you want to develop against a local Express server for simple API mocks etc. (if you selected that during the project setup) you'll in new projects a file src/server/api.js
(or ts
for TypesScript projects). That's also a full Express file (nothing "hidden"), so you have full control.
In case you used that before you have to migrate your configurations from the old scripts/express-dev.js
file over. Note that also the file name changed from server.js
to api.js
(to make things move obvious). Again, this should make things more obvious, and less tool-y.
Depending on your bundler selection you'll find in the scripts/
folder either a custom webpack.config.js
or a workbox.generatesw.js
. These are the external files that allow you to control the PWA configuration based on Google Workbox. Comments in the files point you to the documentation.
In lwc-services.config.js
you can configure which resources to copy over. In v2 I had to make some adjustments b/c of the Rollup support. For existing projects you've very likely to change dist/resources
to dist/
.