Bug ACTIVITY-STREAM: build using webpack draft
authorDan Mosedale <dmose@meer.net>
Tue, 15 May 2018 18:00:52 -0700
changeset 795822 9191c6b8911d07732e785142f0abff235280133a
parent 795821 405890b036d5a61fa5c183f082d4622bb65b0b46
child 795823 f9ea73c690e3bd8eb01a90dc8497bd3781fd4890
push id110091
push userbmo:dmose@mozilla.org
push dateWed, 16 May 2018 16:58:05 +0000
milestone62.0a1
Bug ACTIVITY-STREAM: build using webpack
browser/extensions/activity-stream/jar.mn
browser/extensions/activity-stream/moz.build
browser/extensions/activity-stream/webpack.system-addon.config.js
--- a/browser/extensions/activity-stream/jar.mn
+++ b/browser/extensions/activity-stream/jar.mn
@@ -14,20 +14,22 @@
   content/vendor/react-dom-dev.js (./vendor/react-dom-dev.js)
 #endif
   content/vendor/prop-types.js (./vendor/prop-types.js)
   content/vendor/react-intl.js (./vendor/react-intl.js)
   content/vendor/redux.js (./vendor/redux.js)
   content/vendor/react-redux.js (./vendor/react-redux.js)
   content/data/content/assets/ (./data/content/assets/*)
   content/data/content/tippytop/ (./data/content/tippytop/*)
+#ifndef NODE_ENVIRONMENT
   content/data/content/activity-stream.bundle.js (./data/content/activity-stream.bundle.js)
 #ifndef RELEASE_OR_BETA
   content/data/content/activity-stream.bundle.js.map (./data/content/activity-stream.bundle.js.map)
 #endif
+#endif # NODE_ENVIRONMENT
 #ifdef XP_MACOSX
   content/css/activity-stream.css (./css/activity-stream-mac.css)
 #ifndef RELEASE_OR_BETA
   content/css/activity-stream-mac.css.map (./css/activity-stream-mac.css.map)
 #endif
 #elifdef XP_WIN
   content/css/activity-stream.css (./css/activity-stream-windows.css)
 #ifndef RELEASE_OR_BETA
--- a/browser/extensions/activity-stream/moz.build
+++ b/browser/extensions/activity-stream/moz.build
@@ -4,20 +4,42 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 with Files("**"):
     BUG_COMPONENT = ("Firefox", "Activity Streams: Newtab")
 
 DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
 DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
+DEFINES['NODE_ENVIRONMENT'] = CONFIG['NODE_ENVIRONMENT']
 
 FINAL_TARGET_FILES.features['activity-stream@mozilla.org'] += [
   'bootstrap.js',
 ]
 
 FINAL_TARGET_PP_FILES.features['activity-stream@mozilla.org'] += [
   'install.rdf.in'
 ]
 
 JAR_MANIFESTS += ['jar.mn']
 
 BROWSER_CHROME_MANIFESTS += ['test/functional/mochitest/browser.ini']
+
+if CONFIG['NODE_ENVIRONMENT']:
+    t = ('activity_stream_bundle', 'activity-stream.bundle.js', 'activity-stream.bundle.js.map')
+    GENERATED_FILES += [t]
+
+    bundle = GENERATED_FILES[t]
+    bundle.script = '/python/mozbuild/mozbuild/action/yarn.py'
+    bundle.inputs = ['package.json']
+    bundle.flags = ['run', 'buildmc:webpack', '--', '--output-path', OBJDIR]
+
+    # FINAL_TARGET_FILES forces two build invocations when we just want one
+    # file_generate action to produce multiple files.  TODO: Teach FasterMake to
+    # handle tuple outputs better.
+
+    FINAL_TARGET_FILES.features['activity-stream@mozilla.org'].chrome.content.data.content += [
+        '!activity-stream.bundle.js',
+    ]
+    if not CONFIG['RELEASE_OR_BETA']:
+        FINAL_TARGET_FILES.features['activity-stream@mozilla.org'].chrome.content.data.content += [
+            '!activity-stream.bundle.js.map',
+        ]
--- a/browser/extensions/activity-stream/webpack.system-addon.config.js
+++ b/browser/extensions/activity-stream/webpack.system-addon.config.js
@@ -42,8 +42,22 @@ module.exports = {
     "prop-types": "PropTypes",
     "react": "React",
     "react-dom": "ReactDOM",
     "react-intl": "ReactIntl",
     "redux": "Redux",
     "react-redux": "ReactRedux"
   }
 };
+
+// If we're running under mozilla-central's build system, resolve
+// Babel modules from the special _node/node_modules tree in the
+// object directory.
+const topobjdir = process.env["MOZ_DEVELOPER_OBJ_DIR"];
+if (topobjdir) {
+  Object.assign(module.exports, {
+    resolveLoader: {
+      modules: [
+        topobjdir + path.sep + "_node" + path.sep + "node_modules",
+      ],
+    },
+  });
+}