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

Change subject: Chore: replace IgnorePlugin usage with __non_webpack_require__
......................................................................

Chore: replace IgnorePlugin usage with __non_webpack_require__

It's debatable which is a lesser evil but perhaps
__non_webpack_require__ is preferable to IgnorePlugin usage since it can
also be used to include files not present at compilation time such as
the asset manifest. This patch replaces the Domino package IgnorePlugin
with __non_webpack_require__.

Before:

ls -lh dist/public/{,**/}*.js
-rw-r--r-- 1 stephen stephen  19K Nov 14 17:22 
dist/public/index.df14bc506c6f1cedf570.js
-rw-r--r-- 1 stephen stephen  19K Nov 14 17:22 
dist/public/index.df14bc506c6f1cedf570.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:22 
dist/public/pages/about.10de8b3bffaf9334ba3a.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:22 
dist/public/pages/home.27414422b752227165a4.js
-rw-r--r-- 1 stephen stephen  401 Nov 14 17:22 
dist/public/pages/not-found.432b7d306e2ce80be9a9.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:22 
dist/public/pages/style-guide.321103ee6d3cd65b02fa.js
-rw-r--r-- 1 stephen stephen 9.4K Nov 14 17:22 
dist/public/pages/summary.7766f6de31ee569124ed.js
-rw-r--r-- 1 stephen stephen  12K Nov 14 17:22 
dist/public/pages/wiki.8efe1fe209478967f36a.js
-rw-r--r-- 1 stephen stephen 1.8K Nov 14 17:22 
dist/public/runtime.c877dfc0f29bd63f028c.js
-rw-r--r-- 1 stephen stephen 1.8K Nov 14 17:22 
dist/public/runtime.c877dfc0f29bd63f028c.js
-rw-r--r-- 1 stephen stephen  22K Nov 14 17:22 
dist/public/vendor.ddf5e72cf229878fcbb3.js
-rw-r--r-- 1 stephen stephen  22K Nov 14 17:22 
dist/public/vendor.ddf5e72cf229878fcbb3.js

After (summary is .1K less):

ls -lh dist/public/{,**/}*.js
-rw-r--r-- 1 stephen stephen  19K Nov 14 17:16 
dist/public/index.df14bc506c6f1cedf570.js
-rw-r--r-- 1 stephen stephen  19K Nov 14 17:16 
dist/public/index.df14bc506c6f1cedf570.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:16 
dist/public/pages/about.10de8b3bffaf9334ba3a.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:16 
dist/public/pages/home.27414422b752227165a4.js
-rw-r--r-- 1 stephen stephen  401 Nov 14 17:16 
dist/public/pages/not-found.432b7d306e2ce80be9a9.js
-rw-r--r-- 1 stephen stephen 2.1K Nov 14 17:16 
dist/public/pages/style-guide.321103ee6d3cd65b02fa.js
-rw-r--r-- 1 stephen stephen 9.3K Nov 14 17:16 
dist/public/pages/summary.83f637816846eb5a3a81.js
-rw-r--r-- 1 stephen stephen  12K Nov 14 17:16 
dist/public/pages/wiki.8efe1fe209478967f36a.js
-rw-r--r-- 1 stephen stephen 1.8K Nov 14 17:16 
dist/public/runtime.2b1cbfe22278e0f7cb27.js
-rw-r--r-- 1 stephen stephen 1.8K Nov 14 17:16 
dist/public/runtime.2b1cbfe22278e0f7cb27.js
-rw-r--r-- 1 stephen stephen  22K Nov 14 17:16 
dist/public/vendor.ddf5e72cf229878fcbb3.js
-rw-r--r-- 1 stephen stephen  22K Nov 14 17:16 
dist/public/vendor.ddf5e72cf229878fcbb3.js

A change is necessary to the Mocha configuration to enable general
__non_webpack_require__ usage.

Bug: T177235
Change-Id: Ibc588e80855dc4880584ba15cf34912a3e4af0f7
---
M src/common/marshallers/page-summary/page-summary-unmarshaller.ts
M test/mocha.opts
A test/set-up.ts
M webpack.config.ts
4 files changed, 8 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/marvin refs/changes/63/391363/1

diff --git a/src/common/marshallers/page-summary/page-summary-unmarshaller.ts 
b/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
index 441a1d1..27ac7d0 100644
--- a/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
+++ b/src/common/marshallers/page-summary/page-summary-unmarshaller.ts
@@ -9,6 +9,7 @@
   unmarshalETag
 } from "../page-base/page-base-unmarshaller";
 import { RESTBase } from "../restbase";
+declare function __non_webpack_require__(name: string): any; // 
eslint-disable-line camelcase
 
 export const unmarshalPageThumbnail = (json: JSONObject): PageThumbnail => {
   const type: RESTBase.PageSummary.Thumbnail = json as any;
@@ -31,9 +32,9 @@
   };
 };
 
-// todo: remove this function and Domino package from package*.json, the
-//       corresponding Webpack IgnorePlugin, and the Domino typing, when
-//       isomorphic HTML parsing is unneeded. Some other options explored:
+// todo: remove this function and Domino package from package*.json and the
+//       Domino typing, when isomorphic HTML parsing is unneeded. Some other
+//       options explored:
 // - undom advertises itself as "DOM but not a parser". Parsing, serialization,
 //   and selectors are all unsupported. There is a recipe for rudimentary
 //   serialization but the real issue is the lack of a parser which is 
essential
@@ -58,7 +59,7 @@
 const parseExtractHTML = (extractHTML: string) => {
   const element =
     typeof document === "undefined"
-      ? require("domino").createDocument().body
+      ? __non_webpack_require__("domino").createDocument().body
       : document.implementation.createHTMLDocument("").body;
   element.innerHTML = extractHTML;
 
diff --git a/test/mocha.opts b/test/mocha.opts
index cc8598a..fa4cf58 100644
--- a/test/mocha.opts
+++ b/test/mocha.opts
@@ -1,2 +1,3 @@
 --require ts-node/register
 --require ignore-styles
+--require test/set-up
diff --git a/test/set-up.ts b/test/set-up.ts
new file mode 100644
index 0000000..d399eb5
--- /dev/null
+++ b/test/set-up.ts
@@ -0,0 +1,2 @@
+// Mocha doesn't use the Webpack output.
+(global as any).__non_webpack_require__ = require;
diff --git a/webpack.config.ts b/webpack.config.ts
index ab4ec7e..a350ec3 100644
--- a/webpack.config.ts
+++ b/webpack.config.ts
@@ -198,8 +198,6 @@
 config.plugins = [
   new CleanPlugin(["dist"], { verbose: VERBOSE }),
 
-  new webpack.IgnorePlugin(/domino/),
-
   // Embed values of process.env.NODE_ENV and other variables in the code.
   // This allows to embed information in the source itself at build time, and 
it
   // is used for example to have uglify remove code at minification time,

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibc588e80855dc4880584ba15cf34912a3e4af0f7
Gerrit-PatchSet: 1
Gerrit-Project: marvin
Gerrit-Branch: master
Gerrit-Owner: Niedzielski <sniedziel...@wikimedia.org>
Gerrit-Reviewer: Sniedzielski <sniedziel...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to