Jhernandez has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/372552 )
Change subject: Chore: use official typing for assets-webpack-plugin
......................................................................
Chore: use official typing for assets-webpack-plugin
Use the formal TypeScript definitions for Assets.
Change-Id: Id7bab456de79aa756f798f60d81620b8836b1883
---
M package-lock.json
M package.json
M src/server/index.ts
M src/server/templates/page.ts
4 files changed, 51 insertions(+), 12 deletions(-)
Approvals:
Jhernandez: Verified; Looks good to me, approved
diff --git a/package-lock.json b/package-lock.json
index ab4f98e..ea4b546 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4,6 +4,15 @@
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+ "@types/assets-webpack-plugin": {
+ "version": "3.5.0",
+ "resolved":
"https://registry.npmjs.org/@types/assets-webpack-plugin/-/assets-webpack-plugin-3.5.0.tgz",
+ "integrity":
"sha512-z7BHsG4oHVAvma0RXeNUSe9DKL8Bd/0PvAuf+7yybRrbJZ81zjaI6yfowCvPmyVJgRdwLKx0/Nq9iKE4X1TJIA==",
+ "dev": true,
+ "requires": {
+ "@types/webpack": "3.0.9"
+ }
+ },
"@types/express": {
"version": "4.0.36",
"resolved":
"https://registry.npmjs.org/@types/express/-/express-4.0.36.tgz",
@@ -51,6 +60,18 @@
"@types/mime": "1.3.1"
}
},
+ "@types/source-map": {
+ "version": "0.5.1",
+ "resolved":
"https://registry.npmjs.org/@types/source-map/-/source-map-0.5.1.tgz",
+ "integrity":
"sha512-/GVAjL1Y8puvZab63n8tsuBiYwZt1bApMdx58/msQ9ID5T05ov+wm/ZV1DvYC/DKKEygpTJViqQvkh5Rhrl4CA==",
+ "dev": true
+ },
+ "@types/tapable": {
+ "version": "0.2.3",
+ "resolved":
"https://registry.npmjs.org/@types/tapable/-/tapable-0.2.3.tgz",
+ "integrity": "sha1-CIiw8gzH5Y4cIqGIi06WPu+qgQo=",
+ "dev": true
+ },
"@types/touch": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/@types/touch/-/touch-3.1.0.tgz",
@@ -60,6 +81,26 @@
"@types/node": "8.0.24"
}
},
+ "@types/uglify-js": {
+ "version": "2.6.29",
+ "resolved":
"https://registry.npmjs.org/@types/uglify-js/-/uglify-js-2.6.29.tgz",
+ "integrity":
"sha512-BdFLCZW0GTl31AbqXSak8ss/MqEZ3DN2MH9rkAyGoTuzK7ifGUlX+u0nfbWeTsa7IPcZhtn8BlpYBXSV+vqGhQ==",
+ "dev": true,
+ "requires": {
+ "@types/source-map": "0.5.1"
+ }
+ },
+ "@types/webpack": {
+ "version": "3.0.9",
+ "resolved":
"https://registry.npmjs.org/@types/webpack/-/webpack-3.0.9.tgz",
+ "integrity":
"sha512-xXqusBBKbYb8fA1jtE3iO75uRW1ejqGuH93V+6fhbfNY59ndKjfhftJVxcSaYAMDjmFTRBHy82d+513JKuHD5g==",
+ "dev": true,
+ "requires": {
+ "@types/node": "8.0.24",
+ "@types/tapable": "0.2.3",
+ "@types/uglify-js": "2.6.29"
+ }
+ },
"abbrev": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.0.tgz",
diff --git a/package.json b/package.json
index a8f6077..254749e 100644
--- a/package.json
+++ b/package.json
@@ -49,6 +49,7 @@
"preact-render-to-string": "^3.6.3"
},
"devDependencies": {
+ "@types/assets-webpack-plugin": "^3.5.0",
"@types/express": "^4.0.36",
"@types/mocha": "^2.2.41",
"@types/node": "^8.0.20",
diff --git a/src/server/index.ts b/src/server/index.ts
index 7b11ee2..c7f7c69 100644
--- a/src/server/index.ts
+++ b/src/server/index.ts
@@ -2,15 +2,16 @@
import "ignore-styles";
import * as express from "express";
-import page, { AssetsManifest } from "./templates/page";
+import { Assets } from "assets-webpack-plugin";
import app from "../common/components/app";
+import page from "./templates/page";
import { render } from "preact-render-to-string";
const isProd: boolean = process.env.NODE_ENV === "production";
// The asset manifest built or the webpack-dev-server URL (which has no
// manifest).
-const assets: AssetsManifest | string = isProd
+const assets: Assets | string = isProd
? require("../../dist/public/assets-manifest.json")
: "http://localhost:8080";
diff --git a/src/server/templates/page.ts b/src/server/templates/page.ts
index 6eeb4d9..70985ec 100644
--- a/src/server/templates/page.ts
+++ b/src/server/templates/page.ts
@@ -1,8 +1,4 @@
-export interface AssetsManifest {
- [entrypoint: string]: {
- [format: string]: string
- }
-}
+import { Assets } from "assets-webpack-plugin";
export interface PageParams {
// Title of the page
@@ -10,7 +6,7 @@
// HTML to render in the body of the page
body: string,
// Manifest of filename entry points to bundled assets.
- assets: AssetsManifest | string
+ assets: Assets | string
}
/**
@@ -19,13 +15,13 @@
* filesystem path (production).
*/
const asset = (
- manifest: AssetsManifest | string,
+ assets: Assets | string,
entry: string,
extension: string
): string =>
- typeof manifest === "string"
- ? `${manifest}/${entry}.${extension}`
- : manifest[entry][extension];
+ typeof assets === "string"
+ ? `${assets}/${entry}.${extension}`
+ : assets[entry][extension];
export default function page({ title, body = "", assets }: PageParams): string
{
const script: string = asset(assets, "index", "js");
--
To view, visit https://gerrit.wikimedia.org/r/372552
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Id7bab456de79aa756f798f60d81620b8836b1883
Gerrit-PatchSet: 2
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits