Skip to content

ReferenceError: require is not defined #39

@goto-bus-stop

Description

@goto-bus-stop

@ungoldman found a problem with the change in #38:

15:05 < ungoldman> final note, error seems to be originating from here
                   https://github.com/puleos/object-hash/blob/master/dist/object_hash.js
15:05 < ungoldman> https://usercontent.irccloud-cdn.com/file/6MtxkWve/Screen%20Shot%202019-05-24%20at%2012.05.22%20PM.png
15:05 < ungoldman> source map is broken so hard to find exact spot
15:05 < ungoldman> ok bbiab
15:06 < goto-bus-stop> ohhhh
15:07 < goto-bus-stop> ok i see it
15:07 < goto-bus-stop> i think :P
15:07 < goto-bus-stop> it's already a browserified bundle, and the browserify prelude looks for `require` and
                       tries to use it at runtime if it exists
15:08 < goto-bus-stop> but now i'm claiming it exists while it does not

browserify standalone bundles do

var externalRequire = typeof require === 'function'&&require

…which now breaks.

not sure what the best fix is, but it might be enough to simply add a check for the && require bit—default browserify and browser-pack-flat both use that pattern for external requires and we shouldn't muck with it. Worth checking out what webpack does (though i would guess they don't actually check for external require at all)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions