Repository: vuejs/vue
Pull request: feat(vue-server-renderer): add TypeScript declarations of webpack plugins (fix #6301)

<!--
Please make sure to read the Pull Request Guidelines:
https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#pull-request-guidelines
-->

<!-- PULL REQUEST TEMPLATE -->
<!-- (Update "[ ]" to "[x]" to check a box) -->

**What kind of change does this PR introduce?** (check at least one)

- [ ] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactor
- [ ] Build-related changes
- [x] Other, please describe: Add TS declaration

**Does this PR introduce a breaking change?** (check one)

- [ ] Yes
- [x] No

If yes, please describe the impact and migration path for existing applications:

**The PR fulfills these requirements:**

- [x] It's submitted to the `dev` branch for v2.x (or to a previous version branch), _not_ the `master` branch
- [x] When resolving a specific issue, it's referenced in the PR's title (e.g. `fix #xxx[,#xxx]`, where "xxx" is the issue number)
- [x] All tests are passing: https://github.com/vuejs/vue/blob/dev/.github/CONTRIBUTING.md#development-setup
- [x] New/updated tests are included

If adding a **new feature**, the PR's description includes:
- [ ] A convincing reason for adding this feature (to avoid wasting your time, it's best to open a suggestion issue first and wait for approval before working on it)

**Other information:**

As webpack officially supports a config file written in TypeScript, I think it would make sense to have declaration files of webpack plugins.
https://webpack.js.org/configuration/configuration-languages/#typescript

fix #6301 

Changed files:
filename: packages/vue-server-renderer/client-plugin.d.ts
patch: @@ -0,0 +1,3 @@
+import { WebpackPlugin } from './types/plugin';
+declare const Plugin: WebpackPlugin;
+export = Plugin;

filename: packages/vue-server-renderer/package.json
patch: @@ -28,12 +28,13 @@
     "lodash.template": "^4.4.0",
     "lodash.uniq": "^4.5.0",
     "resolve": "^1.2.0",
-    "source-map": "0.5.6",
-    "serialize-javascript": "^1.3.0"
+    "serialize-javascript": "^1.3.0",
+    "source-map": "0.5.6"
   },
   "devDependencies": {
     "@types/node": "^7.0.22",
-    "typescript": "^2.3.3",
+    "@types/webpack": "^3.0.6",
+    "typescript": "^2.4.2",
     "vue": "file:../.."
   },
   "homepage": "https://github.com/vuejs/vue/tree/dev/packages/vue-server-renderer#readme"

filename: packages/vue-server-renderer/server-plugin.d.ts
patch: @@ -0,0 +1,3 @@
+import { WebpackPlugin } from './types/plugin';
+declare const Plugin: WebpackPlugin;
+export = Plugin;

filename: packages/vue-server-renderer/types/plugin.d.ts
patch: @@ -0,0 +1,9 @@
+import { Plugin } from 'webpack';
+
+interface WebpackPluginOptions {
+  filename?: string;
+}
+
+export interface WebpackPlugin {
+  new (options?: WebpackPluginOptions): Plugin;
+}

filename: packages/vue-server-renderer/types/test.ts
patch: @@ -1,4 +1,7 @@
 import Vue = require('vue');
+import VueSSRClientPlugin = require('../client-plugin');
+import VueSSRServerPlugin = require('../server-plugin');
+import webpack = require('webpack');
 import { readFileSync } from 'fs';
 import { createRenderer, createBundleRenderer } from '../';
 
@@ -82,3 +85,15 @@ bundleRenderer.renderToString(context, (err, html) => {
 bundleRenderer.renderToStream(context).on('data', chunk => {
   const html = chunk.toString();
 });
+
+// webpack plugins
+webpack({
+  plugins: [
+    new VueSSRClientPlugin({
+      filename: 'client-manifest.json'
+    }),
+    new VueSSRServerPlugin({
+      filename: 'server-bundle.json'
+    })
+  ]
+});