diff --git a/site/content/migration/01-migrating.md b/site/content/migration/01-migrating.md index ce1d221..883624d 100644 --- a/site/content/migration/01-migrating.md +++ b/site/content/migration/01-migrating.md @@ -4,6 +4,198 @@ title: Migrating Until we reach version 1.0, there may be occasional changes to the project structure Sapper expects. If you upgrade and Sapper sends you here, it's because it was unable to fix your project automatically. +### 0.21 to 0.22 + +Instead of importing middleware from the `sapper` package, or importing the client runtime from `sapper/runtime.js`, the app is *compiled into* the generated files: + +```diff +// src/client.js +-import { init } from 'sapper/runtime.js'; +-import { manifest } from './manifest/client.js'; ++import * as sapper from '../__sapper__/client.js'; + +-init({ ++sapper.start({ + target: document.querySelector('#sapper'), +- manifest +}); +``` + +```diff +// src/server.js +import sirv from 'sirv'; +import polka from 'polka'; +import compression from 'compression'; +-import sapper from 'sapper'; +-import { manifest } from './manifest/server.js'; ++import * as sapper from '../__sapper__/server.js'; + +const { PORT, NODE_ENV } = process.env; +const dev = NODE_ENV === 'development'; + +polka() // You can also use Express + .use( + compression({ threshold: 0 }), +- sirv('assets', { dev }), ++ sirv('static', { dev }), +- sapper({ manifest }) ++ sapper.middleware() + ) + .listen(PORT, err => { + if (err) console.log('error', err); + }); +``` + +```diff +// src/service-worker.js +-import { assets, shell, routes, timestamp } from './manifest/service-worker.js'; ++import { files, shell, routes, timestamp } from '../__sapper__/service-worker.js'; +``` + +In addition, the default build and export directories are now `__sapper__/build` and `__sapper__/export` respectively. + + +### 0.20 to 0.21 + +* The `app` directory is now `src` +* The `routes` directory is now `src/routes` +* The `assets` directory is now `static` (remember to update your `src/server.js` file to reflect this change as well) +* Instead of having three separate config files (`webpack/client.config.js`, `webpack/server.config.js` and `webpack/service-worker.config.js`), there is a single `webpack.config.js` file that exports `client`, `server` and `serviceworker` configs. + + +### 0.17 to 0.18 + +The `sapper/webpack/config.js` file (required in the `webpack/*.config.js` files) is now `sapper/config/webpack.js`. + + +### 0.14 to 0.15 + +This release changed how routing is handled, resulting in a number of changes. + +Instead of a single `App.html` component, you can place `_layout.html` components in any directory under `routes`. You should move `app/App.html` to `routes/_layout.html` and modify it like so: + +```diff +- ++ + +-