From b1c4f3aec4ca2d51b0ed849914cc8fc97805740a Mon Sep 17 00:00:00 2001
From: Tim Neutkens <tim@timneutkens.nl>
Date: Mon, 1 Oct 2018 01:02:10 +0200
Subject: [PATCH] Monorepo (#5341)

- Implements Lerna
- Moves all source code into `packages/next`
- Keeps integration tests in the root directory
---
 .circleci/config.yml                          |   1 +
 .flowconfig                                   |   3 -
 .travis.yml                                   |   1 +
 appveyor.yml                                  |   1 +
 lerna.json                                    |  14 ++
 package.json                                  | 126 +++---------------
 packages/next/.flowconfig                     |   2 +
 README.md => packages/next/README.md          |   0
 app.js => packages/next/app.js                |   0
 asset.js => packages/next/asset.js            |   0
 .babelrc.js => packages/next/babel.config.js  |   0
 babel.js => packages/next/babel.js            |   0
 {bin => packages/next/bin}/next               |   0
 {bin => packages/next/bin}/next-build         |   0
 {bin => packages/next/bin}/next-dev           |   0
 {bin => packages/next/bin}/next-export        |   0
 {bin => packages/next/bin}/next-init          |   0
 {bin => packages/next/bin}/next-start         |   0
 .../babel/plugins/react-loadable-plugin.js    |   0
 .../next/build}/babel/preset.js               |   0
 {build => packages/next/build}/index.js       |   0
 {build => packages/next/build}/webpack.js     |   0
 .../webpack/loaders/emit-file-loader.js       |   0
 .../webpack/loaders/hot-self-accept-loader.js |   0
 .../webpack/loaders/next-babel-loader.js      |   0
 .../webpack/plugins/build-manifest-plugin.js  |   0
 .../webpack/plugins/chunk-names-plugin.js     |   0
 .../nextjs-require-cache-hot-reloader.js      |   0
 .../webpack/plugins/nextjs-ssr-import.js      |   0
 .../plugins/nextjs-ssr-module-cache.js        |   0
 .../webpack/plugins/pages-manifest-plugin.js  |   0
 .../build}/webpack/plugins/pages-plugin.js    |   0
 .../webpack/plugins/react-loadable-plugin.js  |   0
 .../webpack/plugins/unlink-file-plugin.js     |   0
 .../next/build}/webpack/utils.js              |   0
 client.js => packages/next/client.js          |   0
 .../client}/dev-error-overlay/eventsource.js  |   0
 .../format-webpack-messages.js                |   0
 .../dev-error-overlay/hot-dev-client.js       |   0
 .../next/client}/error-boundary.js            |   0
 .../next/client}/head-manager.js              |   0
 {client => packages/next/client}/index.js     |   0
 {client => packages/next/client}/next-dev.js  |   0
 {client => packages/next/client}/next.js      |   0
 {client => packages/next/client}/noop.js      |   0
 .../next/client}/on-demand-entries-client.js  |   0
 .../next/client}/source-map-support.js        |   0
 .../client}/webpack-hot-middleware-client.js  |   0
 config.js => packages/next/config.js          |   0
 constants.js => packages/next/constants.js    |   0
 .../next/contributing.md                      |   0
 document.js => packages/next/document.js      |   0
 dynamic.js => packages/next/dynamic.js        |   0
 error.js => packages/next/error.js            |   0
 {export => packages/next/export}/index.js     |   0
 .../npm/autodll-webpack-plugin_vx.x.x.js      |   0
 .../next/flow-typed}/npm/glob_vx.x.x.js       |   0
 .../flow-typed}/npm/loader-utils_vx.x.x.js    |   0
 .../npm/react-lifecycles-compat_vx.x.x.js     |   0
 .../next/flow-typed}/npm/source-map_vx.x.x.js |   0
 .../npm/terser-webpack-plugin_vx.x.x.js       |   0
 .../npm/uglifyjs-webpack-plugin_vx.x.x.js     |   0
 .../next/flow-typed}/npm/unfetch_vx.x.x.js    |   0
 .../flow-typed}/npm/webpack-sources_vx.x.x.js |   0
 .../next/flow-typed}/npm/webpack_vx.x.x.js    |   0
 .../next/flow-typed}/npm/webpackbar_vx.x.x.js |   0
 .../npm/write-file-webpack-plugin_vx.x.x.js   |   0
 head.js => packages/next/head.js              |   0
 {lib => packages/next/lib}/EventEmitter.js    |   0
 {lib => packages/next/lib}/app.js             |   0
 {lib => packages/next/lib}/asset.js           |   0
 {lib => packages/next/lib}/constants.js       |   0
 {lib => packages/next/lib}/dynamic.js         |   0
 {lib => packages/next/lib}/error-debug.js     |   0
 {lib => packages/next/lib}/error.js           |   0
 {lib => packages/next/lib}/head.js            |   0
 {lib => packages/next/lib}/link.js            |   0
 .../next/lib}/loadable-capture.js             |   0
 {lib => packages/next/lib}/loadable.js        |   0
 {lib => packages/next/lib}/p-queue.js         |   0
 {lib => packages/next/lib}/page-loader.js     |   0
 {lib => packages/next/lib}/promisify.js       |   0
 {lib => packages/next/lib}/router/index.js    |   0
 {lib => packages/next/lib}/router/router.js   |   0
 .../next/lib}/router/with-router.js           |   0
 {lib => packages/next/lib}/runtime-config.js  |   0
 {lib => packages/next/lib}/shallow-equals.js  |   0
 {lib => packages/next/lib}/side-effect.js     |   0
 {lib => packages/next/lib}/utils.js           |   0
 license.md => packages/next/license.md        |   0
 link.js => packages/next/link.js              |   0
 packages/next/package.json                    | 114 ++++++++++++++++
 {pages => packages/next/pages}/_app.js        |   0
 {pages => packages/next/pages}/_document.js   |   0
 {pages => packages/next/pages}/_error.js      |   0
 prefetch.js => packages/next/prefetch.js      |   0
 router.js => packages/next/router.js          |   0
 {server => packages/next/server}/config.js    |   0
 {server => packages/next/server}/document.js  |   0
 .../next/server}/hot-reloader.js              |   0
 .../server}/lib/error-overlay-middleware.js   |   0
 .../next/server}/lib/path-match.js            |   0
 .../next/server}/lib/start-server.js          |   0
 {server => packages/next/server}/lib/utils.js |   0
 .../next/server}/next-dev-server.js           |   0
 .../next/server}/next-server.js               |   0
 {server => packages/next/server}/next.js      |   0
 .../next/server}/on-demand-entry-handler.js   |   0
 {server => packages/next/server}/render.js    |   0
 {server => packages/next/server}/require.js   |   0
 {server => packages/next/server}/router.js    |   0
 {server => packages/next/server}/utils.js     |   0
 .../next/taskfile-babel.js                    |   0
 packages/next/taskfile.js                     |  68 ++++++++++
 readme.md                                     |   1 +
 taskfile.js                                   |  91 ++-----------
 test/integration/basic/test/rendering.js      |   1 -
 test/isolated/require-page.test.js            |   2 +-
 test/isolated/webpack-utils.test.js           |   2 +-
 test/lib/next-test-utils.js                   |   2 +-
 test/node_modules/next                        |   2 +-
 test/unit/EventEmitter.test.js                |   2 +-
 test/unit/getDisplayName.test.js              |   2 +-
 test/unit/loadGetInitialProps.test.js         |   2 +-
 124 files changed, 241 insertions(+), 196 deletions(-)
 delete mode 100644 .flowconfig
 create mode 100644 lerna.json
 create mode 100644 packages/next/.flowconfig
 rename README.md => packages/next/README.md (100%)
 rename app.js => packages/next/app.js (100%)
 rename asset.js => packages/next/asset.js (100%)
 rename .babelrc.js => packages/next/babel.config.js (100%)
 rename babel.js => packages/next/babel.js (100%)
 rename {bin => packages/next/bin}/next (100%)
 rename {bin => packages/next/bin}/next-build (100%)
 rename {bin => packages/next/bin}/next-dev (100%)
 rename {bin => packages/next/bin}/next-export (100%)
 rename {bin => packages/next/bin}/next-init (100%)
 rename {bin => packages/next/bin}/next-start (100%)
 rename {build => packages/next/build}/babel/plugins/react-loadable-plugin.js (100%)
 rename {build => packages/next/build}/babel/preset.js (100%)
 rename {build => packages/next/build}/index.js (100%)
 rename {build => packages/next/build}/webpack.js (100%)
 rename {build => packages/next/build}/webpack/loaders/emit-file-loader.js (100%)
 rename {build => packages/next/build}/webpack/loaders/hot-self-accept-loader.js (100%)
 rename {build => packages/next/build}/webpack/loaders/next-babel-loader.js (100%)
 rename {build => packages/next/build}/webpack/plugins/build-manifest-plugin.js (100%)
 rename {build => packages/next/build}/webpack/plugins/chunk-names-plugin.js (100%)
 rename {build => packages/next/build}/webpack/plugins/nextjs-require-cache-hot-reloader.js (100%)
 rename {build => packages/next/build}/webpack/plugins/nextjs-ssr-import.js (100%)
 rename {build => packages/next/build}/webpack/plugins/nextjs-ssr-module-cache.js (100%)
 rename {build => packages/next/build}/webpack/plugins/pages-manifest-plugin.js (100%)
 rename {build => packages/next/build}/webpack/plugins/pages-plugin.js (100%)
 rename {build => packages/next/build}/webpack/plugins/react-loadable-plugin.js (100%)
 rename {build => packages/next/build}/webpack/plugins/unlink-file-plugin.js (100%)
 rename {build => packages/next/build}/webpack/utils.js (100%)
 rename client.js => packages/next/client.js (100%)
 rename {client => packages/next/client}/dev-error-overlay/eventsource.js (100%)
 rename {client => packages/next/client}/dev-error-overlay/format-webpack-messages.js (100%)
 rename {client => packages/next/client}/dev-error-overlay/hot-dev-client.js (100%)
 rename {client => packages/next/client}/error-boundary.js (100%)
 rename {client => packages/next/client}/head-manager.js (100%)
 rename {client => packages/next/client}/index.js (100%)
 rename {client => packages/next/client}/next-dev.js (100%)
 rename {client => packages/next/client}/next.js (100%)
 rename {client => packages/next/client}/noop.js (100%)
 rename {client => packages/next/client}/on-demand-entries-client.js (100%)
 rename {client => packages/next/client}/source-map-support.js (100%)
 rename {client => packages/next/client}/webpack-hot-middleware-client.js (100%)
 rename config.js => packages/next/config.js (100%)
 rename constants.js => packages/next/constants.js (100%)
 rename contributing.md => packages/next/contributing.md (100%)
 rename document.js => packages/next/document.js (100%)
 rename dynamic.js => packages/next/dynamic.js (100%)
 rename error.js => packages/next/error.js (100%)
 rename {export => packages/next/export}/index.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/autodll-webpack-plugin_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/glob_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/loader-utils_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/react-lifecycles-compat_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/source-map_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/terser-webpack-plugin_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/uglifyjs-webpack-plugin_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/unfetch_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/webpack-sources_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/webpack_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/webpackbar_vx.x.x.js (100%)
 rename {flow-typed => packages/next/flow-typed}/npm/write-file-webpack-plugin_vx.x.x.js (100%)
 rename head.js => packages/next/head.js (100%)
 rename {lib => packages/next/lib}/EventEmitter.js (100%)
 rename {lib => packages/next/lib}/app.js (100%)
 rename {lib => packages/next/lib}/asset.js (100%)
 rename {lib => packages/next/lib}/constants.js (100%)
 rename {lib => packages/next/lib}/dynamic.js (100%)
 rename {lib => packages/next/lib}/error-debug.js (100%)
 rename {lib => packages/next/lib}/error.js (100%)
 rename {lib => packages/next/lib}/head.js (100%)
 rename {lib => packages/next/lib}/link.js (100%)
 rename {lib => packages/next/lib}/loadable-capture.js (100%)
 rename {lib => packages/next/lib}/loadable.js (100%)
 rename {lib => packages/next/lib}/p-queue.js (100%)
 rename {lib => packages/next/lib}/page-loader.js (100%)
 rename {lib => packages/next/lib}/promisify.js (100%)
 rename {lib => packages/next/lib}/router/index.js (100%)
 rename {lib => packages/next/lib}/router/router.js (100%)
 rename {lib => packages/next/lib}/router/with-router.js (100%)
 rename {lib => packages/next/lib}/runtime-config.js (100%)
 rename {lib => packages/next/lib}/shallow-equals.js (100%)
 rename {lib => packages/next/lib}/side-effect.js (100%)
 rename {lib => packages/next/lib}/utils.js (100%)
 rename license.md => packages/next/license.md (100%)
 rename link.js => packages/next/link.js (100%)
 create mode 100644 packages/next/package.json
 rename {pages => packages/next/pages}/_app.js (100%)
 rename {pages => packages/next/pages}/_document.js (100%)
 rename {pages => packages/next/pages}/_error.js (100%)
 rename prefetch.js => packages/next/prefetch.js (100%)
 rename router.js => packages/next/router.js (100%)
 rename {server => packages/next/server}/config.js (100%)
 rename {server => packages/next/server}/document.js (100%)
 rename {server => packages/next/server}/hot-reloader.js (100%)
 rename {server => packages/next/server}/lib/error-overlay-middleware.js (100%)
 rename {server => packages/next/server}/lib/path-match.js (100%)
 rename {server => packages/next/server}/lib/start-server.js (100%)
 rename {server => packages/next/server}/lib/utils.js (100%)
 rename {server => packages/next/server}/next-dev-server.js (100%)
 rename {server => packages/next/server}/next-server.js (100%)
 rename {server => packages/next/server}/next.js (100%)
 rename {server => packages/next/server}/on-demand-entry-handler.js (100%)
 rename {server => packages/next/server}/render.js (100%)
 rename {server => packages/next/server}/require.js (100%)
 rename {server => packages/next/server}/router.js (100%)
 rename {server => packages/next/server}/utils.js (100%)
 rename taskfile-babel.js => packages/next/taskfile-babel.js (100%)
 create mode 100644 packages/next/taskfile.js
 create mode 120000 readme.md

