Niedzielski has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/391895 )

Change subject: Chore: refactor manifest according to current styles
......................................................................

Chore: refactor manifest according to current styles

Refactor assets/manifest to remove named parameters and prefer function
keyword for top level functions.

Bug: T180623

Change-Id: I34a79ec778fe2ecd8ee3359b9dba9532129a7bc2
---
M src/server/assets/manifest.ts
M src/server/components/html-page.tsx
2 files changed, 23 insertions(+), 27 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/95/391895/1

diff --git a/src/server/assets/manifest.ts b/src/server/assets/manifest.ts
index 8be124a..b1097f9 100644
--- a/src/server/assets/manifest.ts
+++ b/src/server/assets/manifest.ts
@@ -3,18 +3,16 @@
 /** Manifest of filename entry points to bundled asset paths. */
 export type Manifest = Assets | string;
 
-export interface AssetParams {
-  manifest: Manifest;
-  entry: string;
-  extension: string;
-}
-
 /**
  * @return The path to the asset identified by entry and extension (e.g.,
  *         index.js); either a URL (development) or a filesystem path
  *         (production).
  */
-export const asset = ({ manifest, entry, extension }: AssetParams): string => {
+export function asset(
+  manifest: Manifest,
+  entry: string,
+  extension: string
+): string {
   if (typeof manifest === "string")
     // When the manifest is a string, it is the URL of something like
     // webpack-dev-server, so just point to there for the asset
@@ -26,7 +24,7 @@
     // If the entry is not on the asset manifest, then just point to it 
directly
     // to the static assets path (copied there as-is from src/public)
     return `/public/${entry}.${extension}`;
-};
+}
 
 // Note: scripts must be included in the correct order: runtime, vendor, index.
 // Example errors:
@@ -44,20 +42,22 @@
 //       at webpackJsonpCallback (runtime.js:26)
 //       at index.js:1
 
-export const runtime = (manifest: Manifest): string =>
-  asset({ manifest, entry: "runtime", extension: "js" });
+export function runtime(manifest: Manifest): string {
+  return asset(manifest, "runtime", "js");
+}
 
-export const vendor = (manifest: Manifest): string =>
-  asset({ manifest, entry: "vendor", extension: "js" });
+export function vendor(manifest: Manifest): string {
+  return asset(manifest, "vendor", "js");
+}
 
-export const index = (manifest: Manifest): string =>
-  asset({ manifest, entry: "index", extension: "js" });
+export function index(manifest: Manifest): string {
+  return asset(manifest, "index", "js");
+}
 
-export const scripts = (manifest: Manifest): string[] => [
-  runtime(manifest),
-  vendor(manifest),
-  index(manifest)
-];
+export function scripts(manifest: Manifest): string[] {
+  return [runtime(manifest), vendor(manifest), index(manifest)];
+}
 
-export const style = (manifest: Manifest): string =>
-  asset({ manifest, entry: "index", extension: "css" });
+export function style(manifest: Manifest): string {
+  return asset(manifest, "index", "css");
+}
diff --git a/src/server/components/html-page.tsx 
b/src/server/components/html-page.tsx
index 1f4e77c..b9962ef 100644
--- a/src/server/components/html-page.tsx
+++ b/src/server/components/html-page.tsx
@@ -16,13 +16,9 @@
   children
 }: Props): JSX.Element {
   const assets: string[] = scripts(manifest);
-  assets.push(asset({ manifest, entry: chunkName, extension: "js" }));
+  assets.push(asset(manifest, chunkName, "js"));
 
-  const favicon = asset({
-    manifest,
-    entry: "favicon/wikipedia",
-    extension: "ico"
-  });
+  const favicon = asset(manifest, "favicon/wikipedia", "ico");
 
   return (
     <html lang="en">

-- 
To view, visit https://gerrit.wikimedia.org/r/391895
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I34a79ec778fe2ecd8ee3359b9dba9532129a7bc2
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <[email protected]>
Gerrit-Reviewer: Sniedzielski <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to