From 016a4586b8be4446bfa4fd14413eaa6be43e06e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Mon, 21 Nov 2016 21:59:52 -0800 Subject: [PATCH 1/3] Fix browser bundle for AMD --- grunt/config/browserify.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/grunt/config/browserify.js b/grunt/config/browserify.js index 282c003d61b6b..6e410b59c726a 100644 --- a/grunt/config/browserify.js +++ b/grunt/config/browserify.js @@ -74,7 +74,12 @@ function simpleBannerify(src) { // variable. So we write a wrapper around the UMD bundle that browserify creates, // and define a React variable that will require across Webpack-boundaries or fall // back to the global, just like it would previously. +// Additionally, we're going to modify the original UMD wrapper a bit, replacing +// the define([], f) call with f(). This allows our additional wrapper to work +// so we can define() there without issue (AMD was causing issues). If you +// think this is all a bit insane, you are absolutely correct. function wrapperify(src) { + src = src.replace('define([],f)', 'return f()'); return ` ;(function(f) { // CommonJS @@ -83,7 +88,7 @@ function wrapperify(src) { // RequireJS } else if (typeof define === "function" && define.amd) { - require(['react'], f); + define(['react'], f); //