diff --git a/.circleci/config.yml b/.circleci/config.yml
index 4df303365faa..ae60df93faf9 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -7,4 +7,5 @@ jobs:
     steps:
       - checkout
       - run: yarn install
+      - run: yarn bootstrap
       - run: yarn test
diff --git a/.flowconfig b/.flowconfig
deleted file mode 100644
index 4d38b2dac476..000000000000
--- a/.flowconfig
+++ /dev/null
@@ -1,3 +0,0 @@
-[ignore]
-<PROJECT_ROOT>/examples/.*
-<PROJECT_ROOT>/.*.json
\ No newline at end of file
diff --git a/.travis.yml b/.travis.yml
index f5ca2ee83536..f67a0815a52e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,6 +20,7 @@
   before_cache: [
     "rm -rf node_modules/.cache"
   ],
+  before_script: ["npm run bootstrap"],
   after_script: ["npm run coveralls"],
   deploy: {
     provider: "npm",
diff --git a/appveyor.yml b/appveyor.yml
index 8ee5e51ef52c..1c1d32692815 100644
--- a/appveyor.yml
+++ b/appveyor.yml
@@ -10,6 +10,7 @@ install:
   - ps: Install-Product node $env:nodejs_version x64
   # install modules
   - npm install
+  - npm run bootstrap
 
 # Post-install test scripts.
 test_script:
diff --git a/lerna.json b/lerna.json
new file mode 100644
index 000000000000..825d36ff38b3
--- /dev/null
+++ b/lerna.json
@@ -0,0 +1,14 @@
+{
+  "npmClient": "yarn",
+  "useWorkspaces": true,
+  "packages": [
+    "packages/*"
+  ],
+  "command": {
+    "publish": {
+      "allowBranch": "canary",
+      "registry": "https://registry.npmjs.org/"
+    }
+  },
+  "version": "0.0.0"
+}
diff --git a/package.json b/package.json
index fc3cc0788198..be9e93f688fa 100644
--- a/package.json
+++ b/package.json
@@ -1,50 +1,26 @@
 {
-  "name": "next",
-  "version": "7.0.1",
-  "description": "Minimalistic framework for server-rendered React applications",
-  "main": "./dist/server/next.js",
-  "license": "MIT",
-  "repository": "zeit/next.js",
-  "bugs": "https://github.com/zeit/next.js/issues",
-  "homepage": "https://github.com/zeit/next.js",
-  "files": [
-    "dist",
-    "app.js",
-    "asset.js",
-    "babel.js",
-    "client.js",
-    "config.js",
-    "constants.js",
-    "document.js",
-    "dynamic.js",
-    "error.js",
-    "head.js",
-    "link.js",
-    "prefetch.js",
-    "router.js"
+  "name": "nextjs-project",
+  "private": true,
+  "workspaces": [
+    "packages/*"
   ],
-  "bin": {
-    "next": "./dist/bin/next"
-  },
   "scripts": {
-    "build": "taskr",
-    "release": "taskr release",
+    "lerna": "lerna",
+    "bootstrap": "lerna bootstrap",
     "pretestonly": "taskr pretest",
     "testonly": "cross-env NODE_PATH=test/lib jest \\.test.js",
     "posttestonly": "taskr posttest",
     "testall": "npm run testonly -- --coverage --forceExit --runInBand --verbose --bail",
-    "pretest": "npm run lint && npm run flow",
+    "pretest": "npm run lint",
     "test": "cross-env npm run testall || npm run testall",
     "coveralls": "nyc --instrument=false --source-map=false report --temp-directory=./coverage --reporter=text-lcov | coveralls",
-    "flow": "flow check",
-    "lint": "standard 'bin/*' 'client/**/*.js' 'examples/**/*.js' 'lib/**/*.js' 'pages/**/*.js' 'server/**/*.js' 'build/**/*.js' 'test/**/*.js'",
-    "prepublish": "npm run release",
-    "precommit": "lint-staged"
+    "precommit": "lint-staged",
+    "lint": "lerna run lint",
+    "prepublish": "lerna run prepublish"
   },
-  "taskr": {
-    "requires": [
-      "./taskfile-babel.js"
-    ]
+  "lint-staged": {
+    "*.js": "standard",
+    "bin/*": "standard"
   },
   "standard": {
     "parser": "babel-eslint",
@@ -55,73 +31,22 @@
       "**/examples/with-mobx/**"
     ]
   },
-  "lint-staged": {
-    "*.js": "standard",
-    "bin/*": "standard"
+  "jest": {
+    "testEnvironment": "node",
+    "roots": [
+      "test/"
+    ]
   },
-  "dependencies": {
-    "@babel/core": "7.0.0",
-    "@babel/plugin-proposal-class-properties": "7.0.0",
+  "devDependencies": {
     "@babel/plugin-proposal-object-rest-spread": "7.0.0",
-    "@babel/plugin-syntax-dynamic-import": "7.0.0",
-    "@babel/plugin-transform-runtime": "7.0.0",
-    "@babel/preset-env": "7.0.0",
     "@babel/preset-react": "7.0.0",
-    "@babel/runtime": "7.0.0",
-    "@babel/runtime-corejs2": "7.0.0",
-    "@babel/template": "7.0.0",
-    "ansi-html": "0.0.7",
-    "autodll-webpack-plugin": "0.4.2",
-    "babel-core": "7.0.0-bridge.0",
-    "babel-loader": "8.0.2",
-    "babel-plugin-react-require": "3.0.0",
-    "babel-plugin-transform-react-remove-prop-types": "0.4.15",
-    "case-sensitive-paths-webpack-plugin": "2.1.2",
-    "cross-spawn": "5.1.0",
-    "del": "3.0.0",
-    "etag": "1.8.1",
-    "event-source-polyfill": "0.0.12",
-    "find-up": "2.1.0",
-    "fresh": "0.5.2",
-    "friendly-errors-webpack-plugin": "1.7.0",
-    "glob": "7.1.2",
-    "hoist-non-react-statics": "2.5.5",
-    "htmlescape": "1.1.1",
-    "http-errors": "1.6.2",
-    "http-status": "1.0.1",
-    "launch-editor": "2.2.1",
-    "loader-utils": "1.1.0",
-    "minimist": "1.2.0",
-    "mkdirp-then": "1.2.0",
-    "nanoid": "1.2.1",
-    "path-to-regexp": "2.1.0",
-    "prop-types": "15.6.2",
-    "prop-types-exact": "1.2.0",
-    "react-error-overlay": "4.0.0",
-    "recursive-copy": "2.0.6",
-    "resolve": "1.5.0",
-    "send": "0.16.1",
-    "source-map": "0.5.7",
-    "strip-ansi": "3.0.1",
-    "styled-jsx": "3.1.0",
-    "terser-webpack-plugin": "1.0.2",
-    "unfetch": "3.0.0",
-    "url": "0.11.0",
-    "webpack": "4.20.2",
-    "webpack-dev-middleware": "3.4.0",
-    "webpack-hot-middleware": "2.22.3",
-    "webpack-sources": "1.2.0",
-    "webpackbar": "2.6.3",
-    "write-file-webpack-plugin": "4.3.2"
-  },
-  "devDependencies": {
-    "@babel/preset-flow": "7.0.0",
     "@taskr/clear": "1.1.0",
     "@taskr/esnext": "1.1.0",
     "@taskr/watch": "1.1.0",
     "@zeit/next-css": "0.2.1-canary.1",
     "@zeit/next-sass": "0.2.1-canary.1",
     "@zeit/next-typescript": "1.1.0",
+    "babel-core": "7.0.0-bridge.0",
     "babel-eslint": "9.0.0",
     "babel-jest": "23.4.2",
     "babel-plugin-transform-define": "1.3.0",
@@ -138,6 +63,7 @@
     "get-port": "3.2.0",
     "husky": "0.14.3",
     "jest-cli": "21.2.0",
+    "lerna": "^3.4.0",
     "lint-staged": "4.2.3",
     "micro": "9.1.0",
     "mkdirp": "0.5.1",
@@ -151,15 +77,5 @@
     "standard": "11.0.1",
     "taskr": "1.1.0",
     "wd": "1.10.3"
-  },
-  "peerDependencies": {
-    "react": "^16.0.0",
-    "react-dom": "^16.0.0"
-  },
-  "jest": {
-    "testEnvironment": "node",
-    "roots": [
-      "test/"
-    ]
   }
 }
diff --git a/packages/next/.flowconfig b/packages/next/.flowconfig
new file mode 100644
index 000000000000..5183c2e19e31
--- /dev/null
+++ b/packages/next/.flowconfig
@@ -0,0 +1,2 @@
+[ignore]
+<PROJECT_ROOT>/.*.json
\ No newline at end of file
diff --git a/README.md b/packages/next/README.md
similarity index 100%
rename from README.md
rename to packages/next/README.md
diff --git a/app.js b/packages/next/app.js
similarity index 100%
rename from app.js
rename to packages/next/app.js
diff --git a/asset.js b/packages/next/asset.js
similarity index 100%
rename from asset.js
rename to packages/next/asset.js
diff --git a/.babelrc.js b/packages/next/babel.config.js
similarity index 100%
rename from .babelrc.js
rename to packages/next/babel.config.js
diff --git a/babel.js b/packages/next/babel.js
similarity index 100%
rename from babel.js
rename to packages/next/babel.js
diff --git a/bin/next b/packages/next/bin/next
similarity index 100%
rename from bin/next
rename to packages/next/bin/next
diff --git a/bin/next-build b/packages/next/bin/next-build
similarity index 100%
rename from bin/next-build
rename to packages/next/bin/next-build
diff --git a/bin/next-dev b/packages/next/bin/next-dev
similarity index 100%
rename from bin/next-dev
rename to packages/next/bin/next-dev
diff --git a/bin/next-export b/packages/next/bin/next-export
similarity index 100%
rename from bin/next-export
rename to packages/next/bin/next-export
diff --git a/bin/next-init b/packages/next/bin/next-init
similarity index 100%
rename from bin/next-init
rename to packages/next/bin/next-init
diff --git a/bin/next-start b/packages/next/bin/next-start
similarity index 100%
rename from bin/next-start
rename to packages/next/bin/next-start
diff --git a/build/babel/plugins/react-loadable-plugin.js b/packages/next/build/babel/plugins/react-loadable-plugin.js
similarity index 100%
rename from build/babel/plugins/react-loadable-plugin.js
rename to packages/next/build/babel/plugins/react-loadable-plugin.js
diff --git a/build/babel/preset.js b/packages/next/build/babel/preset.js
similarity index 100%
rename from build/babel/preset.js
rename to packages/next/build/babel/preset.js
diff --git a/build/index.js b/packages/next/build/index.js
similarity index 100%
rename from build/index.js
rename to packages/next/build/index.js
diff --git a/build/webpack.js b/packages/next/build/webpack.js
similarity index 100%
rename from build/webpack.js
rename to packages/next/build/webpack.js
diff --git a/build/webpack/loaders/emit-file-loader.js b/packages/next/build/webpack/loaders/emit-file-loader.js
similarity index 100%
rename from build/webpack/loaders/emit-file-loader.js
rename to packages/next/build/webpack/loaders/emit-file-loader.js
diff --git a/build/webpack/loaders/hot-self-accept-loader.js b/packages/next/build/webpack/loaders/hot-self-accept-loader.js
similarity index 100%
rename from build/webpack/loaders/hot-self-accept-loader.js
rename to packages/next/build/webpack/loaders/hot-self-accept-loader.js
diff --git a/build/webpack/loaders/next-babel-loader.js b/packages/next/build/webpack/loaders/next-babel-loader.js
similarity index 100%
rename from build/webpack/loaders/next-babel-loader.js
rename to packages/next/build/webpack/loaders/next-babel-loader.js
diff --git a/build/webpack/plugins/build-manifest-plugin.js b/packages/next/build/webpack/plugins/build-manifest-plugin.js
similarity index 100%
rename from build/webpack/plugins/build-manifest-plugin.js
rename to packages/next/build/webpack/plugins/build-manifest-plugin.js
diff --git a/build/webpack/plugins/chunk-names-plugin.js b/packages/next/build/webpack/plugins/chunk-names-plugin.js
similarity index 100%
rename from build/webpack/plugins/chunk-names-plugin.js
rename to packages/next/build/webpack/plugins/chunk-names-plugin.js
diff --git a/build/webpack/plugins/nextjs-require-cache-hot-reloader.js b/packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
similarity index 100%
rename from build/webpack/plugins/nextjs-require-cache-hot-reloader.js
rename to packages/next/build/webpack/plugins/nextjs-require-cache-hot-reloader.js
diff --git a/build/webpack/plugins/nextjs-ssr-import.js b/packages/next/build/webpack/plugins/nextjs-ssr-import.js
similarity index 100%
rename from build/webpack/plugins/nextjs-ssr-import.js
rename to packages/next/build/webpack/plugins/nextjs-ssr-import.js
diff --git a/build/webpack/plugins/nextjs-ssr-module-cache.js b/packages/next/build/webpack/plugins/nextjs-ssr-module-cache.js
similarity index 100%
rename from build/webpack/plugins/nextjs-ssr-module-cache.js
rename to packages/next/build/webpack/plugins/nextjs-ssr-module-cache.js
diff --git a/build/webpack/plugins/pages-manifest-plugin.js b/packages/next/build/webpack/plugins/pages-manifest-plugin.js
similarity index 100%
rename from build/webpack/plugins/pages-manifest-plugin.js
rename to packages/next/build/webpack/plugins/pages-manifest-plugin.js
diff --git a/build/webpack/plugins/pages-plugin.js b/packages/next/build/webpack/plugins/pages-plugin.js
similarity index 100%
rename from build/webpack/plugins/pages-plugin.js
rename to packages/next/build/webpack/plugins/pages-plugin.js
diff --git a/build/webpack/plugins/react-loadable-plugin.js b/packages/next/build/webpack/plugins/react-loadable-plugin.js
similarity index 100%
rename from build/webpack/plugins/react-loadable-plugin.js
rename to packages/next/build/webpack/plugins/react-loadable-plugin.js
diff --git a/build/webpack/plugins/unlink-file-plugin.js b/packages/next/build/webpack/plugins/unlink-file-plugin.js
similarity index 100%
rename from build/webpack/plugins/unlink-file-plugin.js
rename to packages/next/build/webpack/plugins/unlink-file-plugin.js
diff --git a/build/webpack/utils.js b/packages/next/build/webpack/utils.js
similarity index 100%
rename from build/webpack/utils.js
rename to packages/next/build/webpack/utils.js
diff --git a/client.js b/packages/next/client.js
similarity index 100%
rename from client.js
rename to packages/next/client.js
diff --git a/client/dev-error-overlay/eventsource.js b/packages/next/client/dev-error-overlay/eventsource.js
similarity index 100%
rename from client/dev-error-overlay/eventsource.js
rename to packages/next/client/dev-error-overlay/eventsource.js
diff --git a/client/dev-error-overlay/format-webpack-messages.js b/packages/next/client/dev-error-overlay/format-webpack-messages.js
similarity index 100%
rename from client/dev-error-overlay/format-webpack-messages.js
rename to packages/next/client/dev-error-overlay/format-webpack-messages.js
diff --git a/client/dev-error-overlay/hot-dev-client.js b/packages/next/client/dev-error-overlay/hot-dev-client.js
similarity index 100%
rename from client/dev-error-overlay/hot-dev-client.js
rename to packages/next/client/dev-error-overlay/hot-dev-client.js
diff --git a/client/error-boundary.js b/packages/next/client/error-boundary.js
similarity index 100%
rename from client/error-boundary.js
rename to packages/next/client/error-boundary.js
diff --git a/client/head-manager.js b/packages/next/client/head-manager.js
similarity index 100%
rename from client/head-manager.js
rename to packages/next/client/head-manager.js
diff --git a/client/index.js b/packages/next/client/index.js
similarity index 100%
rename from client/index.js
rename to packages/next/client/index.js
diff --git a/client/next-dev.js b/packages/next/client/next-dev.js
similarity index 100%
rename from client/next-dev.js
rename to packages/next/client/next-dev.js
diff --git a/client/next.js b/packages/next/client/next.js
similarity index 100%
rename from client/next.js
rename to packages/next/client/next.js
diff --git a/client/noop.js b/packages/next/client/noop.js
similarity index 100%
rename from client/noop.js
rename to packages/next/client/noop.js
diff --git a/client/on-demand-entries-client.js b/packages/next/client/on-demand-entries-client.js
similarity index 100%
rename from client/on-demand-entries-client.js
rename to packages/next/client/on-demand-entries-client.js
diff --git a/client/source-map-support.js b/packages/next/client/source-map-support.js
similarity index 100%
rename from client/source-map-support.js
rename to packages/next/client/source-map-support.js
diff --git a/client/webpack-hot-middleware-client.js b/packages/next/client/webpack-hot-middleware-client.js
similarity index 100%
rename from client/webpack-hot-middleware-client.js
rename to packages/next/client/webpack-hot-middleware-client.js
diff --git a/config.js b/packages/next/config.js
similarity index 100%
rename from config.js
rename to packages/next/config.js
diff --git a/constants.js b/packages/next/constants.js
similarity index 100%
rename from constants.js
rename to packages/next/constants.js
diff --git a/contributing.md b/packages/next/contributing.md
similarity index 100%
rename from contributing.md
rename to packages/next/contributing.md
diff --git a/document.js b/packages/next/document.js
similarity index 100%
rename from document.js
rename to packages/next/document.js
diff --git a/dynamic.js b/packages/next/dynamic.js
similarity index 100%
rename from dynamic.js
rename to packages/next/dynamic.js
diff --git a/error.js b/packages/next/error.js
similarity index 100%
rename from error.js
rename to packages/next/error.js
diff --git a/export/index.js b/packages/next/export/index.js
similarity index 100%
rename from export/index.js
rename to packages/next/export/index.js
diff --git a/flow-typed/npm/autodll-webpack-plugin_vx.x.x.js b/packages/next/flow-typed/npm/autodll-webpack-plugin_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/autodll-webpack-plugin_vx.x.x.js
rename to packages/next/flow-typed/npm/autodll-webpack-plugin_vx.x.x.js
diff --git a/flow-typed/npm/glob_vx.x.x.js b/packages/next/flow-typed/npm/glob_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/glob_vx.x.x.js
rename to packages/next/flow-typed/npm/glob_vx.x.x.js
diff --git a/flow-typed/npm/loader-utils_vx.x.x.js b/packages/next/flow-typed/npm/loader-utils_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/loader-utils_vx.x.x.js
rename to packages/next/flow-typed/npm/loader-utils_vx.x.x.js
diff --git a/flow-typed/npm/react-lifecycles-compat_vx.x.x.js b/packages/next/flow-typed/npm/react-lifecycles-compat_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/react-lifecycles-compat_vx.x.x.js
rename to packages/next/flow-typed/npm/react-lifecycles-compat_vx.x.x.js
diff --git a/flow-typed/npm/source-map_vx.x.x.js b/packages/next/flow-typed/npm/source-map_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/source-map_vx.x.x.js
rename to packages/next/flow-typed/npm/source-map_vx.x.x.js
diff --git a/flow-typed/npm/terser-webpack-plugin_vx.x.x.js b/packages/next/flow-typed/npm/terser-webpack-plugin_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/terser-webpack-plugin_vx.x.x.js
rename to packages/next/flow-typed/npm/terser-webpack-plugin_vx.x.x.js
diff --git a/flow-typed/npm/uglifyjs-webpack-plugin_vx.x.x.js b/packages/next/flow-typed/npm/uglifyjs-webpack-plugin_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/uglifyjs-webpack-plugin_vx.x.x.js
rename to packages/next/flow-typed/npm/uglifyjs-webpack-plugin_vx.x.x.js
diff --git a/flow-typed/npm/unfetch_vx.x.x.js b/packages/next/flow-typed/npm/unfetch_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/unfetch_vx.x.x.js
rename to packages/next/flow-typed/npm/unfetch_vx.x.x.js
diff --git a/flow-typed/npm/webpack-sources_vx.x.x.js b/packages/next/flow-typed/npm/webpack-sources_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/webpack-sources_vx.x.x.js
rename to packages/next/flow-typed/npm/webpack-sources_vx.x.x.js
diff --git a/flow-typed/npm/webpack_vx.x.x.js b/packages/next/flow-typed/npm/webpack_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/webpack_vx.x.x.js
rename to packages/next/flow-typed/npm/webpack_vx.x.x.js
diff --git a/flow-typed/npm/webpackbar_vx.x.x.js b/packages/next/flow-typed/npm/webpackbar_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/webpackbar_vx.x.x.js
rename to packages/next/flow-typed/npm/webpackbar_vx.x.x.js
diff --git a/flow-typed/npm/write-file-webpack-plugin_vx.x.x.js b/packages/next/flow-typed/npm/write-file-webpack-plugin_vx.x.x.js
similarity index 100%
rename from flow-typed/npm/write-file-webpack-plugin_vx.x.x.js
rename to packages/next/flow-typed/npm/write-file-webpack-plugin_vx.x.x.js
diff --git a/head.js b/packages/next/head.js
similarity index 100%
rename from head.js
rename to packages/next/head.js
diff --git a/lib/EventEmitter.js b/packages/next/lib/EventEmitter.js
similarity index 100%
rename from lib/EventEmitter.js
rename to packages/next/lib/EventEmitter.js
diff --git a/lib/app.js b/packages/next/lib/app.js
similarity index 100%
rename from lib/app.js
rename to packages/next/lib/app.js
diff --git a/lib/asset.js b/packages/next/lib/asset.js
similarity index 100%
rename from lib/asset.js
rename to packages/next/lib/asset.js
diff --git a/lib/constants.js b/packages/next/lib/constants.js
similarity index 100%
rename from lib/constants.js
rename to packages/next/lib/constants.js
diff --git a/lib/dynamic.js b/packages/next/lib/dynamic.js
similarity index 100%
rename from lib/dynamic.js
rename to packages/next/lib/dynamic.js
diff --git a/lib/error-debug.js b/packages/next/lib/error-debug.js
similarity index 100%
rename from lib/error-debug.js
rename to packages/next/lib/error-debug.js
diff --git a/lib/error.js b/packages/next/lib/error.js
similarity index 100%
rename from lib/error.js
rename to packages/next/lib/error.js
diff --git a/lib/head.js b/packages/next/lib/head.js
similarity index 100%
rename from lib/head.js
rename to packages/next/lib/head.js
diff --git a/lib/link.js b/packages/next/lib/link.js
similarity index 100%
rename from lib/link.js
rename to packages/next/lib/link.js
diff --git a/lib/loadable-capture.js b/packages/next/lib/loadable-capture.js
similarity index 100%
rename from lib/loadable-capture.js
rename to packages/next/lib/loadable-capture.js
diff --git a/lib/loadable.js b/packages/next/lib/loadable.js
similarity index 100%
rename from lib/loadable.js
rename to packages/next/lib/loadable.js
diff --git a/lib/p-queue.js b/packages/next/lib/p-queue.js
similarity index 100%
rename from lib/p-queue.js
rename to packages/next/lib/p-queue.js
diff --git a/lib/page-loader.js b/packages/next/lib/page-loader.js
similarity index 100%
rename from lib/page-loader.js
rename to packages/next/lib/page-loader.js
diff --git a/lib/promisify.js b/packages/next/lib/promisify.js
similarity index 100%
rename from lib/promisify.js
rename to packages/next/lib/promisify.js
diff --git a/lib/router/index.js b/packages/next/lib/router/index.js
similarity index 100%
rename from lib/router/index.js
rename to packages/next/lib/router/index.js
diff --git a/lib/router/router.js b/packages/next/lib/router/router.js
similarity index 100%
rename from lib/router/router.js
rename to packages/next/lib/router/router.js
diff --git a/lib/router/with-router.js b/packages/next/lib/router/with-router.js
similarity index 100%
rename from lib/router/with-router.js
rename to packages/next/lib/router/with-router.js
diff --git a/lib/runtime-config.js b/packages/next/lib/runtime-config.js
similarity index 100%
rename from lib/runtime-config.js
rename to packages/next/lib/runtime-config.js
diff --git a/lib/shallow-equals.js b/packages/next/lib/shallow-equals.js
similarity index 100%
rename from lib/shallow-equals.js
rename to packages/next/lib/shallow-equals.js
diff --git a/lib/side-effect.js b/packages/next/lib/side-effect.js
similarity index 100%
rename from lib/side-effect.js
rename to packages/next/lib/side-effect.js
diff --git a/lib/utils.js b/packages/next/lib/utils.js
similarity index 100%
rename from lib/utils.js
rename to packages/next/lib/utils.js
diff --git a/license.md b/packages/next/license.md
similarity index 100%
rename from license.md
rename to packages/next/license.md
diff --git a/link.js b/packages/next/link.js
similarity index 100%
rename from link.js
rename to packages/next/link.js
diff --git a/packages/next/package.json b/packages/next/package.json
new file mode 100644
index 000000000000..420af47aa582
--- /dev/null
+++ b/packages/next/package.json
@@ -0,0 +1,114 @@
+{
+  "name": "next",
+  "version": "7.0.1",
+  "description": "Minimalistic framework for server-rendered React applications",
+  "main": "./dist/server/next.js",
+  "license": "MIT",
+  "repository": "zeit/next.js",
+  "bugs": "https://github.com/zeit/next.js/issues",
+  "homepage": "https://github.com/zeit/next.js",
+  "files": [
+    "dist",
+    "app.js",
+    "asset.js",
+    "babel.js",
+    "client.js",
+    "config.js",
+    "constants.js",
+    "document.js",
+    "dynamic.js",
+    "error.js",
+    "head.js",
+    "link.js",
+    "prefetch.js",
+    "router.js"
+  ],
+  "bin": {
+    "next": "./dist/bin/next"
+  },
+  "scripts": {
+    "build": "taskr",
+    "release": "taskr release",
+    "flow": "flow check",
+    "lint": "standard 'bin/*' 'client/**/*.js' 'examples/**/*.js' 'lib/**/*.js' 'pages/**/*.js' 'server/**/*.js' 'build/**/*.js' 'test/**/*.js'",
+    "prepublish": "npm run release"
+  },
+  "taskr": {
+    "requires": [
+      "./taskfile-babel.js"
+    ]
+  },
+  "standard": {
+    "parser": "babel-eslint",
+    "ignore": [
+      "**/node_modules/**",
+      "**/examples/with-ioc/**",
+      "**/examples/with-kea/**",
+      "**/examples/with-mobx/**"
+    ]
+  },
+  "dependencies": {
+    "@babel/core": "7.1.2",
+    "@babel/plugin-proposal-class-properties": "7.1.0",
+    "@babel/plugin-proposal-object-rest-spread": "7.0.0",
+    "@babel/plugin-syntax-dynamic-import": "7.0.0",
+    "@babel/plugin-transform-runtime": "7.1.0",
+    "@babel/preset-env": "7.1.0",
+    "@babel/preset-react": "7.0.0",
+    "@babel/runtime": "7.1.2",
+    "@babel/runtime-corejs2": "7.1.2",
+    "@babel/template": "7.1.2",
+    "ansi-html": "0.0.7",
+    "autodll-webpack-plugin": "0.4.2",
+    "babel-core": "7.0.0-bridge.0",
+    "babel-loader": "8.0.2",
+    "babel-plugin-react-require": "3.0.0",
+    "babel-plugin-transform-react-remove-prop-types": "0.4.15",
+    "case-sensitive-paths-webpack-plugin": "2.1.2",
+    "cross-spawn": "5.1.0",
+    "del": "3.0.0",
+    "etag": "1.8.1",
+    "event-source-polyfill": "0.0.12",
+    "find-up": "2.1.0",
+    "fresh": "0.5.2",
+    "friendly-errors-webpack-plugin": "1.7.0",
+    "glob": "7.1.2",
+    "hoist-non-react-statics": "2.5.5",
+    "htmlescape": "1.1.1",
+    "http-errors": "1.6.2",
+    "http-status": "1.0.1",
+    "launch-editor": "2.2.1",
+    "loader-utils": "1.1.0",
+    "minimist": "1.2.0",
+    "mkdirp-then": "1.2.0",
+    "nanoid": "1.2.1",
+    "path-to-regexp": "2.1.0",
+    "prop-types": "15.6.2",
+    "prop-types-exact": "1.2.0",
+    "react-error-overlay": "4.0.0",
+    "recursive-copy": "2.0.6",
+    "resolve": "1.5.0",
+    "send": "0.16.1",
+    "source-map": "0.5.7",
+    "strip-ansi": "3.0.1",
+    "styled-jsx": "3.1.0",
+    "terser-webpack-plugin": "1.0.2",
+    "unfetch": "3.0.0",
+    "url": "0.11.0",
+    "webpack": "4.20.2",
+    "webpack-dev-middleware": "3.4.0",
+    "webpack-hot-middleware": "2.22.3",
+    "webpack-sources": "1.2.0",
+    "webpackbar": "2.6.3",
+    "write-file-webpack-plugin": "4.3.2"
+  },
+  "peerDependencies": {
+    "react": "^16.0.0",
+    "react-dom": "^16.0.0"
+  },
+  "devDependencies": {
+    "@babel/preset-flow": "7.0.0",
+    "@taskr/clear": "1.1.0",
+    "@taskr/watch": "1.1.0"
+  }
+}
diff --git a/pages/_app.js b/packages/next/pages/_app.js
similarity index 100%
rename from pages/_app.js
rename to packages/next/pages/_app.js
diff --git a/pages/_document.js b/packages/next/pages/_document.js
similarity index 100%
rename from pages/_document.js
rename to packages/next/pages/_document.js
diff --git a/pages/_error.js b/packages/next/pages/_error.js
similarity index 100%
rename from pages/_error.js
rename to packages/next/pages/_error.js
diff --git a/prefetch.js b/packages/next/prefetch.js
similarity index 100%
rename from prefetch.js
rename to packages/next/prefetch.js
diff --git a/router.js b/packages/next/router.js
similarity index 100%
rename from router.js
rename to packages/next/router.js
diff --git a/server/config.js b/packages/next/server/config.js
similarity index 100%
rename from server/config.js
rename to packages/next/server/config.js
diff --git a/server/document.js b/packages/next/server/document.js
similarity index 100%
rename from server/document.js
rename to packages/next/server/document.js
diff --git a/server/hot-reloader.js b/packages/next/server/hot-reloader.js
similarity index 100%
rename from server/hot-reloader.js
rename to packages/next/server/hot-reloader.js
diff --git a/server/lib/error-overlay-middleware.js b/packages/next/server/lib/error-overlay-middleware.js
similarity index 100%
rename from server/lib/error-overlay-middleware.js
rename to packages/next/server/lib/error-overlay-middleware.js
diff --git a/server/lib/path-match.js b/packages/next/server/lib/path-match.js
similarity index 100%
rename from server/lib/path-match.js
rename to packages/next/server/lib/path-match.js
diff --git a/server/lib/start-server.js b/packages/next/server/lib/start-server.js
similarity index 100%
rename from server/lib/start-server.js
rename to packages/next/server/lib/start-server.js
diff --git a/server/lib/utils.js b/packages/next/server/lib/utils.js
similarity index 100%
rename from server/lib/utils.js
rename to packages/next/server/lib/utils.js
diff --git a/server/next-dev-server.js b/packages/next/server/next-dev-server.js
similarity index 100%
rename from server/next-dev-server.js
rename to packages/next/server/next-dev-server.js
diff --git a/server/next-server.js b/packages/next/server/next-server.js
similarity index 100%
rename from server/next-server.js
rename to packages/next/server/next-server.js
diff --git a/server/next.js b/packages/next/server/next.js
similarity index 100%
rename from server/next.js
rename to packages/next/server/next.js
diff --git a/server/on-demand-entry-handler.js b/packages/next/server/on-demand-entry-handler.js
similarity index 100%
rename from server/on-demand-entry-handler.js
rename to packages/next/server/on-demand-entry-handler.js
diff --git a/server/render.js b/packages/next/server/render.js
similarity index 100%
rename from server/render.js
rename to packages/next/server/render.js
diff --git a/server/require.js b/packages/next/server/require.js
similarity index 100%
rename from server/require.js
rename to packages/next/server/require.js
diff --git a/server/router.js b/packages/next/server/router.js
similarity index 100%
rename from server/router.js
rename to packages/next/server/router.js
diff --git a/server/utils.js b/packages/next/server/utils.js
similarity index 100%
rename from server/utils.js
rename to packages/next/server/utils.js
diff --git a/taskfile-babel.js b/packages/next/taskfile-babel.js
similarity index 100%
rename from taskfile-babel.js
rename to packages/next/taskfile-babel.js
diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js
new file mode 100644
index 000000000000..c97c4b5d6339
--- /dev/null
+++ b/packages/next/taskfile.js
@@ -0,0 +1,68 @@
+const notifier = require('node-notifier')
+
+export async function compile (task) {
+  await task.parallel(['bin', 'server', 'nextbuild', 'nextbuildstatic', 'lib', 'client'])
+}
+
+export async function bin (task, opts) {
+  await task.source(opts.src || 'bin/*').babel().target('dist/bin', {mode: '0755'})
+  notify('Compiled binaries')
+}
+
+export async function lib (task, opts) {
+  await task.source(opts.src || 'lib/**/*.js').babel().target('dist/lib')
+  notify('Compiled lib files')
+}
+
+export async function server (task, opts) {
+  await task.source(opts.src || 'server/**/*.js').babel().target('dist/server')
+  notify('Compiled server files')
+}
+
+export async function nextbuild (task, opts) {
+  await task.source(opts.src || 'build/**/*.js').babel().target('dist/build')
+  notify('Compiled build files')
+}
+
+export async function client (task, opts) {
+  await task.source(opts.src || 'client/**/*.js').babel().target('dist/client')
+  notify('Compiled client files')
+}
+
+// export is a reserved keyword for functions
+export async function nextbuildstatic (task, opts) {
+  await task.source(opts.src || 'export/**/*.js').babel().target('dist/export')
+  notify('Compiled export files')
+}
+
+export async function copy (task) {
+  await task.source('pages/**/*.js').target('dist/pages')
+}
+
+export async function build (task) {
+  await task.serial(['copy', 'compile'])
+}
+
+export default async function (task) {
+  await task.start('build')
+  await task.watch('bin/*', 'bin')
+  await task.watch('pages/**/*.js', 'copy')
+  await task.watch('server/**/*.js', 'server')
+  await task.watch('build/**/*.js', 'nextbuild')
+  await task.watch('export/**/*.js', 'nextexport')
+  await task.watch('client/**/*.js', 'client')
+  await task.watch('lib/**/*.js', 'lib')
+}
+
+export async function release (task) {
+  await task.clear('dist').start('build')
+}
+
+// notification helper
+function notify (msg) {
+  return notifier.notify({
+    title: '▲ Next',
+    message: msg,
+    icon: false
+  })
+}
diff --git a/readme.md b/readme.md
new file mode 120000
index 000000000000..29e4f3032d3d
--- /dev/null
+++ b/readme.md
@@ -0,0 +1 @@
+packages/next/README.md
\ No newline at end of file
diff --git a/taskfile.js b/taskfile.js
index 135c4aac4013..b6ffaf2e9edd 100644
--- a/taskfile.js
+++ b/taskfile.js
@@ -1,82 +1,22 @@
-const notifier = require('node-notifier')
+const isWindows = /^win/.test(process.platform)
 const childProcess = require('child_process')
 const rimraf = require('rimraf')
 const mkdirp = require('mkdirp')
-const isWindows = /^win/.test(process.platform)
-
-export async function compile (task) {
-  await task.parallel(['bin', 'server', 'nextbuild', 'nextbuildstatic', 'lib', 'client'])
-}
-
-export async function bin (task, opts) {
-  await task.source(opts.src || 'bin/*').babel().target('dist/bin', {mode: '0755'})
-  notify('Compiled binaries')
-}
-
-export async function lib (task, opts) {
-  await task.source(opts.src || 'lib/**/*.js').babel().target('dist/lib')
-  notify('Compiled lib files')
-}
-
-export async function server (task, opts) {
-  await task.source(opts.src || 'server/**/*.js').babel().target('dist/server')
-  notify('Compiled server files')
-}
-
-export async function nextbuild (task, opts) {
-  await task.source(opts.src || 'build/**/*.js').babel().target('dist/build')
-  notify('Compiled build files')
-}
-
-export async function client (task, opts) {
-  await task.source(opts.src || 'client/**/*.js').babel().target('dist/client')
-  notify('Compiled client files')
-}
-
-// export is a reserved keyword for functions
-export async function nextbuildstatic (task, opts) {
-  await task.source(opts.src || 'export/**/*.js').babel().target('dist/export')
-  notify('Compiled export files')
-}
 
-// Create node_modules/next for the use of test apps
-export async function symlinkNextForTesting () {
+export async function pretest (task) {
+  // Create node_modules/next for the use of test apps
   rimraf.sync('test/node_modules/next')
   mkdirp.sync('test/node_modules')
 
-  const symlinkCommand = isWindows ? 'mklink /D "next" "..\\..\\"' : 'ln -s ../../ next'
-  childProcess.execSync(symlinkCommand, { cwd: 'test/node_modules' })
-}
-
-export async function copy (task) {
-  await task.source('pages/**/*.js').target('dist/pages')
-}
-
-export async function build (task) {
-  await task.serial(['symlinkNextForTesting', 'copy', 'compile'])
-}
-
-export default async function (task) {
-  await task.start('build')
-  await task.watch('bin/*', 'bin')
-  await task.watch('pages/**/*.js', 'copy')
-  await task.watch('server/**/*.js', 'server')
-  await task.watch('build/**/*.js', 'nextbuild')
-  await task.watch('export/**/*.js', 'nextexport')
-  await task.watch('client/**/*.js', 'client')
-  await task.watch('lib/**/*.js', 'lib')
-}
-
-export async function release (task) {
-  await task.clear('dist').start('build')
-}
-
-// We run following task inside a NPM script chain and it runs chromedriver
-// inside a child process tree.
-// Even though we kill this task's process, chromedriver exists throughout
-// the lifetime of the original npm script.
+  if (isWindows) {
+    const symlinkCommand = 'mklink /D "next" "..\\..\\packages\\next"'
+    childProcess.execSync(symlinkCommand, { cwd: 'test/node_modules' })
+  }
 
-export async function pretest (task) {
+  // We run following task inside a NPM script chain and it runs chromedriver
+  // inside a child process tree.
+  // Even though we kill this task's process, chromedriver exists throughout
+  // the lifetime of the original npm script.
   // Start chromedriver
   const processName = isWindows ? 'chromedriver.cmd' : 'chromedriver'
   childProcess.spawn(processName, { stdio: 'inherit' })
@@ -93,12 +33,3 @@ export async function posttest (task) {
     // Do nothing
   }
 }
-
-// notification helper
-function notify (msg) {
-  return notifier.notify({
-    title: '▲ Next',
-    message: msg,
-    icon: false
-  })
-}
diff --git a/test/integration/basic/test/rendering.js b/test/integration/basic/test/rendering.js
index 8ad9a85b491b..8bd8292d8def 100644
--- a/test/integration/basic/test/rendering.js
+++ b/test/integration/basic/test/rendering.js
@@ -173,7 +173,6 @@ export default function ({ app }, suiteName, render, fetch, appPort) {
       await fetch('/dynamic/ssr')
 
       const buildManifest = require(join('../.next', BUILD_MANIFEST))
-      console.log(buildManifest)
       const reactLoadableManifest = require(join('../.next', REACT_LOADABLE_MANIFEST))
       const resources = []
 
diff --git a/test/isolated/require-page.test.js b/test/isolated/require-page.test.js
index 839479acb073..e25481f63fbc 100644
--- a/test/isolated/require-page.test.js
+++ b/test/isolated/require-page.test.js
@@ -2,7 +2,7 @@
 
 import { join } from 'path'
 import {SERVER_DIRECTORY, CLIENT_STATIC_FILES_PATH} from 'next/constants'
-import requirePage, {getPagePath, normalizePagePath, pageNotFoundError} from '../../dist/server/require'
+import requirePage, {getPagePath, normalizePagePath, pageNotFoundError} from 'next/dist/server/require'
 
 const sep = '/'
 const distDir = join(__dirname, '_resolvedata')
diff --git a/test/isolated/webpack-utils.test.js b/test/isolated/webpack-utils.test.js
index de38f8e86688..577d1f9ec674 100644
--- a/test/isolated/webpack-utils.test.js
+++ b/test/isolated/webpack-utils.test.js
@@ -1,7 +1,7 @@
 /* global describe, it, expect */
 
 import {normalize, join} from 'path'
-import {getPageEntries, createEntry} from '../../dist/build/webpack/utils'
+import {getPageEntries, createEntry} from 'next/dist/build/webpack/utils'
 
 const buildId = 'development'
 
diff --git a/test/lib/next-test-utils.js b/test/lib/next-test-utils.js
index 6673f373a716..a30f53955732 100644
--- a/test/lib/next-test-utils.js
+++ b/test/lib/next-test-utils.js
@@ -71,7 +71,7 @@ export function findPort () {
 
 // Launch the app in dev mode.
 export function launchApp (dir, port) {
-  const cwd = path.resolve(__dirname, '../../')
+  const cwd = path.dirname(require.resolve('next/package'))
   return new Promise((resolve, reject) => {
     const instance = spawn('node', ['dist/bin/next', dir, '-p', port], { cwd })
 
diff --git a/test/node_modules/next b/test/node_modules/next
index 6581736d6238..0127bcd4e700 120000
--- a/test/node_modules/next
+++ b/test/node_modules/next
@@ -1 +1 @@
-../../
\ No newline at end of file
+../../packages/next
\ No newline at end of file
diff --git a/test/unit/EventEmitter.test.js b/test/unit/EventEmitter.test.js
index 8c04ca28cb0f..1f5646020d4a 100644
--- a/test/unit/EventEmitter.test.js
+++ b/test/unit/EventEmitter.test.js
@@ -1,5 +1,5 @@
 /* global describe, it, expect */
-import EventEmitter from '../../dist/lib/EventEmitter'
+import EventEmitter from 'next/dist/lib/EventEmitter'
 
 describe('EventEmitter', () => {
   describe('With listeners', () => {
diff --git a/test/unit/getDisplayName.test.js b/test/unit/getDisplayName.test.js
index 8181de677fca..84f6e62802df 100644
--- a/test/unit/getDisplayName.test.js
+++ b/test/unit/getDisplayName.test.js
@@ -1,6 +1,6 @@
 /* global describe, it, expect */
 import { Component } from 'react'
-import { getDisplayName } from '../../dist/lib/utils'
+import { getDisplayName } from 'next/dist/lib/utils'
 
 describe('getDisplayName', () => {
   it('gets the proper display name of a component', () => {
diff --git a/test/unit/loadGetInitialProps.test.js b/test/unit/loadGetInitialProps.test.js
index 0c3087a2f2e4..6963c78de45a 100644
--- a/test/unit/loadGetInitialProps.test.js
+++ b/test/unit/loadGetInitialProps.test.js
@@ -1,5 +1,5 @@
 /* global describe, it, expect */
-import { loadGetInitialProps } from '../../dist/lib/utils'
+import { loadGetInitialProps } from 'next/dist/lib/utils'
 
 describe('loadGetInitialProps', () => {
   it('should throw if getInitialProps is defined as an instance method', () => {
