question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using Browserify and RequireJS on the same page?

See original GitHub issue

So i’ve come across an interesting use case where i’m using Browserify to bundle all of my assets together in a project, but a large external (external to the project) module needs to be loaded in when a certain in-app window is accessed. (It’s a video player module made up of three scripts that get pulled in asynchronously when required).

At the moment i’m getting all kinds of errors from uncalled object errors if the requireJS module is loaded in before the Browserified app.js file, to cannot find module errors if loaded in after the Browserified code.

Is there anyway i can get Browserify and RequireJS to play nicely on the same page? I’m losing my mind!

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:3
  • Comments:18

github_iconTop GitHub Comments

1reaction
Pupixcommented, Oct 1, 2015

We had a similar problem, using the --standalone option. If a user was using requirejs, our module would never reach the window, thus making a few web components that needed to access the library through window unusable.

Our fix was to remove the AMD module check and let browserify assign the variable to window. https://github.com/expandjs/expandjs/commit/32765905ea2cb0815f115867e11db192856541e5

1reaction
currancommented, Feb 21, 2015

You can avoid the conflict by changing your AMD code to use the requirejs global rather than the require global, and only have the Browserified code use require. This solution worked for me for having AMD modules and Browserified modules on the same page.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using Browserify and RequireJS on the same page?
So i've come across an interesting use case where i'm using Browserify to bundle all of my assets together in a project, but...
Read more >
Is it possible to use Browserify and RequireJS on the same ...
I'm really only just getting the hang of modular coding. Browserify is really nice, and is quite easy to get up and running...
Read more >
Javascript – Using Browserify and RequireJS on the same page ...
So i've come across an interesting use case where i'm using Browserify to bundle all of my assets together in a project, but...
Read more >
A Journey From Require.js to Browserify - Orizens
Require.js has support both for the AMD & CommonJS specs for module definition as well as for loading incompatible files with these specs....
Read more >
Browserify Tutorial - Using require() In The Browser - YouTube
Learn how to use the require() function to import Javascript modules in the front-end part of your web application ( in the browser)...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found