Repository navigation
Conversation
|
manually tested that this works with webpack using https://gist.github.com/mollymerp/369e1287a473966e29fe92569495687e and editing the |
|
@mollymerp oooof thanks for figuring this out 😕 🏅 🌟 I wonder if we should add browserify and webpack build tests. Browserify would be easy to do without adding a new dependency. Webpack's a heavy dep to add just for a unit test... maybe we could do that one only on CI? |
|
cc @mourner @jfirebaugh as well -- note that this reverts the change @mourner proposed in #3551 |
|
Nothing here that we did have a webpack test at one point: f6bcd06#diff-cf4d6d7603881cba61aea62bcbf7e77d |
|
Did you uncover the root cause of the build failures? I would much prefer a solution that doesn't require special steps for either webpack of browserify. |
|
@lucaswoj I'm not 100% on this, but I think the problem is that a browserified bundle is not, in fact, a valid CommonJS module. In particular, my hypothesis is:
|
|
I believe the root cause is that because the bundle we create in the /dist folder is |
^ this might not be accurate, actually -- I think as Molly said it's a UMD module, which should work in a CommonJS environment (Node); but it doesn't work when re-browserified because of the |
|
Just found https://github.com/calvinmetcalf/derequire -- it's possible that including this transform when building |
|
To me this looks like a bug in browserify's static analysis. A very simple example that demonstrates what's going on is: If you attempt to browserify this, you get: Browserify shouldn't assume that any local variable that happens to be named |
|
@jfirebaugh yah, I agree, but I don't think we should count on it getting
fixed anytime soon, alas
…On Wed, Mar 22, 2017 at 7:18 PM John Firebaugh ***@***.***> wrote:
To me this looks like a bug in browserify's static analysis. A very simple
example that demonstrates what's going on is:
module.exports = function(require) {
require('nonesuch');
};
If you attempt to browserify this, you get:
Error: Cannot find module 'nonesuch' from '/Users/john/Development/mapbox-gl-js'
at /Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
at process (/Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:173:43)
at ondir (/Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:188:17)
at load (/Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
at onex (/Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
at /Users/john/Development/mapbox-gl-js/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:82:15)
Browserify shouldn't assume that any local variable that happens to be
named require refers to the global.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#4462 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEvmR1HxzJla4LRu7GPMMNbfa2LUJuNYks5roaw8gaJpZM4MjMos>
.
|
|
Agreed. In the meantime, derequire (or perhaps derequire-transform) looks like the most commonly used workaround. |
|
I'm enjoying this comment in the README of
since that's exactly what browserify does. |
|
The derequire approach works! #4486 |
Potential fix for the ongoing webpack saga 😭
@anandthakker @lucaswoj
Launch Checklist